🚀 深度任意模型V2(針對度量深度估計進行微調) - Transformers版本
本模型是 深度任意模型V2 的微調版本,用於使用合成的虛擬KITTI數據集進行室外度量深度估計。
該模型檢查點與transformers庫兼容。
深度任意模型V2由李和楊等人在 同名論文 中提出。它採用了與原始深度任意模型相同的架構,但使用了合成數據和更大容量的教師模型,以實現更精細、更穩健的深度預測。這個針對度量深度估計的微調版本首次發佈於 此倉庫。
🔍 主要特性
- 多尺度模型發佈:分別針對室內和室外場景發佈了三種尺度的 六個度量深度模型,具體信息如下:
| 基礎模型 | 參數 | 室內(Hypersim) | 室外(Virtual KITTI 2) |
| ---- | ---- | ---- | ---- |
| Depth-Anything-V2-Small | 2480萬 | 模型卡片 | 模型卡片 |
| Depth-Anything-V2-Base | 9750萬 | 模型卡片 | 模型卡片 |
| Depth-Anything-V2-Large | 3.353億 | 模型卡片 | 模型卡片 |
📚 詳細文檔
- 模型架構:深度任意模型V2利用 DPT 架構,並以 DINOv2 為骨幹網絡。
- 訓練數據:該模型在約60萬個合成標註圖像和約6200萬個真實未標註圖像上進行訓練,在相對和絕對深度估計方面均取得了最先進的結果。

深度任意模型概述。取自 原始論文。
🚀 快速開始
🔧 要求
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-Outdoor-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-Metric-Outdoor-Large-hf")
model = AutoModelForDepthEstimation.from_pretrained("depth-anything/Depth-Anything-V2-Metric-Outdoor-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,
)
更多代碼示例,請參考 文檔。
📄 許可證
本項目採用Apache 2.0許可證。
📖 引用
@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}
}