Spaces:
Running
Running
Akash Raj
commited on
Commit
•
516f50c
1
Parent(s):
055d4a8
test
Browse files
app.py
CHANGED
@@ -2,28 +2,36 @@ from transformers import pipeline
|
|
2 |
from PIL import Image
|
3 |
import gradio as gr
|
4 |
|
5 |
-
# Load the Hugging Face depth estimation
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Create a Gradio interface
|
14 |
iface = gr.Interface(
|
15 |
-
fn=
|
16 |
inputs=gr.Image(type="pil"),
|
17 |
-
outputs=
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
)
|
21 |
|
22 |
# Launch the Gradio app
|
23 |
iface.launch()
|
24 |
|
25 |
|
26 |
-
|
27 |
"""
|
28 |
from transformers import pipeline
|
29 |
from PIL import Image
|
|
|
2 |
from PIL import Image
|
3 |
import gradio as gr
|
4 |
|
5 |
+
# Load the Hugging Face depth estimation pipelines
|
6 |
+
pipe_base = pipeline(task="depth-estimation", model="LiheYoung/depth-anything-base-hf")
|
7 |
+
pipe_small = pipeline(task="depth-estimation", model="LiheYoung/depth-anything-small-hf")
|
8 |
+
pipe_intel = pipeline(task="depth-estimation", model="Intel/dpt-swinv2-tiny-256")
|
9 |
+
|
10 |
+
def estimate_depths(image):
|
11 |
+
# Perform depth estimation with each pipeline
|
12 |
+
depth_base = pipe_base(image)["depth"]
|
13 |
+
depth_small = pipe_small(image)["depth"]
|
14 |
+
depth_intel = pipe_intel(image)["depth"]
|
15 |
+
|
16 |
+
return depth_base, depth_small, depth_intel
|
17 |
|
18 |
# Create a Gradio interface
|
19 |
iface = gr.Interface(
|
20 |
+
fn=estimate_depths,
|
21 |
inputs=gr.Image(type="pil"),
|
22 |
+
outputs=[
|
23 |
+
gr.outputs.Image(type="pil", label="LiheYoung/depth-anything-base-hf"),
|
24 |
+
gr.outputs.Image(type="pil", label="LiheYoung/depth-anything-small-hf"),
|
25 |
+
gr.outputs.Image(type="pil", label="Intel/dpt-swinv2-tiny-256")
|
26 |
+
],
|
27 |
+
title="Multi-Model Depth Estimation",
|
28 |
+
description="Upload an image to get depth estimation maps from multiple models."
|
29 |
)
|
30 |
|
31 |
# Launch the Gradio app
|
32 |
iface.launch()
|
33 |
|
34 |
|
|
|
35 |
"""
|
36 |
from transformers import pipeline
|
37 |
from PIL import Image
|