Views
No views yet
| Base Model | Params | Indoor (Hypersim) | Outdoor (Virtual KITTI 2) |
|---|---|---|---|
| Depth-Anything-V2-Small | 24.8M | Download | Download |
| Depth-Anything-V2-Base | 97.5M | Download | Download |
| Depth-Anything-V2-Large | 335.3M | Download | Download |
1git clone https://github.com/DepthAnything/Depth-Anything-V2
2cd Depth-Anything-V2/metric_depth
3pip install -r requirements.txtcheckpoints directory.1import cv2
2import torch
3
4from depth_anything_v2.dpt import DepthAnythingV2
5
6model_configs = {
7 'vits': {'encoder': 'vits', 'features': 64, 'out_channels': [48, 96, 192, 384]},
8 'vitb': {'encoder': 'vitb', 'features': 128, 'out_channels': [96, 192, 384, 768]},
9 'vitl': {'encoder': 'vitl', 'features': 256, 'out_channels': [256, 512, 1024, 1024]}
10}
11
12encoder = 'vitl' # or 'vits', 'vitb'
13dataset = 'hypersim' # 'hypersim' for indoor model, 'vkitti' for outdoor model
14max_depth = 20 # 20 for indoor model, 80 for outdoor model
15
16model = DepthAnythingV2(**{**model_configs[encoder], 'max_depth': max_depth})
17model.load_state_dict(torch.load(f'checkpoints/depth_anything_v2_metric_{dataset}_{encoder}.pth', map_location='cpu'))
18model.eval()
19
20raw_img = cv2.imread('your/image/path')
21depth = model.infer_image(raw_img) # HxW depth map in meters in numpyvitl encoder as an example. You can also use vitb or vits encoders.1# indoor scenes
2python run.py \
3 --encoder vitl \
4 --load-from checkpoints/depth_anything_v2_metric_hypersim_vitl.pth \
5 --max-depth 20 \
6 --img-path <path> --outdir <outdir> [--input-size <size>] [--save-numpy]
7
8# outdoor scenes
9python run.py \
10 --encoder vitl \
11 --load-from checkpoints/depth_anything_v2_metric_vkitti_vitl.pth \
12 --max-depth 80 \
13 --img-path <path> --outdir <outdir> [--input-size <size>] [--save-numpy]1python depth_to_pointcloud.py \
2 --encoder vitl \
3 --load-from checkpoints/depth_anything_v2_metric_hypersim_vitl.pth \
4 --max-depth 20 \
5 --img-path <path> --outdir <outdir>bash dist_train.sh1@article{depth_anything_v2,
2 title={Depth Anything V2},
3 author={Yang, Lihe and Kang, Bingyi and Huang, Zilong and Zhao, Zhen and Xu, Xiaogang and Feng, Jiashi and Zhao, Hengshuang},
4 journal={arXiv:2406.09414},
5 year={2024}
6}
7
8@inproceedings{depth_anything_v1,
9 title={Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data},
10 author={Yang, Lihe and Kang, Bingyi and Huang, Zilong and Xu, Xiaogang and Feng, Jiashi and Zhao, Hengshuang},
11 booktitle={CVPR},
12 year={2024}
13}