🚀 深度任意模型(小型模型,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-small-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-small-hf")
model = AutoModelForDepthEstimation.from_pretrained("LiheYoung/depth-anything-small-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,
)
更多代碼示例請參考文檔。
📚 詳細文檔
模型描述
深度任意模型利用DPT架構和DINOv2骨幹網絡,在約6200萬張圖像上進行訓練,在相對和絕對深度估計任務中均取得了最先進的結果。

深度任意模型概述。取自原始論文。
預期用途和侷限性
你可以使用原始模型進行零樣本深度估計等任務。
引用信息
@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許可證。