SauravMaheshkar commited on
Commit
5f8c34f
1 Parent(s): 19120fc

feat: add example

Browse files
Files changed (2) hide show
  1. app.py +35 -13
  2. assets/input_one.webp +0 -0
app.py CHANGED
@@ -5,6 +5,12 @@ import numpy as np
5
  from depth_pro.depth_pro import DepthProConfig
6
  from PIL import Image
7
 
 
 
 
 
 
 
8
 
9
  def run(input_image_path):
10
  config = DepthProConfig(
@@ -40,17 +46,33 @@ def run(input_image_path):
40
  return depth_map, focallength_px.item()
41
 
42
 
43
- demo = gr.Interface(
44
- fn=run,
45
- inputs=gr.Image(label="Input Image", type="filepath"),
46
- outputs=[
47
- gr.Image(label="Depth Map"),
48
- gr.Number(label="Focal Length"),
49
- ],
50
- description="""
51
- <div align="center">
52
- <h2><a href="https://arxiv.org/abs/2410.02073">Depth Pro: Sharp Monocular Metric Depth in Less Than a Second</a></h2>
53
- </div>
54
- """,
55
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  demo.launch()
 
5
  from depth_pro.depth_pro import DepthProConfig
6
  from PIL import Image
7
 
8
+ MARKDOWN = """
9
+ <div align="center">
10
+ <h2><a href="https://arxiv.org/abs/2410.02073">Depth Pro: Sharp Monocular Metric Depth in Less Than a Second</a></h2>
11
+ </div>
12
+ """
13
+
14
 
15
  def run(input_image_path):
16
  config = DepthProConfig(
 
46
  return depth_map, focallength_px.item()
47
 
48
 
49
+ with gr.Blocks() as demo:
50
+ gr.Markdown(MARKDOWN)
51
+ with gr.Row():
52
+ with gr.Column():
53
+ input_image_path = gr.Image(
54
+ label="Input Image", type="filepath", sources=["upload"]
55
+ )
56
+ with gr.Column():
57
+ with gr.Column():
58
+ output_depth_map = gr.Image(label="Depth Map")
59
+ output_focal_length = gr.Number(label="Focal Length")
60
+
61
+ with gr.Row():
62
+ btn = gr.Button("Run")
63
+
64
+ btn.click(
65
+ run, inputs=[input_image_path], outputs=[output_depth_map, output_focal_length]
66
+ )
67
+
68
+ examples = gr.Examples(
69
+ examples=[
70
+ "assets/input_one.webp",
71
+ ],
72
+ fn=run,
73
+ inputs=[input_image_path],
74
+ outputs=[output_depth_map, output_focal_length],
75
+ cache_examples=True,
76
+ )
77
+
78
  demo.launch()
assets/input_one.webp ADDED