🚀 深度任意模型V2基础版
深度任意模型V2(Depth Anything V2)是用于深度估计的模型,它基于大量合成和真实图像进行训练,在单目深度估计任务中表现出色,具有细节丰富、性能稳健、高效轻量等优势。
🚀 快速开始
深度任意模型V2基于595K合成标注图像和6200万+真实无标注图像进行训练,为单目深度估计(MDE)提供了强大的解决方案。
✨ 主要特性
- 相较于深度任意模型V1,具有更精细的细节。
- 比深度任意模型V1和基于稳定扩散(SD)的模型(如Marigold、Geowizard)更稳健。
- 比基于SD的模型更高效(快10倍)、更轻量。
- 使用预训练模型进行微调,能获得出色的性能。
📦 安装指南
git clone https://huggingface.co/spaces/depth-anything/Depth-Anything-V2
cd Depth-Anything-V2
pip install -r requirements.txt
💻 使用示例
基础用法
首先,下载模型并将其放在checkpoints
目录下。
import cv2
import torch
from depth_anything_v2.dpt import DepthAnythingV2
model = DepthAnythingV2(encoder='vitb', features=128, out_channels=[96, 192, 384, 768])
model.load_state_dict(torch.load('checkpoints/depth_anything_v2_vitb.pth', map_location='cpu'))
model.eval()
raw_img = cv2.imread('your/image/path')
depth = model.infer_image(raw_img)
📄 许可证
本项目采用CC BY-NC 4.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}
}