🚀 深度任意模型V2基础版 - Transformers版本
深度任意模型V2基于59.5万张合成标注图像和6200万张以上真实未标注图像进行训练,是目前最强大的单目深度估计(MDE)模型,具备以下特性:
- 比深度任意模型V1拥有更精细的细节
- 比深度任意模型V1和基于Stable Diffusion(SD)的模型(如Marigold、Geowizard)更稳健
- 比基于SD的模型更高效(快10倍)、更轻量级
- 使用预训练模型进行微调后,能取得出色的性能
此模型检查点与Transformers库兼容。
深度任意模型V2由李和(Lihe Yang)等人在同名论文《深度任意模型V2》中提出。它采用了与原始深度任意模型相同的架构,但利用合成数据和更大容量的教师模型,实现了更精细、更稳健的深度预测。原始深度任意模型由李和(Lihe Yang)等人在论文《深度任意模型:释放大规模未标注数据的力量》中提出,并首次在该仓库发布。
在线演示。
🚀 快速开始
深度任意模型V2是一款强大的单目深度估计模型,下面为你介绍其基本信息和使用方法。
✨ 主要特性
- 细节更精细:相较于深度任意模型V1,深度任意模型V2能捕捉到更多的图像细节。
- 性能更稳健:比深度任意模型V1和基于SD的模型(如Marigold、Geowizard)更稳定,在不同场景下都能有较好的表现。
- 高效轻量级:比基于SD的模型更高效,推理速度快10倍,同时模型体积更小。
- 微调效果好:使用预训练模型进行微调后,能在特定任务上取得出色的性能。
📚 详细文档
模型描述
深度任意模型V2采用了DPT架构,并以DINOv2作为骨干网络。
该模型在约60万张合成标注图像和约6200万张真实未标注图像上进行训练,在相对深度估计和绝对深度估计任务上都取得了最先进的成果。

深度任意模型概述。取自原论文。
预期用途与限制
你可以使用该原始模型进行零样本深度估计任务。你可以在模型中心查找其他版本以满足你的特定需求。
模型信息表格
属性 |
详情 |
模型类型 |
基于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-Base-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-Base-hf")
model = AutoModelForDepthEstimation.from_pretrained("depth-anything/Depth-Anything-V2-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,
)
更多代码示例请参考文档。
引用信息
@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许可证。