nielsr HF staff commited on
Commit
6b3f9ec
1 Parent(s): 643c2b0

Load models from Hugging Face

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -10,7 +10,7 @@ from torchvision.transforms import Compose
10
  import tempfile
11
  from gradio_imageslider import ImageSlider
12
 
13
- from depth_anything.dpt import DPT_DINOv2
14
  from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
15
 
16
  css = """
@@ -25,8 +25,8 @@ css = """
25
  }
26
  """
27
  DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
28
- model = DPT_DINOv2(encoder='vitl', features=256, out_channels=[256, 512, 1024, 1024]).to(DEVICE).eval()
29
- model.load_state_dict(torch.load('checkpoints/depth_anything_vitl14.pth'))
30
 
31
  title = "# Depth Anything"
32
  description = """Official demo for **Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data**.
 
10
  import tempfile
11
  from gradio_imageslider import ImageSlider
12
 
13
+ from depth_anything.dpt import DepthAnything
14
  from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
15
 
16
  css = """
 
25
  }
26
  """
27
  DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
28
+ encoder = 'vitl' # can also be 'vitb' or 'vitl'
29
+ model = DepthAnything.from_pretrained(f"LiheYoung/depth_anything_{encoder}14")
30
 
31
  title = "# Depth Anything"
32
  description = """Official demo for **Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data**.