🚀 深度任意模型(基礎尺寸模型,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許可證。