Update app.py
Browse files
app.py
CHANGED
|
@@ -221,6 +221,11 @@ if __name__ == "__main__":
|
|
| 221 |
checkbox_label_text_color_selected="*button_primary_text_color",
|
| 222 |
)
|
| 223 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
.custom-log * {
|
| 225 |
font-style: italic;
|
| 226 |
font-size: 22px !important;
|
|
@@ -259,11 +264,6 @@ if __name__ == "__main__":
|
|
| 259 |
}
|
| 260 |
"""
|
| 261 |
with gr.Blocks(css=css, title="AnySplat Demo", theme=theme) as demo:
|
| 262 |
-
gr.Markdown(
|
| 263 |
-
"""
|
| 264 |
-
<h1 style='text-align: center;'>AnySplat: Feed-forward 3D Gaussian Splatting from Unconstrained Views</h1>
|
| 265 |
-
"""
|
| 266 |
-
)
|
| 267 |
|
| 268 |
gr.Markdown(
|
| 269 |
""" # AnySplat – Feed-forward 3D Gaussian Splatting from Unconstrained Views
|
|
@@ -279,128 +279,129 @@ if __name__ == "__main__":
|
|
| 279 |
scene_name = gr.Textbox(label="scene_name", visible=False, value="None")
|
| 280 |
image_type = gr.Textbox(label="image_type", visible=False, value="None")
|
| 281 |
|
| 282 |
-
with gr.
|
| 283 |
-
with gr.
|
| 284 |
-
input_video = gr.Video(label="Upload Video", interactive=True)
|
| 285 |
-
input_images = gr.File(
|
| 286 |
-
file_count="multiple",
|
| 287 |
-
label="Upload Images",
|
| 288 |
-
interactive=True,
|
| 289 |
-
)
|
| 290 |
-
|
| 291 |
-
image_gallery = gr.Gallery(
|
| 292 |
-
label="Preview",
|
| 293 |
-
columns=4,
|
| 294 |
-
height="300px",
|
| 295 |
-
show_download_button=True,
|
| 296 |
-
object_fit="contain",
|
| 297 |
-
preview=True,
|
| 298 |
-
)
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
with gr.Column():
|
| 302 |
with gr.Column():
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
)
|
| 310 |
|
| 311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
with gr.Row():
|
| 313 |
-
|
| 314 |
-
|
| 315 |
)
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
)
|
| 321 |
-
|
| 322 |
-
with gr.Row():
|
| 323 |
-
submit_btn = gr.Button(
|
| 324 |
-
"Reconstruct", scale=1, variant="primary"
|
| 325 |
-
)
|
| 326 |
-
clear_btn = gr.ClearButton(
|
| 327 |
-
[
|
| 328 |
-
input_video,
|
| 329 |
-
input_images,
|
| 330 |
-
reconstruction_output,
|
| 331 |
-
target_dir_output,
|
| 332 |
-
image_gallery,
|
| 333 |
-
rgb_video,
|
| 334 |
-
depth_video,
|
| 335 |
-
],
|
| 336 |
-
scale=1,
|
| 337 |
-
)
|
| 338 |
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
input_images,
|
| 361 |
-
input_video,
|
| 362 |
-
dataset_name,
|
| 363 |
-
scene_name,
|
| 364 |
-
num_images_str,
|
| 365 |
-
image_type,
|
| 366 |
-
is_example,
|
| 367 |
-
):
|
| 368 |
-
"""
|
| 369 |
-
1) Copy example images to new target_dir
|
| 370 |
-
2) Reconstruct
|
| 371 |
-
3) Return model3D + logs + new_dir + updated dropdown + gallery
|
| 372 |
-
We do NOT return is_example. It's just an input.
|
| 373 |
-
"""
|
| 374 |
-
target_dir, image_paths = handle_uploads(input_video, input_images)
|
| 375 |
-
plyfile, video, depth_colored = gradio_demo(target_dir)
|
| 376 |
-
return plyfile, video, depth_colored, target_dir, image_paths
|
| 377 |
-
|
| 378 |
-
gr.Markdown("Click any row to load an example.", elem_classes=["example-log"])
|
| 379 |
-
|
| 380 |
-
gr.Examples(
|
| 381 |
-
examples=examples,
|
| 382 |
-
inputs=[
|
| 383 |
input_images,
|
| 384 |
input_video,
|
| 385 |
dataset_name,
|
| 386 |
scene_name,
|
| 387 |
-
|
| 388 |
image_type,
|
| 389 |
is_example,
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
|
| 405 |
submit_btn.click(
|
| 406 |
fn=clear_fields,
|
|
|
|
| 221 |
checkbox_label_text_color_selected="*button_primary_text_color",
|
| 222 |
)
|
| 223 |
css = """
|
| 224 |
+
#col-container {
|
| 225 |
+
margin: 0 auto;
|
| 226 |
+
max-width: 1024px;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
.custom-log * {
|
| 230 |
font-style: italic;
|
| 231 |
font-size: 22px !important;
|
|
|
|
| 264 |
}
|
| 265 |
"""
|
| 266 |
with gr.Blocks(css=css, title="AnySplat Demo", theme=theme) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
|
| 268 |
gr.Markdown(
|
| 269 |
""" # AnySplat – Feed-forward 3D Gaussian Splatting from Unconstrained Views
|
|
|
|
| 279 |
scene_name = gr.Textbox(label="scene_name", visible=False, value="None")
|
| 280 |
image_type = gr.Textbox(label="image_type", visible=False, value="None")
|
| 281 |
|
| 282 |
+
with gr.Column(elem_id="col-container"):
|
| 283 |
+
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
with gr.Column():
|
| 285 |
+
input_video = gr.Video(label="Upload Video", interactive=True)
|
| 286 |
+
input_images = gr.File(
|
| 287 |
+
file_count="multiple",
|
| 288 |
+
label="Upload Images",
|
| 289 |
+
interactive=True,
|
| 290 |
+
)
|
| 291 |
+
|
| 292 |
+
image_gallery = gr.Gallery(
|
| 293 |
+
label="Preview",
|
| 294 |
+
columns=4,
|
| 295 |
+
height="300px",
|
| 296 |
+
show_download_button=True,
|
| 297 |
+
object_fit="contain",
|
| 298 |
+
preview=True,
|
| 299 |
)
|
| 300 |
|
| 301 |
+
|
| 302 |
+
with gr.Column():
|
| 303 |
+
with gr.Column():
|
| 304 |
+
reconstruction_output = gr.Model3D(
|
| 305 |
+
label="3D Reconstructed Gaussian Splat",
|
| 306 |
+
height=540,
|
| 307 |
+
zoom_speed=0.5,
|
| 308 |
+
pan_speed=0.5,
|
| 309 |
+
camera_position=[20, 20, 20],
|
| 310 |
+
)
|
| 311 |
+
|
| 312 |
+
with gr.Row():
|
| 313 |
+
with gr.Row():
|
| 314 |
+
rgb_video = gr.Video(
|
| 315 |
+
label="RGB Video", interactive=False, autoplay=True
|
| 316 |
+
)
|
| 317 |
+
depth_video = gr.Video(
|
| 318 |
+
label="Depth Video",
|
| 319 |
+
interactive=False,
|
| 320 |
+
autoplay=True,
|
| 321 |
+
)
|
| 322 |
+
|
| 323 |
with gr.Row():
|
| 324 |
+
submit_btn = gr.Button(
|
| 325 |
+
"Reconstruct", scale=1, variant="primary"
|
| 326 |
)
|
| 327 |
+
clear_btn = gr.ClearButton(
|
| 328 |
+
[
|
| 329 |
+
input_video,
|
| 330 |
+
input_images,
|
| 331 |
+
reconstruction_output,
|
| 332 |
+
target_dir_output,
|
| 333 |
+
image_gallery,
|
| 334 |
+
rgb_video,
|
| 335 |
+
depth_video,
|
| 336 |
+
],
|
| 337 |
+
scale=1,
|
| 338 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
|
| 340 |
+
# ---------------------- Examples section ----------------------
|
| 341 |
+
|
| 342 |
+
examples = [
|
| 343 |
+
[None, "examples/video/re10k_1eca36ec55b88fe4.mp4", "re10k", "1eca36ec55b88fe4", "2", "Real", "True",],
|
| 344 |
+
[None, "examples/video/bungeenerf_colosseum.mp4", "bungeenerf", "colosseum", "8", "Synthetic", "True",],
|
| 345 |
+
[None, "examples/video/fox.mp4", "InstantNGP", "fox", "14", "Real", "True",],
|
| 346 |
+
[None, "examples/video/matrixcity_street.mp4", "matrixcity", "street", "32", "Synthetic", "True",],
|
| 347 |
+
[None, "examples/video/vrnerf_apartment.mp4", "vrnerf", "apartment", "32", "Real", "True",],
|
| 348 |
+
[None, "examples/video/vrnerf_kitchen.mp4", "vrnerf", "kitchen", "17", "Real", "True",],
|
| 349 |
+
[None, "examples/video/vrnerf_riverview.mp4", "vrnerf", "riverview", "12", "Real", "True",],
|
| 350 |
+
[None, "examples/video/vrnerf_workshop.mp4", "vrnerf", "workshop", "32", "Real", "True",],
|
| 351 |
+
[None, "examples/video/fillerbuster_ramen.mp4", "fillerbuster", "ramen", "32", "Real", "True",],
|
| 352 |
+
[None, "examples/video/meganerf_rubble.mp4", "meganerf", "rubble", "10", "Real", "True",],
|
| 353 |
+
[None, "examples/video/llff_horns.mp4", "llff", "horns", "12", "Real", "True",],
|
| 354 |
+
[None, "examples/video/llff_fortress.mp4", "llff", "fortress", "7", "Real", "True",],
|
| 355 |
+
[None, "examples/video/dtu_scan_106.mp4", "dtu", "scan_106", "20", "Real", "True",],
|
| 356 |
+
[None, "examples/video/horizongs_hillside_summer.mp4", "horizongs", "hillside_summer", "55", "Synthetic", "True",],
|
| 357 |
+
[None, "examples/video/kitti360.mp4", "kitti360", "kitti360", "64", "Real", "True",],
|
| 358 |
+
]
|
| 359 |
+
|
| 360 |
+
def example_pipeline(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
input_images,
|
| 362 |
input_video,
|
| 363 |
dataset_name,
|
| 364 |
scene_name,
|
| 365 |
+
num_images_str,
|
| 366 |
image_type,
|
| 367 |
is_example,
|
| 368 |
+
):
|
| 369 |
+
"""
|
| 370 |
+
1) Copy example images to new target_dir
|
| 371 |
+
2) Reconstruct
|
| 372 |
+
3) Return model3D + logs + new_dir + updated dropdown + gallery
|
| 373 |
+
We do NOT return is_example. It's just an input.
|
| 374 |
+
"""
|
| 375 |
+
target_dir, image_paths = handle_uploads(input_video, input_images)
|
| 376 |
+
plyfile, video, depth_colored = gradio_demo(target_dir)
|
| 377 |
+
return plyfile, video, depth_colored, target_dir, image_paths
|
| 378 |
+
|
| 379 |
+
gr.Markdown("Click any row to load an example.", elem_classes=["example-log"])
|
| 380 |
+
|
| 381 |
+
gr.Examples(
|
| 382 |
+
examples=examples,
|
| 383 |
+
inputs=[
|
| 384 |
+
input_images,
|
| 385 |
+
input_video,
|
| 386 |
+
dataset_name,
|
| 387 |
+
scene_name,
|
| 388 |
+
num_images,
|
| 389 |
+
image_type,
|
| 390 |
+
is_example,
|
| 391 |
+
],
|
| 392 |
+
outputs=[
|
| 393 |
+
reconstruction_output,
|
| 394 |
+
rgb_video,
|
| 395 |
+
depth_video,
|
| 396 |
+
target_dir_output,
|
| 397 |
+
image_gallery,
|
| 398 |
+
],
|
| 399 |
+
fn=example_pipeline,
|
| 400 |
+
cache_examples=False,
|
| 401 |
+
examples_per_page=50,
|
| 402 |
+
)
|
| 403 |
+
|
| 404 |
+
gr.Markdown("<p style='text-align: center; font-style: italic; color: #666;'>We thank VGGT for their excellent gradio implementation!</p>")
|
| 405 |
|
| 406 |
submit_btn.click(
|
| 407 |
fn=clear_fields,
|