Spaces:
Running
Running
Akash Raj
commited on
Commit
•
22aa42f
1
Parent(s):
284f074
test
Browse files
app.py
CHANGED
@@ -29,38 +29,22 @@ def normalize_depth(depth_map):
|
|
29 |
normalized_depth = ((depth_map - depth_map.min()) / (depth_map.max() - depth_map.min())) * 255
|
30 |
return normalized_depth.astype(np.uint8)
|
31 |
|
32 |
-
# Create a Gradio interface
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
gr.Image(type="
|
38 |
-
|
39 |
-
|
40 |
-
gr.
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
)
|
|
|
|
|
46 |
|
47 |
# Launch the Gradio app
|
48 |
iface.launch()
|
49 |
-
|
50 |
-
|
51 |
-
"""
|
52 |
-
from transformers import pipeline
|
53 |
-
from PIL import Image
|
54 |
-
import requests
|
55 |
-
|
56 |
-
# load pipe
|
57 |
-
pipe = pipeline(task="depth-estimation", model="LiheYoung/depth-anything-small-hf")
|
58 |
-
|
59 |
-
# load image
|
60 |
-
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
61 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
62 |
-
|
63 |
-
# inference
|
64 |
-
depth = pipe(image)["depth"]
|
65 |
-
|
66 |
-
"""
|
|
|
29 |
normalized_depth = ((depth_map - depth_map.min()) / (depth_map.max() - depth_map.min())) * 255
|
30 |
return normalized_depth.astype(np.uint8)
|
31 |
|
32 |
+
# Create a Gradio interface using Blocks
|
33 |
+
with gr.Blocks() as iface:
|
34 |
+
gr.Markdown("# Multi-Model Depth Estimation\nUpload an image to get depth estimation maps from multiple models.")
|
35 |
+
|
36 |
+
with gr.Row():
|
37 |
+
input_image = gr.Image(type="pil", label="Input Image")
|
38 |
+
|
39 |
+
with gr.Row():
|
40 |
+
with gr.Column():
|
41 |
+
output_base = gr.Image(type="numpy", label="LiheYoung/depth-anything-base-hf", interactive=False)
|
42 |
+
output_small = gr.Image(type="numpy", label="LiheYoung/depth-anything-small-hf", interactive=False)
|
43 |
+
with gr.Column():
|
44 |
+
output_intel = gr.Image(type="numpy", label="Intel/dpt-swinv2-tiny-256", interactive=False)
|
45 |
+
output_beit = gr.Image(type="numpy", label="Intel/dpt-beit-base-384", interactive=False)
|
46 |
+
|
47 |
+
input_image.change(fn=estimate_depths, inputs=input_image, outputs=[output_base, output_small, output_intel, output_beit])
|
48 |
|
49 |
# Launch the Gradio app
|
50 |
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|