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