Views
No views yet
1git clone https://huggingface.co/spaces/depth-anything/Depth-Anything-V2
2cd Depth-Anything-V2
3pip install -r requirements.txtcheckpoints directory.1import cv2
2import torch
3
4from depth_anything_v2.dpt import DepthAnythingV2
5
6model = DepthAnythingV2(encoder='vitl', features=256, out_channels=[256, 512, 1024, 1024])
7model.load_state_dict(torch.load('checkpoints/depth_anything_v2_vitl.pth', map_location='cpu'))
8model.eval()
9
10raw_img = cv2.imread('your/image/path')
11depth = model.infer_image(raw_img) # HxW raw depth map1@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}