Spaces:
Running
Running
SauravMaheshkar
commited on
Commit
•
5f8c34f
1
Parent(s):
19120fc
feat: add example
Browse files- app.py +35 -13
- 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 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
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