🚀 Model Card: DPT model with DINOv2 backbone
This model card introduces a DPT (Dense Prediction Transformer) model with a DINOv2 backbone. It demonstrates that using the DPT framework with DINOv2 as the backbone can create a powerful depth estimator.
✨ Features
- Utilizes the DPT framework with a DINOv2 backbone for depth estimation.
- Can be easily integrated with the Transformers library.
📦 Installation
Since the model uses the transformers
library, you can install it using the following command:
pip install transformers torch pillow requests
💻 Usage Examples
Basic Usage
from transformers import AutoImageProcessor, DPTForDepthEstimation
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("facebook/dpt-dinov2-base-nyu")
model = DPTForDepthEstimation.from_pretrained("facebook/dpt-dinov2-base-nyu")
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,
)
output = prediction.squeeze().cpu().numpy()
formatted = (output * 255 / np.max(output)).astype("uint8")
depth = Image.fromarray(formatted)
📚 Documentation
Model Details
DPT (Dense Prediction Transformer) model with DINOv2 backbone as proposed in DINOv2: Learning Robust Visual Features without Supervision by Oquab et al.

DPT architecture. Taken from the original paper.
Resources
Model Use
Intended Use
The model is intended to showcase that using the DPT framework with DINOv2 as backbone yields a powerful depth estimator.
BibTeX entry and citation info
@misc{oquab2023dinov2,
title={DINOv2: Learning Robust Visual Features without Supervision},
author={Maxime Oquab and Timothée Darcet and Théo Moutakanni and Huy Vo and Marc Szafraniec and Vasil Khalidov and Pierre Fernandez and Daniel Haziza and Francisco Massa and Alaaeldin El-Nouby and Mahmoud Assran and Nicolas Ballas and Wojciech Galuba and Russell Howes and Po-Yao Huang and Shang-Wen Li and Ishan Misra and Michael Rabbat and Vasu Sharma and Gabriel Synnaeve and Hu Xu and Hervé Jegou and Julien Mairal and Patrick Labatut and Armand Joulin and Piotr Bojanowski},
year={2023},
eprint={2304.07193},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
📄 License
This model is licensed under the Apache-2.0 license.