Spaces:
Running
on
Zero
Running
on
Zero
Charlie Amalet
commited on
Commit
·
5212158
1
Parent(s):
949b232
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from zoedepth.utils.config import get_config
|
| 2 |
+
from zoedepth.models.builder import build_model
|
| 3 |
+
|
| 4 |
+
import gradio as gr
|
| 5 |
+
import torch
|
| 6 |
+
|
| 7 |
+
from depth import depth_interface
|
| 8 |
+
from mesh import mesh_interface
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
css = """
|
| 12 |
+
#img-display-container {
|
| 13 |
+
max-height: 50vh;
|
| 14 |
+
}
|
| 15 |
+
#img-display-input {
|
| 16 |
+
max-height: 40vh;
|
| 17 |
+
}
|
| 18 |
+
#img-display-output {
|
| 19 |
+
max-height: 40vh;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
"""
|
| 23 |
+
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 24 |
+
model = torch.hub.load('isl-org/ZoeDepth', "ZoeD_N", pretrained=True).to(DEVICE).eval()
|
| 25 |
+
|
| 26 |
+
# config_mode="infer"
|
| 27 |
+
# pretrained_resource = f"local::C:/Users/Charl/.cache/torch/hub/checkpoints/ZoeD_M12_N.pt"
|
| 28 |
+
# config = get_config("zoedepth", config_mode, pretrained_resource=pretrained_resource)
|
| 29 |
+
# model = build_model(config).to(DEVICE).eval()
|
| 30 |
+
|
| 31 |
+
# title = "# ZoeDepth"
|
| 32 |
+
# description = """Official demo for **ZoeDepth: Zero-shot Transfer by Combining Relative and Metric Depth**."""
|
| 33 |
+
|
| 34 |
+
with gr.Blocks(css=css) as API:
|
| 35 |
+
# gr.Markdown(title)
|
| 36 |
+
# gr.Markdown(description)
|
| 37 |
+
with gr.Tab("Depth Prediction"):
|
| 38 |
+
depth_interface(model)
|
| 39 |
+
with gr.Tab("Image to 3D"):
|
| 40 |
+
mesh_interface(model)
|
| 41 |
+
# with gr.Tab("360 Panorama to 3D"):
|
| 42 |
+
# create_pano_to_3d_demo(model)
|
| 43 |
+
|
| 44 |
+
if __name__ == '__main__':
|
| 45 |
+
API.launch()
|