đ Depth Anything (base-sized model, Transformers version)
Depth Anything is a model for depth estimation, leveraging large - scale unlabeled data to achieve state - of - the - art results.
đ Quick Start
You can use the Depth Anything model for zero - shot depth estimation tasks. For other versions of the model, you can search on the model hub.
⨠Features
- Leverages the DPT architecture with a DINOv2 backbone.
- Trained on approximately 62 million images, achieving state - of - the - art results for both relative and absolute depth estimation.
đĻ Installation
No specific installation steps are provided in the original document, so this section is skipped.
đģ Usage Examples
Basic Usage
from transformers import pipeline
from PIL import Image
import requests
pipe = pipeline(task="depth-estimation", model="LiheYoung/depth-anything-base-hf")
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
depth = pipe(image)["depth"]
Advanced Usage
from transformers import AutoImageProcessor, AutoModelForDepthEstimation
import torch
import numpy as np
from PIL import Image
import requests
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
image_processor = AutoImageProcessor.from_pretrained("LiheYoung/depth-anything-base-hf")
model = AutoModelForDepthEstimation.from_pretrained("LiheYoung/depth-anything-base-hf")
inputs = image_processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predicted_depth = outputs.predicted_depth
prediction = torch.nn.functional.interpolate(
predicted_depth.unsqueeze(1),
size=image.size[::-1],
mode="bicubic",
align_corners=False,
)
For more code examples, refer to the documentation.
đ Documentation
Model description
Depth Anything leverages the DPT architecture with a DINOv2 backbone.
The model is trained on ~62 million images, obtaining state - of - the - art results for both relative and absolute depth estimation.

Depth Anything overview. Taken from the original paper.
Intended uses & limitations
You can use the raw model for tasks like zero - shot depth estimation. See the model hub to look for
other versions on a task that interests you.
BibTeX entry and citation info
@misc{yang2024depth,
title={Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data},
author={Lihe Yang and Bingyi Kang and Zilong Huang and Xiaogang Xu and Jiashi Feng and Hengshuang Zhao},
year={2024},
eprint={2401.10891},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
đ License
The model is licensed under the Apache - 2.0 license.
Property |
Details |
Model Type |
Depth Anything (base - sized model, Transformers version) |
Training Data |
Approximately 62 million images |