🚀 帶有DINOv2主幹的DPT模型
本項目提供了一個帶有DINOv2主幹的DPT(Dense Prediction Transformer)模型,可用於強大的深度估計任務。該模型結合了DPT框架和DINOv2的優勢,為視覺領域的深度估計問題提供了有效的解決方案。
🚀 快速開始
使用Transformers庫調用模型
以下是使用transformers
庫調用該模型進行深度估計的示例代碼:
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-giant-kitti")
model = DPTForDepthEstimation.from_pretrained("facebook/dpt-dinov2-giant-kitti")
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)
✨ 主要特性
- 強大的深度估計能力:使用DPT框架和DINOv2作為主幹,能夠實現高效準確的深度估計。
- 易於使用:可通過
transformers
庫輕鬆調用,方便集成到各種項目中。
📚 詳細文檔
模型詳情
DPT(Dense Prediction Transformer)模型採用了DINOv2作為主幹,該模型由Oquab等人在論文DINOv2: Learning Robust Visual Features without Supervision中提出。
DPT架構。取自 原始論文。
參考資源
模型使用
預期用途
該模型旨在展示使用DPT框架並以DINOv2作為主幹可以得到一個強大的深度估計器。
BibTeX引用信息
@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}
}
📄 許可證
本項目採用Apache-2.0許可證。