🚀 深度任意模型V2(針對度量深度估計進行微調) - Transformers版本
本模型是 深度任意模型V2 的微調版本,用於使用合成的Hypersim數據集進行室內度量深度估計。
該模型檢查點與transformers庫兼容。
深度任意模型V2由Lihe Yang等人在 同名論文 中提出。它採用了與原始深度任意模型相同的架構,但使用了合成數據和更大容量的教師模型,以實現更精細、更穩健的深度預測。這個針對度量深度估計的微調版本首次發佈於 此倉庫。
分別針對室內和室外場景發佈了三種規模的 六個度量深度模型,具體信息如下:
基礎模型 |
參數數量 |
室內(Hypersim) |
室外(Virtual KITTI 2) |
Depth-Anything-V2-Small |
2480萬 |
模型卡片 |
模型卡片 |
Depth-Anything-V2-Base |
9750萬 |
模型卡片 |
模型卡片 |
Depth-Anything-V2-Large |
3.353億 |
模型卡片 |
模型卡片 |
✨ 主要特性
- 基於微調的深度任意模型V2,適用於室內度量深度估計。
- 模型檢查點與transformers庫兼容。
- 使用合成數據和更大容量的教師模型,實現更精細、更穩健的深度預測。
📦 安裝指南
要求
transformers>=4.45.0
或者,使用從源代碼安裝的 transformers
最新版本:
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-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-Metric-Indoor-Base-hf")
model = AutoModelForDepthEstimation.from_pretrained("depth-anything/Depth-Anything-V2-Metric-Indoor-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,
)
更多代碼示例,請參考 文檔。
📚 詳細文檔
模型描述
深度任意模型V2採用了 DPT 架構和 DINOv2 主幹網絡。
該模型在約60萬張合成標註圖像和約6200萬張真實未標註圖像上進行訓練,在相對和絕對深度估計方面均取得了最先進的成果。

深度任意模型概述。取自 原始論文。
預期用途和限制
你可以使用原始模型進行零樣本深度估計等任務。請查看 模型中心 以查找你感興趣任務的其他版本。
📄 許可證
引用
@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}
}