Spaces:
Runtime error
Runtime error
RamAnanth1
commited on
Commit
•
b213e2f
1
Parent(s):
e74e489
Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,19 @@ import matplotlib.pyplot as plt
|
|
9 |
title = "Interactive demo: ZoeDepth"
|
10 |
description = "Unofficial Gradio Demo for using ZoeDepth: Zero-shot Transfer by Combining Relative and Metric Depth. To use it, simply upload an image or use one of the examples below and click 'Submit'. Results will show up in a few seconds."
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
zoe = torch.hub.load(".", "ZoeD_N", source="local", pretrained=True)
|
14 |
-
def process_image(raw_image):
|
15 |
-
return raw_image
|
16 |
interface = gr.Interface(fn=process_image,
|
17 |
inputs=[gr.Image(type="pil")],
|
18 |
outputs=[gr.Image(type="pil", label ="Depth")
|
|
|
9 |
title = "Interactive demo: ZoeDepth"
|
10 |
description = "Unofficial Gradio Demo for using ZoeDepth: Zero-shot Transfer by Combining Relative and Metric Depth. To use it, simply upload an image or use one of the examples below and click 'Submit'. Results will show up in a few seconds."
|
11 |
|
12 |
+
repo = "isl-org/ZoeDepth"
|
13 |
+
# Zoe_N
|
14 |
+
model_zoe_n = torch.hub.load(repo, "ZoeD_N", pretrained=True)
|
15 |
+
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
+
zoe = model_zoe_n.to(DEVICE)
|
17 |
+
|
18 |
+
def process_image(image):
|
19 |
+
depth_numpy = zoe.infer_pil(image) # as numpy
|
20 |
+
|
21 |
+
depth_pil = zoe.infer_pil(image, output_type="pil") # as 16-bit PIL Image
|
22 |
+
|
23 |
+
return depth_pil
|
24 |
|
|
|
|
|
|
|
25 |
interface = gr.Interface(fn=process_image,
|
26 |
inputs=[gr.Image(type="pil")],
|
27 |
outputs=[gr.Image(type="pil", label ="Depth")
|