Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
return 255 - img
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
+
from depth_anything_v2.dpt import DepthAnythingV2
|
| 5 |
+
|
| 6 |
+
def dummy_infer(img):
|
| 7 |
return 255 - img
|
| 8 |
+
|
| 9 |
+
# --- LOAD THE MODEL, BUT DON'T USE IT ---
|
| 10 |
+
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 11 |
+
model_configs = {
|
| 12 |
+
'vitl': {'encoder': 'vitl', 'features': 256, 'out_channels': [256, 512, 1024, 1024]},
|
| 13 |
+
}
|
| 14 |
+
encoder = 'vitl'
|
| 15 |
+
model = DepthAnythingV2(**model_configs[encoder])
|
| 16 |
+
model_path = hf_hub_download(
|
| 17 |
+
repo_id="depth-anything/Depth-Anything-V2-Large",
|
| 18 |
+
filename=f"depth_anything_v2_{encoder}.pth",
|
| 19 |
+
repo_type="model"
|
| 20 |
+
)
|
| 21 |
+
state_dict = torch.load(model_path, map_location="cpu")
|
| 22 |
+
model.load_state_dict(state_dict)
|
| 23 |
+
model = model.to(DEVICE).eval()
|
| 24 |
+
# --- END MODEL LOADING ---
|
| 25 |
+
|
| 26 |
+
iface = gr.Interface(fn=dummy_infer, inputs=gr.Image(type="numpy"), outputs=gr.Image())
|
| 27 |
+
iface.launch()
|