🚀 深度任意模型(大型模型,Transformer版本)
深度任意模型(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-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("LiheYoung/depth-anything-large-hf")
model = AutoModelForDepthEstimation.from_pretrained("LiheYoung/depth-anything-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,
)
更多代码示例请参考 文档。
📚 详细文档
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许可证。