Tohru127 commited on
Commit
84dee2b
Β·
verified Β·
1 Parent(s): 0096615

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -20
app.py CHANGED
@@ -534,6 +534,16 @@ with gr.Blocks(title="DepthForge") as demo:
534
  with gr.Row():
535
  with gr.Column(scale=1):
536
  input_image = gr.Image(type="pil", label="Upload a photo", sources=["upload", "clipboard"])
 
 
 
 
 
 
 
 
 
 
537
  model_choice = gr.Radio(
538
  choices=["GLPN (Recommended)", "DPT (High Quality)"],
539
  value="GLPN (Recommended)", label="Depth model",
@@ -558,16 +568,18 @@ with gr.Blocks(title="DepthForge") as demo:
558
  inputs=[input_image, model_choice, visualization_type, consent_checkbox],
559
  outputs=[depth_output, viewer_3d, download_output, metrics_output, json_output])
560
 
561
- # ── Try a Sample ────────────────────────────────────────────────────
562
- with gr.Tab("πŸ–ΌοΈ Try a Sample"):
563
  gr.Markdown("""
564
- ## Two built-in sample images
565
 
566
- New here? These images are generated with PIL β€” no download, no licence
567
- concerns. They are designed as a direct side-by-side comparison:
568
- **Sample 1** shows the model at its best; **Sample 2** shows where it
569
- struggles and when to switch models. Click a button to load the image
570
- straight into the Reconstruct tab, then hit β–Ά Reconstruct.
 
 
571
  """)
572
 
573
  with gr.Row(equal_height=False):
@@ -589,8 +601,7 @@ straight into the Reconstruct tab, then hit β–Ά Reconstruct.
589
  <span class="sample-pill good">βœ“ indoor scene</span>
590
  </div>
591
  """)
592
- gr.Image(value=SAMPLE_INDOOR, label="Preview", interactive=False)
593
- load_indoor_btn = gr.Button("Load Sample 1 into Reconstruct tab", variant="secondary")
594
 
595
  # ── Sample 2 ────────────────────────────────────────────────
596
  with gr.Column():
@@ -610,8 +621,7 @@ straight into the Reconstruct tab, then hit β–Ά Reconstruct.
610
  <span class="sample-pill good">βœ“ switch to DPT here</span>
611
  </div>
612
  """)
613
- gr.Image(value=SAMPLE_OUTDOOR, label="Preview", interactive=False)
614
- load_outdoor_btn = gr.Button("Load Sample 2 into Reconstruct tab", variant="secondary")
615
 
616
  gr.Markdown("""
617
  ---
@@ -630,10 +640,6 @@ straight into the Reconstruct tab, then hit β–Ά Reconstruct.
630
  > flag are the fastest way to judge which model suited the scene better.
631
  """)
632
 
633
- # wire buttons β†’ loads PIL image into the uploader on Reconstruct tab
634
- load_indoor_btn.click(fn=lambda: SAMPLE_INDOOR, inputs=[], outputs=[input_image])
635
- load_outdoor_btn.click(fn=lambda: SAMPLE_OUTDOOR, inputs=[], outputs=[input_image])
636
-
637
  # ── Theory ──────────────────────────────────────────────────────────
638
  with gr.Tab("πŸ“– Theory & Background"):
639
  gr.Markdown("""
@@ -685,10 +691,11 @@ multiple cameras, no manual modelling.
685
  gr.Markdown("""
686
  ## How to Use This Application
687
 
688
- ### First time? Use the sample tab
689
- Go to **πŸ–ΌοΈ Try a Sample**, click **Load Sample 1**, then come back here
690
- and tick the consent box. You'll have a working reconstruction in under
691
- a minute without needing your own image.
 
692
 
693
  ### Step 1 Β· Read the guidelines
694
  The **⚠️ Responsible Use** tab explains privacy rules, prohibited uses,
 
534
  with gr.Row():
535
  with gr.Column(scale=1):
536
  input_image = gr.Image(type="pil", label="Upload a photo", sources=["upload", "clipboard"])
537
+
538
+ # Click a sample thumbnail to load it straight into the
539
+ # uploader above β€” no tab switching needed.
540
+ gr.Examples(
541
+ examples=[[SAMPLE_INDOOR_PATH], [SAMPLE_OUTDOOR_PATH]],
542
+ inputs=[input_image],
543
+ label="No image? Click a sample to try it instantly",
544
+ examples_per_page=2,
545
+ )
546
+
547
  model_choice = gr.Radio(
548
  choices=["GLPN (Recommended)", "DPT (High Quality)"],
549
  value="GLPN (Recommended)", label="Depth model",
 
568
  inputs=[input_image, model_choice, visualization_type, consent_checkbox],
569
  outputs=[depth_output, viewer_3d, download_output, metrics_output, json_output])
570
 
571
+ # ── Sample Guide ─────────────────────────────────────────────────────
572
+ with gr.Tab("πŸ–ΌοΈ Sample Guide"):
573
  gr.Markdown("""
574
+ ## About the two sample images
575
 
576
+ You don't need to come to this tab to use the samples β€” they're available as
577
+ clickable thumbnails right under the uploader on the **πŸ”¬ Reconstruct** tab.
578
+ Click one there and it loads instantly, no switching back and forth.
579
+
580
+ This page just explains what each sample is for and how to read the results.
581
+ The two are a deliberate side-by-side: **Sample 1** shows the model at its
582
+ best, **Sample 2** shows where it struggles and when to switch models.
583
  """)
584
 
585
  with gr.Row(equal_height=False):
 
601
  <span class="sample-pill good">βœ“ indoor scene</span>
602
  </div>
603
  """)
604
+ gr.Image(value=SAMPLE_INDOOR, label="Sample 1 preview", interactive=False)
 
605
 
606
  # ── Sample 2 ────────────────────────────────────────────────
607
  with gr.Column():
 
621
  <span class="sample-pill good">βœ“ switch to DPT here</span>
622
  </div>
623
  """)
624
+ gr.Image(value=SAMPLE_OUTDOOR, label="Sample 2 preview", interactive=False)
 
625
 
626
  gr.Markdown("""
627
  ---
 
640
  > flag are the fastest way to judge which model suited the scene better.
641
  """)
642
 
 
 
 
 
643
  # ── Theory ──────────────────────────────────────────────────────────
644
  with gr.Tab("πŸ“– Theory & Background"):
645
  gr.Markdown("""
 
691
  gr.Markdown("""
692
  ## How to Use This Application
693
 
694
+ ### First time? Use a sample
695
+ On the **πŸ”¬ Reconstruct** tab, tick the consent box, then click one of the
696
+ sample thumbnails under the uploader. It loads instantly β€” hit β–Ά Reconstruct
697
+ and you'll have a result in under a minute, no image of your own needed.
698
+ (See the **πŸ–ΌοΈ Sample Guide** tab for what each sample demonstrates.)
699
 
700
  ### Step 1 Β· Read the guidelines
701
  The **⚠️ Responsible Use** tab explains privacy rules, prohibited uses,