Clara211111 commited on
Commit
31efb4c
·
1 Parent(s): f76a387

Add examples (stored with Xet)

Browse files
.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", 155, degrees=True).as_matrix() # roll
 
 
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

  • SHA256: 1405bb8f59317c3e2dc0a61920e9b9c33f1b26e5b3fc2ed407ba962223412b81
  • Pointer size: 132 Bytes
  • Size of remote file: 3.07 MB
examples/flower/IMG_6700.PNG ADDED

Git LFS Details

  • SHA256: dbe44ff50f220d03cc486810a85e9af96ebc9162eed8989589b799c900840008
  • Pointer size: 132 Bytes
  • Size of remote file: 2.89 MB
examples/flower/IMG_6701.PNG ADDED

Git LFS Details

  • SHA256: 4b70d988af906b124a723f429351206eca7f728f8c3cfb50e6c33ebbef7efa4c
  • Pointer size: 132 Bytes
  • Size of remote file: 2.85 MB
examples/flower/IMG_6702.PNG ADDED

Git LFS Details

  • SHA256: bebb00522853963688c909805876118d223de49da7c09f254efed7f6c3388aaa
  • Pointer size: 132 Bytes
  • Size of remote file: 2.92 MB
examples/friends/Screenshot 2025-11-05 at 23.37.49.png ADDED

Git LFS Details

  • SHA256: da2981d9b93a3d25bf47f9d30ef777627835155a92d2b949df26894696e7ad41
  • Pointer size: 131 Bytes
  • Size of remote file: 299 kB
examples/friends/Screenshot 2025-11-05 at 23.38.02.png ADDED

Git LFS Details

  • SHA256: 3b9f5477dd17cab591cea5a11b9e19f4a6636b5dfe1a0a928da7f908f005046e
  • Pointer size: 131 Bytes
  • Size of remote file: 392 kB
examples/friends/Screenshot 2025-11-05 at 23.38.19.png ADDED

Git LFS Details

  • SHA256: b28300b07339cf4e99e9a53ef56e298e6821a6af450bd8e37a74c86d4d3946ba
  • Pointer size: 131 Bytes
  • Size of remote file: 389 kB
examples/friends/Screenshot 2025-11-05 at 23.39.15.png ADDED

Git LFS Details

  • SHA256: 93aa84ae80a1d2af39ee4ad446beeaf539f79fcb93443e9ece567abbf9ec12a2
  • Pointer size: 131 Bytes
  • Size of remote file: 311 kB
examples/friends/Screenshot 2025-11-05 at 23.39.58.png ADDED

Git LFS Details

  • SHA256: 283d0bda09109022a3937b9529780d3f24d0a35ca8b336956499af24a2e04bdd
  • Pointer size: 131 Bytes
  • Size of remote file: 363 kB
examples/kitchen/frame_0000006347.jpg ADDED

Git LFS Details

  • SHA256: dab542dfacb3289e0284fadf2d1a34ece7b0f743140f1dde028cce615a6ffc18
  • Pointer size: 130 Bytes
  • Size of remote file: 13.7 kB
examples/kitchen/frame_0000006355.jpg ADDED

Git LFS Details

  • SHA256: d06f13d966fc3f1087e2766dc161379a2ca3b42c76653ef4e396816d42def075
  • Pointer size: 130 Bytes
  • Size of remote file: 15.7 kB
examples/kitchen/frame_0000006368.jpg ADDED

Git LFS Details

  • SHA256: 949dbd66440cc4bed6995e61985d835b48069a7d89a24d5b8c4afd17e1140219
  • Pointer size: 130 Bytes
  • Size of remote file: 19.4 kB
examples/kitchen/frame_0000006376.jpg ADDED

Git LFS Details

  • SHA256: 3ad961dbb275f7fad3a6df11ee6390451c9ea77efcd0029fbbf0724331a1ff26
  • Pointer size: 130 Bytes
  • Size of remote file: 21.3 kB
examples/kitchen/frame_0000006397.jpg ADDED

Git LFS Details

  • SHA256: c3cb4e5093889d98f4c98ea40ed9a2332ed56b6de1283c1ab0e9bdaba8e197e1
  • Pointer size: 130 Bytes
  • Size of remote file: 22.2 kB
examples/mall/Screenshot 2025-11-05 at 17.20.26.png ADDED

Git LFS Details

  • SHA256: 19c61c1b2850c6b2b97b157ec60ca984feb86dbdd939ee3d42a80d189b8d00d8
  • Pointer size: 132 Bytes
  • Size of remote file: 3.55 MB
examples/mall/Screenshot 2025-11-05 at 17.21.11.png ADDED

Git LFS Details

  • SHA256: ffa4498369ff89b12aad24063d96189a77bdfd3c4d643115c888b873e43ef3e7
  • Pointer size: 132 Bytes
  • Size of remote file: 3.34 MB
examples/mall/Screenshot 2025-11-05 at 17.21.46.png ADDED

Git LFS Details

  • SHA256: 00fa21fd7f3663f650c8291b13edffce5c42eb2b690a36a509d4cb2e6fad3a62
  • Pointer size: 132 Bytes
  • Size of remote file: 3.01 MB
examples/mall/Screenshot 2025-11-05 at 17.22.03.png ADDED

Git LFS Details

  • SHA256: dd1146922a8d70d4f01867993ce22cc99493e98f5ecaa7d59bfe403c35ca83d6
  • Pointer size: 132 Bytes
  • Size of remote file: 2.77 MB
examples/mall/Screenshot 2025-11-05 at 17.22.20.png ADDED

Git LFS Details

  • SHA256: 528accc988dfaade15a107decd0cc123be853949c819811e104e00f1a5950c1e
  • Pointer size: 132 Bytes
  • Size of remote file: 3.05 MB
examples/mall/Screenshot 2025-11-05 at 17.22.33.png ADDED

Git LFS Details

  • SHA256: 0f1e9c1c9367ccc88608de80767f9020c22f7428151055a30a975235bc0409de
  • Pointer size: 132 Bytes
  • Size of remote file: 3.16 MB
examples/mall/Screenshot 2025-11-05 at 17.22.46.png ADDED

Git LFS Details

  • SHA256: 4e33061a4f5bcd63966c36515fd50c432a76b4ddc5b5df8a27fe267008c1e9ed
  • Pointer size: 132 Bytes
  • Size of remote file: 3.13 MB
examples/mall/Screenshot 2025-11-05 at 17.23.00.png ADDED

Git LFS Details

  • SHA256: 373ff02bb7f518bdd4c556b2542752d2fabf4fe25f5fa820cab5ff7d48359538
  • Pointer size: 132 Bytes
  • Size of remote file: 2.76 MB
examples/outdoor/IMG_5115.jpg ADDED

Git LFS Details

  • SHA256: cb89246a6cb7a658e869493da80a3c59baa769dc0115726f9201dda2a700a395
  • Pointer size: 131 Bytes
  • Size of remote file: 566 kB
examples/outdoor/IMG_5117.jpg ADDED

Git LFS Details

  • SHA256: 6f92414a0b466b41018ea09f489bf13039c14a9c1ff35a6df2b2a7912d89a40f
  • Pointer size: 131 Bytes
  • Size of remote file: 570 kB
examples/outdoor/IMG_5118.jpg ADDED

Git LFS Details

  • SHA256: 310f44bd546d8ffc2d3361efb3f383d9a5ed299bcdb807000167c0ed7e80c560
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB