🚀 深度任意模型V2基礎版 - Transformers版本
深度任意模型V2基於59.5萬張合成標註圖像和6200萬張以上真實未標註圖像進行訓練,是目前最強大的單目深度估計(MDE)模型,具備以下特性:
- 比深度任意模型V1擁有更精細的細節
- 比深度任意模型V1和基於穩定擴散(SD)的模型(如Marigold、Geowizard)更穩健
- 比基於SD的模型更高效(快10倍)、更輕量級
- 使用預訓練模型進行微調後,能獲得出色的性能
此模型檢查點與transformers庫兼容。
深度任意模型V2由李和楊等人在同名論文中提出。它採用了與原始深度任意模型相同的架構,但使用了合成數據和更大容量的教師模型,從而實現了更精細、更穩健的深度預測。原始的深度任意模型由李和楊等人在論文《深度任意:釋放大規模未標註數據的力量》中提出,並首次在此倉庫發佈。
在線演示。
🚀 快速開始
深度任意模型V2為單目深度估計提供了強大的解決方案,你可以按照以下步驟快速使用該模型。
✨ 主要特性
- 細節更精細:相較於深度任意模型V1,能捕捉到更多精細的細節。
- 性能更穩健:比深度任意模型V1和基於SD的模型(如Marigold、Geowizard)更穩健。
- 高效輕量:比基於SD的模型更高效(快10倍)、更輕量級。
- 微調效果出色:使用預訓練模型進行微調後,能獲得出色的性能。
📚 詳細文檔
模型描述
深度任意模型V2採用了DPT架構,並以DINOv2為骨幹網絡。
該模型在約60萬張合成標註圖像和約6200萬張真實未標註圖像上進行訓練,在相對和絕對深度估計方面均取得了最先進的成果。

深度任意模型概述。取自原論文。
預期用途與限制
你可以使用該原始模型進行零樣本深度估計等任務。請參考模型中心,查找其他感興趣的版本。
如何使用
基礎用法
以下是如何使用該模型進行零樣本深度估計的示例:
from transformers import pipeline
from PIL import Image
import requests
pipe = pipeline(task="depth-estimation", model="depth-anything/Depth-Anything-V2-Large-hf")
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
depth = pipe(image)["depth"]
高級用法
你也可以使用模型和處理器類:
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("depth-anything/Depth-Anything-V2-Large-hf")
model = AutoModelForDepthEstimation.from_pretrained("depth-anything/Depth-Anything-V2-Large-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,
)
更多代碼示例,請參考文檔。
引用
@misc{yang2024depth,
title={Depth Anything V2},
author={Lihe Yang and Bingyi Kang and Zilong Huang and Zhen Zhao and Xiaogang Xu and Jiashi Feng and Hengshuang Zhao},
year={2024},
eprint={2406.09414},
archivePrefix={arXiv},
primaryClass={id='cs.CV' full_name='Computer Vision and Pattern Recognition' is_active=True alt_name=None in_archive='cs' is_general=False description='Covers image processing, computer vision, pattern recognition, and scene understanding. Roughly includes material in ACM Subject Classes I.2.10, I.4, and I.5.'}
}
📄 許可證
本項目採用CC BY-NC 4.0許可證。