DepthAnything /Depth-Anything-V2
[NeurIPS 2024] Depth Anything V2. A More Capable Foundation Model for Monocular Depth Estimation
★ 9,157⑂ 948👁 59⑃ 37● 290▤ 0
+2
Daily
9,157
stars
948
forks
59
watchers
37
prs
290
issues
0
releases
README
Depth Anything V2
Lihe Yang1 · Bingyi Kang2† · Zilong Huang2
Zhen Zhao · Xiaogang Xu · Jiashi Feng2 · Hengshuang Zhao1
1HKU   2TikTok
†project lead corresponding author
This work presents Depth Anything V2. It significantly outperforms V1 in fine-grained details and robustness. Compared with SD-based models, it enjoys faster inference speed, fewer parameters, and higher depth accuracy.
!teaser
News
- 2025-01-22: Video Depth Anything has been released. It generates consistent depth maps for super-long videos (e.g., over 5 minutes).
- 2024-12-22: Prompt Depth Anything has been released. It supports 4K resolution metric depth estimation when low-res LiDAR is used to prompt the DA models.
- 2024-07-06: Depth Anything V2 is supported in Transformers. See the instructions for convenient usage.
- 2024-06-25: Depth Anything is integrated into Apple Core ML Models. See the instructions (V1, V2) for usage.
- 2024-06-22: We release smaller metric depth models based on Depth-Anything-V2-Small and Base.
- 2024-06-20: Our repository and project page are flagged by GitHub and removed from the public for 6 days. Sorry for the inconvenience.
- 2024-06-14: Paper, project page, code, models, demo, and benchmark are all released.
Pre-trained Models
We provide four models of varying scales for robust relative depth estimation:
| Model | Params | Checkpoint |
|:-|-:|:-:|
| Depth-Anything-V2-Small | 24.8M | Download |
| Depth-Anything-V2-Base | 97.5M | Download |
| Depth-Anything-V2-Large | 335.3M | Download |
| Depth-Anything-V2-Giant | 1.3B | Coming soon |
Usage
Prepraration
bash
git clone https://github.com/DepthAnything/Depth-Anything-V2
cd Depth-Anything-V2
pip install -r requirements.txt
Download the checkpoints listed here and put them under the checkpoints directory.
Use our models
python
import cv2
import torch
from depth_anything_v2.dpt import DepthAnythingV2
DEVICE = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
model_configs = {
'vits': {'encoder': 'vits', 'features': 64, 'out_channels': [48, 96, 192, 384]},
'vitb': {'encoder': 'vitb', 'features': 128, 'out_channels': [96, 192, 384, 768]},
'vitl': {'encoder': 'vitl', 'features': 256, 'out_channels': [256, 512, 1024, 1024]},
'vitg': {'encoder': 'vitg', 'features': 384, 'out_channels': [1536, 1536, 1536, 1536]}
}
encoder = 'vitl' or 'vits', 'vitb', 'vitg'
model = DepthAnythingV2(model_configs[encoder])
model.load_state_dict(torch.load(f'checkpoints/depth_anything_v2_{encoder}.pth', map_location='cpu'))
model = model.to(DEVICE).eval()
raw_img = cv2.imread('your/image/path')
depth = model.infer_image(raw_img) HxW raw depth map in numpy
If you do not want to clone this repository, you can also load our models through Transformers. Below is a simple code snippet. Please refer to the official page for more details.
- Note 1: Make sure you can connect to Hugging Face and have iTop issues
#128Issue when converting depth to point cloud30 comments · 2024-08-11#99Fine-tuning problems21 comments · 2024-07-22#93What's the meaning of the model's output?How can I get the true distance from the model output?18 comments · 2024-07-19#25question:is there anyway use the output as mask to segment or remove component in source image17 comments · 2024-06-24#8Fintuning17 comments · 2024-06-21#58bit only depth15 comments · 2024-06-21#85Temporal consistency13 comments · 2024-07-13#4Issue about max-depth value in metric depth estimation10 comments · 2024-06-20