🚀 深度任意模型(基础尺寸模型,Transformers版本)
深度任意模型(Depth Anything)用于深度估计任务,它利用大规模无标签数据,在相对和绝对深度估计方面取得了先进的成果。该模型为相关视觉任务提供了强大的支持,可应用于零样本深度估计等场景。
🚀 快速开始
深度任意模型(Depth Anything)由Lihe Yang等人在论文 深度任意模型:释放大规模无标签数据的力量 中提出,并首次在 此仓库 发布。同时还提供了 在线演示。
需注意,发布深度任意模型的团队未为此模型撰写模型卡片,此卡片由Hugging Face团队编写。
✨ 主要特性
- 架构优势:深度任意模型采用 DPT 架构,并以 DINOv2 为骨干网络。
- 训练数据丰富:该模型在约6200万张图像上进行训练,在相对和绝对深度估计方面均取得了先进的成果。

深度任意模型概述。取自 原论文。
📚 详细文档
预期用途和限制
你可以使用原始模型进行零样本深度估计等任务。可查看 模型中心 以寻找其他感兴趣的版本。
使用方法
以下是使用该模型进行零样本深度估计的示例:
基础用法
from transformers import pipeline
from PIL import Image
import requests
pipe = pipeline(task="depth-estimation", model="LiheYoung/depth-anything-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("LiheYoung/depth-anything-base-hf")
model = AutoModelForDepthEstimation.from_pretrained("LiheYoung/depth-anything-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,
)
更多代码示例请参考 文档。
BibTeX引用和引用信息
@misc{yang2024depth,
title={Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data},
author={Lihe Yang and Bingyi Kang and Zilong Huang and Xiaogang Xu and Jiashi Feng and Hengshuang Zhao},
year={2024},
eprint={2401.10891},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
📄 许可证
本项目采用Apache 2.0许可证。