许可协议:apache-2.0
标签:
- 视觉
任务类型:深度估计
小部件:
- 推理: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-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}
}