Views
No views yet
| Base Model | Params | Indoor (Hypersim) | Outdoor (Virtual KITTI 2) |
|---|---|---|---|
| Depth-Anything-V2-Small | 24.8M | Model Card | Model Card |
| Depth-Anything-V2-Base | 97.5M | Model Card | Model Card |
| Depth-Anything-V2-Large | 335.3M | Model Card | Model Card |

transformers>=4.45.0transformers latest version installed from the source:pip install git+https://github.com/huggingface/transformers1from transformers import pipeline
2from PIL import Image
3import requests
4
5# load pipe
6pipe = pipeline(task="depth-estimation", model="depth-anything/Depth-Anything-V2-Metric-Outdoor-Large-hf")
7
8# load image
9url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
10image = Image.open(requests.get(url, stream=True).raw)
11
12# inference
13depth = pipe(image)["depth"]1from transformers import AutoImageProcessor, AutoModelForDepthEstimation
2import torch
3import numpy as np
4from PIL import Image
5import requests
6
7url = "http://images.cocodataset.org/val2017/000000039769.jpg"
8image = Image.open(requests.get(url, stream=True).raw)
9
10image_processor = AutoImageProcessor.from_pretrained("depth-anything/Depth-Anything-V2-Metric-Outdoor-Large-hf")
11model = AutoModelForDepthEstimation.from_pretrained("depth-anything/Depth-Anything-V2-Metric-Outdoor-Large-hf")
12
13# prepare image for the model
14inputs = image_processor(images=image, return_tensors="pt")
15
16with torch.no_grad():
17 outputs = model(**inputs)
18 predicted_depth = outputs.predicted_depth
19
20# interpolate to original size
21prediction = torch.nn.functional.interpolate(
22 predicted_depth.unsqueeze(1),
23 size=image.size[::-1],
24 mode="bicubic",
25 align_corners=False,
26)1@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}