license: apache-2.0
tags:
- 视觉
pipeline_tag: 深度估计
widget:
- inference: false
Depth Anything(大尺寸模型,Transformers版本)
Depth Anything模型。该模型由Lihe Yang等人在论文《Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data》中提出,并首次发布于此代码库。
同时提供了在线演示。
免责声明:发布Depth Anything的团队未为此模型编写模型卡,因此本模型卡由Hugging Face团队编写。
模型描述
Depth Anything采用DPT架构,并基于DINOv2骨干网络。
该模型在约6200万张图像上进行训练,在相对和绝对深度估计任务中均取得了最先进的结果。

Depth Anything概览图。摘自原论文。
预期用途与限制
您可以将原始模型用于零样本深度估计等任务。请访问模型中心查找其他适用于您感兴趣任务的版本。
使用方法
以下是如何使用该模型进行零样本深度估计的示例:
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}
}