library_name: transformers
tags:
- 深度估计
- 绝对深度
pipeline_tag: 深度估计
Depth Anything V2(针对度量深度估计微调)- Transformers版本
该模型是基于Depth Anything V2针对室内度量深度估计任务进行微调的版本,使用了合成数据集Hypersim进行训练。
该模型检查点与transformers库兼容。
Depth Anything V2由Lihe Yang等人在同名论文中提出。它采用与原始Depth Anything相同的架构,但通过合成数据和更大容量的教师模型实现了更精细、更鲁棒的深度预测。这个针对度量深度估计的微调版本首次发布于该仓库。
共发布了六种度量深度模型,分别针对室内和室外场景的三种规模:
基础模型 |
参数量 |
室内(Hypersim) |
室外(Virtual KITTI 2) |
Depth-Anything-V2-Small |
24.8M |
模型卡片 |
模型卡片 |
Depth-Anything-V2-Base |
97.5M |
模型卡片 |
模型卡片 |
Depth-Anything-V2-Large |
335.3M |
模型卡片 |
模型卡片 |
模型描述
Depth Anything V2采用DPT架构,以DINOv2为骨干网络。
该模型在约60万张合成标注图像和约6200万张真实无标注图像上进行训练,在相对和绝对深度估计任务上都达到了最先进的性能。

Depth Anything概览图。取自原论文。
使用场景与限制
您可以将原始模型用于零样本深度估计等任务。查看模型中心寻找其他任务版本。
环境要求
transformers>=4.45.0
或者从源码安装最新版:
pip install git+https://github.com/huggingface/transformers
使用方法
以下是使用该模型进行零样本深度估计的示例:
from transformers import pipeline
from PIL import Image
import requests
pipe = pipeline(task="depth-estimation", model="depth-anything/Depth-Anything-V2-Metric-Indoor-Small-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-Metric-Indoor-Small-hf")
model = AutoModelForDepthEstimation.from_pretrained("depth-anything/Depth-Anything-V2-Metric-Indoor-Small-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,
)
更多代码示例请参考文档。
引用
@article{depth_anything_v2,
title={Depth Anything V2},
author={Yang, Lihe and Kang, Bingyi and Huang, Zilong and Zhao, Zhen and Xu, Xiaogang and Feng, Jiashi and Zhao, Hengshuang},
journal={arXiv:2406.09414},
year={2024}
}
@inproceedings{depth_anything_v1,
title={Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data},
author={Yang, Lihe and Kang, Bingyi and Huang, Zilong and Xu, Xiaogang and Feng, Jiashi and Zhao, Hengshuang},
booktitle={CVPR},
year={2024}
}