Spaces:
Configuration error
Configuration error
Commit ·
31efb4c
1
Parent(s): f76a387
Add examples (stored with Xet)
Browse files- .gitattributes +2 -0
- .gitignore +1 -0
- app.py +110 -3
- examples/flower/IMG_6699.PNG +3 -0
- examples/flower/IMG_6700.PNG +3 -0
- examples/flower/IMG_6701.PNG +3 -0
- examples/flower/IMG_6702.PNG +3 -0
- examples/friends/Screenshot 2025-11-05 at 23.37.49.png +3 -0
- examples/friends/Screenshot 2025-11-05 at 23.38.02.png +3 -0
- examples/friends/Screenshot 2025-11-05 at 23.38.19.png +3 -0
- examples/friends/Screenshot 2025-11-05 at 23.39.15.png +3 -0
- examples/friends/Screenshot 2025-11-05 at 23.39.58.png +3 -0
- examples/kitchen/frame_0000006347.jpg +3 -0
- examples/kitchen/frame_0000006355.jpg +3 -0
- examples/kitchen/frame_0000006368.jpg +3 -0
- examples/kitchen/frame_0000006376.jpg +3 -0
- examples/kitchen/frame_0000006397.jpg +3 -0
- examples/mall/Screenshot 2025-11-05 at 17.20.26.png +3 -0
- examples/mall/Screenshot 2025-11-05 at 17.21.11.png +3 -0
- examples/mall/Screenshot 2025-11-05 at 17.21.46.png +3 -0
- examples/mall/Screenshot 2025-11-05 at 17.22.03.png +3 -0
- examples/mall/Screenshot 2025-11-05 at 17.22.20.png +3 -0
- examples/mall/Screenshot 2025-11-05 at 17.22.33.png +3 -0
- examples/mall/Screenshot 2025-11-05 at 17.22.46.png +3 -0
- examples/mall/Screenshot 2025-11-05 at 17.23.00.png +3 -0
- examples/outdoor/IMG_5115.jpg +3 -0
- examples/outdoor/IMG_5117.jpg +3 -0
- examples/outdoor/IMG_5118.jpg +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
examples/** filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
examples/ filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
app.py
CHANGED
|
@@ -156,7 +156,9 @@ def predictions_to_glb(
|
|
| 156 |
# Rotate scene for better visualize
|
| 157 |
align_rotation = np.eye(4)
|
| 158 |
align_rotation[:3, :3] = Rotation.from_euler("y", 100, degrees=True).as_matrix() # plane rotate
|
| 159 |
-
align_rotation[:3, :3] = align_rotation[:3, :3] @ Rotation.from_euler("x",
|
|
|
|
|
|
|
| 160 |
scene_3d.apply_transform(align_rotation)
|
| 161 |
|
| 162 |
print("GLB Scene built")
|
|
@@ -548,6 +550,72 @@ def update_visualization(
|
|
| 548 |
# Example images
|
| 549 |
# -------------------------------------------------------------------------
|
| 550 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
great_wall_video = "examples/videos/great_wall.mp4"
|
| 552 |
colosseum_video = "examples/videos/Colosseum.mp4"
|
| 553 |
room_video = "examples/videos/room.mp4"
|
|
@@ -611,9 +679,9 @@ with gr.Blocks(
|
|
| 611 |
# Instead of gr.State, we use a hidden Textbox:
|
| 612 |
is_example = gr.Textbox(label="is_example", visible=False, value="None")
|
| 613 |
num_images = gr.Textbox(label="num_images", visible=False, value="None")
|
| 614 |
-
|
| 615 |
gr.HTML(
|
| 616 |
-
|
| 617 |
<h1>Flow3r: Factored Flow Prediction for Visual Geometry Learning</h1>
|
| 618 |
<p>
|
| 619 |
<a href="https://github.com/Kidrauh/flow3r">GitHub Repository</a> |
|
|
@@ -730,4 +798,43 @@ with gr.Blocks(
|
|
| 730 |
inputs=[input_video, input_images],
|
| 731 |
outputs=[reconstruction_output, target_dir_output, image_gallery, log_output],
|
| 732 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 733 |
demo.queue(max_size=20).launch(show_error=True, share=True, ssr_mode=False)
|
|
|
|
| 156 |
# Rotate scene for better visualize
|
| 157 |
align_rotation = np.eye(4)
|
| 158 |
align_rotation[:3, :3] = Rotation.from_euler("y", 100, degrees=True).as_matrix() # plane rotate
|
| 159 |
+
align_rotation[:3, :3] = align_rotation[:3, :3] @ Rotation.from_euler("x", 208, degrees=True).as_matrix() # roll
|
| 160 |
+
align_rotation[:3, :3] = align_rotation[:3, :3] @ Rotation.from_euler("y", 180, degrees=True).as_matrix() # roll
|
| 161 |
+
align_rotation[:3, :3] = align_rotation[:3, :3] @ Rotation.from_euler("z", 350, degrees=True).as_matrix() # roll
|
| 162 |
scene_3d.apply_transform(align_rotation)
|
| 163 |
|
| 164 |
print("GLB Scene built")
|
|
|
|
| 550 |
# Example images
|
| 551 |
# -------------------------------------------------------------------------
|
| 552 |
|
| 553 |
+
EXAMPLES_BASE_DIR = os.path.join(os.path.dirname(__file__), "examples")
|
| 554 |
+
|
| 555 |
+
def build_example_index(base_dir: str):
|
| 556 |
+
examples = []
|
| 557 |
+
if not os.path.isdir(base_dir):
|
| 558 |
+
return examples
|
| 559 |
+
for folder in sorted(os.listdir(base_dir)):
|
| 560 |
+
full_path = os.path.join(base_dir, folder)
|
| 561 |
+
if not os.path.isdir(full_path):
|
| 562 |
+
continue
|
| 563 |
+
images = [
|
| 564 |
+
os.path.join(full_path, name)
|
| 565 |
+
for name in sorted(os.listdir(full_path))
|
| 566 |
+
if name.lower().endswith((".png", ".jpg", ".jpeg", ".webp"))
|
| 567 |
+
]
|
| 568 |
+
if not images:
|
| 569 |
+
continue
|
| 570 |
+
examples.append(
|
| 571 |
+
{
|
| 572 |
+
"name": folder,
|
| 573 |
+
"thumb": images[0],
|
| 574 |
+
"images": images,
|
| 575 |
+
}
|
| 576 |
+
)
|
| 577 |
+
return examples[:5]
|
| 578 |
+
|
| 579 |
+
|
| 580 |
+
EXAMPLE_DATA = build_example_index(EXAMPLES_BASE_DIR)
|
| 581 |
+
EXAMPLE_THUMBNAILS = [item["thumb"] for item in EXAMPLE_DATA]
|
| 582 |
+
EXAMPLE_BY_THUMB = {os.path.abspath(item["thumb"]): item for item in EXAMPLE_DATA}
|
| 583 |
+
|
| 584 |
+
|
| 585 |
+
def _normalize_gallery_value(value):
|
| 586 |
+
if value is None:
|
| 587 |
+
return None
|
| 588 |
+
if isinstance(value, dict):
|
| 589 |
+
value = value.get("name")
|
| 590 |
+
if isinstance(value, (list, tuple)) and value:
|
| 591 |
+
value = value[0]
|
| 592 |
+
if isinstance(value, str):
|
| 593 |
+
return os.path.abspath(value)
|
| 594 |
+
return None
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
def select_example(evt: gr.SelectData):
|
| 598 |
+
if evt is None:
|
| 599 |
+
return None, gr.update(), gr.update(), "No example selected.", "False", gr.update(selected_index=None)
|
| 600 |
+
|
| 601 |
+
example = None
|
| 602 |
+
selected_path = _normalize_gallery_value(getattr(evt, "value", None))
|
| 603 |
+
if selected_path:
|
| 604 |
+
example = EXAMPLE_BY_THUMB.get(selected_path)
|
| 605 |
+
|
| 606 |
+
if example is None and getattr(evt, "index", None) is not None:
|
| 607 |
+
idx = evt.index[0] if isinstance(evt.index, (list, tuple)) else evt.index
|
| 608 |
+
if isinstance(idx, int) and 0 <= idx < len(EXAMPLE_DATA):
|
| 609 |
+
example = EXAMPLE_DATA[idx]
|
| 610 |
+
|
| 611 |
+
if example is None:
|
| 612 |
+
return None, gr.update(), gr.update(), "No example selected.", "False", gr.update(selected_index=None)
|
| 613 |
+
|
| 614 |
+
target_dir, image_paths = handle_uploads(None, example["images"])
|
| 615 |
+
log_msg = f"Example '{example['name']}' loaded. Click 'Reconstruct' to begin 3D processing."
|
| 616 |
+
return None, target_dir, image_paths, log_msg, "False", gr.update(selected_index=None)
|
| 617 |
+
|
| 618 |
+
|
| 619 |
great_wall_video = "examples/videos/great_wall.mp4"
|
| 620 |
colosseum_video = "examples/videos/Colosseum.mp4"
|
| 621 |
room_video = "examples/videos/room.mp4"
|
|
|
|
| 679 |
# Instead of gr.State, we use a hidden Textbox:
|
| 680 |
is_example = gr.Textbox(label="is_example", visible=False, value="None")
|
| 681 |
num_images = gr.Textbox(label="num_images", visible=False, value="None")
|
| 682 |
+
|
| 683 |
gr.HTML(
|
| 684 |
+
"""
|
| 685 |
<h1>Flow3r: Factored Flow Prediction for Visual Geometry Learning</h1>
|
| 686 |
<p>
|
| 687 |
<a href="https://github.com/Kidrauh/flow3r">GitHub Repository</a> |
|
|
|
|
| 798 |
inputs=[input_video, input_images],
|
| 799 |
outputs=[reconstruction_output, target_dir_output, image_gallery, log_output],
|
| 800 |
)
|
| 801 |
+
|
| 802 |
+
# -------------------------------------------------------------------------
|
| 803 |
+
# Examples
|
| 804 |
+
# -------------------------------------------------------------------------
|
| 805 |
+
gr.Markdown("**Examples**")
|
| 806 |
+
gr.Markdown("Click any image to load an example.")
|
| 807 |
+
example_gallery = gr.Gallery(
|
| 808 |
+
value=[],
|
| 809 |
+
columns=5,
|
| 810 |
+
height="140px",
|
| 811 |
+
object_fit="contain",
|
| 812 |
+
label="Example Sets",
|
| 813 |
+
show_label=False,
|
| 814 |
+
preview=False,
|
| 815 |
+
selected_index=None,
|
| 816 |
+
)
|
| 817 |
+
example_gallery.select(
|
| 818 |
+
fn=select_example,
|
| 819 |
+
inputs=[],
|
| 820 |
+
outputs=[reconstruction_output, target_dir_output, image_gallery, log_output, is_example, example_gallery],
|
| 821 |
+
).then(
|
| 822 |
+
fn=update_log, inputs=[], outputs=[log_output]
|
| 823 |
+
).then(
|
| 824 |
+
fn=gradio_demo,
|
| 825 |
+
inputs=[
|
| 826 |
+
target_dir_output,
|
| 827 |
+
conf_thres,
|
| 828 |
+
frame_filter,
|
| 829 |
+
show_cam,
|
| 830 |
+
],
|
| 831 |
+
outputs=[reconstruction_output, log_output, frame_filter],
|
| 832 |
+
).then(
|
| 833 |
+
fn=lambda: "False", inputs=[], outputs=[is_example]
|
| 834 |
+
)
|
| 835 |
+
demo.load(
|
| 836 |
+
fn=lambda: gr.update(value=EXAMPLE_THUMBNAILS, selected_index=None),
|
| 837 |
+
inputs=[],
|
| 838 |
+
outputs=[example_gallery],
|
| 839 |
+
)
|
| 840 |
demo.queue(max_size=20).launch(show_error=True, share=True, ssr_mode=False)
|
examples/flower/IMG_6699.PNG
ADDED
|
|
Git LFS Details
|
examples/flower/IMG_6700.PNG
ADDED
|
|
Git LFS Details
|
examples/flower/IMG_6701.PNG
ADDED
|
|
Git LFS Details
|
examples/flower/IMG_6702.PNG
ADDED
|
|
Git LFS Details
|
examples/friends/Screenshot 2025-11-05 at 23.37.49.png
ADDED
|
Git LFS Details
|
examples/friends/Screenshot 2025-11-05 at 23.38.02.png
ADDED
|
Git LFS Details
|
examples/friends/Screenshot 2025-11-05 at 23.38.19.png
ADDED
|
Git LFS Details
|
examples/friends/Screenshot 2025-11-05 at 23.39.15.png
ADDED
|
Git LFS Details
|
examples/friends/Screenshot 2025-11-05 at 23.39.58.png
ADDED
|
Git LFS Details
|
examples/kitchen/frame_0000006347.jpg
ADDED
|
Git LFS Details
|
examples/kitchen/frame_0000006355.jpg
ADDED
|
Git LFS Details
|
examples/kitchen/frame_0000006368.jpg
ADDED
|
Git LFS Details
|
examples/kitchen/frame_0000006376.jpg
ADDED
|
Git LFS Details
|
examples/kitchen/frame_0000006397.jpg
ADDED
|
Git LFS Details
|
examples/mall/Screenshot 2025-11-05 at 17.20.26.png
ADDED
|
Git LFS Details
|
examples/mall/Screenshot 2025-11-05 at 17.21.11.png
ADDED
|
Git LFS Details
|
examples/mall/Screenshot 2025-11-05 at 17.21.46.png
ADDED
|
Git LFS Details
|
examples/mall/Screenshot 2025-11-05 at 17.22.03.png
ADDED
|
Git LFS Details
|
examples/mall/Screenshot 2025-11-05 at 17.22.20.png
ADDED
|
Git LFS Details
|
examples/mall/Screenshot 2025-11-05 at 17.22.33.png
ADDED
|
Git LFS Details
|
examples/mall/Screenshot 2025-11-05 at 17.22.46.png
ADDED
|
Git LFS Details
|
examples/mall/Screenshot 2025-11-05 at 17.23.00.png
ADDED
|
Git LFS Details
|
examples/outdoor/IMG_5115.jpg
ADDED
|
Git LFS Details
|
examples/outdoor/IMG_5117.jpg
ADDED
|
Git LFS Details
|
examples/outdoor/IMG_5118.jpg
ADDED
|
Git LFS Details
|