Vanyadoing commited on
Commit
b0778a4
·
verified ·
1 Parent(s): dd6bf46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -3
app.py CHANGED
@@ -1,5 +1,27 @@
1
  import gradio as gr
2
- def invert(img):
 
 
 
 
3
  return 255 - img
4
- iface = gr.Interface(fn=invert, inputs=gr.Image(type="numpy"), outputs=gr.Image())
5
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()