Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
# Load the depth estimation pipeline using Depth Anything V2 Large model
|
6 |
+
depth_pipeline = pipeline(task="depth-estimation", model="depth-anything/Depth-Anything-V2-Large-hf")
|
7 |
+
|
8 |
+
|
9 |
+
def predict_depth(image):
|
10 |
+
# image is a PIL Image
|
11 |
+
result = depth_pipeline(image)
|
12 |
+
depth_image = result["depth"]
|
13 |
+
return depth_image
|
14 |
+
|
15 |
+
|
16 |
+
title = "Depth Anything V2 Large - Depth Map Generator"
|
17 |
+
description = "Upload an image to generate a depth map using the Depth Anything V2 Large model (Relative depth)."
|
18 |
+
|
19 |
+
|
20 |
+
iface = gr.Interface(
|
21 |
+
fn=predict_depth,
|
22 |
+
inputs=gr.Image(type="pil", label="Input Image"),
|
23 |
+
outputs=gr.Image(type="pil", label="Predicted Depth Map"),
|
24 |
+
title=title,
|
25 |
+
description=description,
|
26 |
+
)
|
27 |
+
|
28 |
+
|
29 |
+
if __name__ == "__main__":
|
30 |
+
iface.launch()
|