🚀 深度任意模型V2基础版 - Transformers版本
深度任意模型V2基于59.5万张合成标注图像和6200万多张真实无标注图像进行训练,是当前最强大的单目深度估计(MDE)模型,具备以下特性:
- 比深度任意模型V1拥有更精细的细节
- 比深度任意模型V1和基于稳定扩散(SD)的模型(如Marigold、Geowizard)更稳健
- 比基于SD的模型更高效(快10倍)、更轻量级
- 使用预训练模型进行微调后,性能表现出色
此模型检查点与Transformers库兼容。
深度任意模型V2由李和杨等人在同名论文中提出。它采用了与原始深度任意模型相同的架构,但使用了合成数据和更大容量的教师模型,从而实现了更精细、更稳健的深度预测。原始的深度任意模型由李和杨等人在论文《深度任意:释放大规模无标注数据的力量》中提出,并首次在此仓库中发布。
在线演示
✨ 主要特性
- 基于59.5万张合成标注图像和6200万多张真实无标注图像训练,提供强大的单目深度估计能力。
- 相比Depth Anything V1,具有更精细的细节和更强的鲁棒性。
- 比基于SD的模型更高效(快10倍)和轻量级。
- 使用预训练模型进行微调后,能获得出色的性能。
📦 安装指南
文档未提及安装步骤,跳过此章节。
💻 使用示例
基础用法
以下是如何使用该模型进行零样本深度估计的示例:
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,
)
更多代码示例,请参考文档。
📚 详细文档
模型描述
深度任意模型V2采用了基于DPT架构和DINOv2主干网络。
该模型在约60万张合成标注图像和约6200万张真实无标注图像上进行训练,在相对和绝对深度估计方面均取得了最先进的成果。

深度任意模型概述。取自原始论文。
预期用途与限制
你可以使用原始模型进行零样本深度估计等任务。请参考模型中心,查找其他感兴趣的版本。
引用
@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许可证。