库名称: transformers
许可证: apple-amlr
标签:
- 视觉
- 深度估计
任务标签: 深度估计
示例:
- 图片: https://huggingface.co/datasets/mishig/sample_images/resolve/main/tiger.jpg
示例标题: 老虎
- 图片: https://huggingface.co/datasets/mishig/sample_images/resolve/main/teapot.jpg
示例标题: 茶壶
- 图片: https://huggingface.co/datasets/mishig/sample_images/resolve/main/palace.jpg
示例标题: 宫殿
DepthPro: 单目深度估计

这是DepthPro的transformers版本,一个用于零样本度量单目深度估计的基础模型,旨在生成具有卓越清晰度和细粒度细节的高分辨率深度图。如需与原始代码库兼容的检查点,请访问此仓库。
目录
模型详情
DepthPro是一个用于零样本度量单目深度估计的基础模型,旨在生成具有卓越清晰度和细粒度细节的高分辨率深度图。它采用基于多尺度视觉变换器(ViT)的架构,其中图像被下采样、分割成块,并使用共享的Dinov2编码器进行处理。提取的块级特征被合并、上采样,并使用类似DPT的融合阶段进行细化,从而实现精确的深度估计。
论文摘要如下:
我们提出了一个用于零样本度量单目深度估计的基础模型。我们的模型Depth Pro能够合成具有无与伦比清晰度和高频细节的高分辨率深度图。预测结果是度量的,具有绝对尺度,无需依赖相机内参等元数据。并且模型速度快,在标准GPU上0.3秒内即可生成2.25兆像素的深度图。这些特性得益于多项技术贡献,包括用于密集预测的高效多尺度视觉变换器、结合真实和合成数据集的训练协议以实现高度量精度和精细边界追踪、用于评估深度图边界精度的专用指标,以及从单张图像中估计焦距的最新技术。大量实验分析了具体设计选择,并证明Depth Pro在多个维度上优于先前的工作。
这是🤗 transformers模型的模型卡,已推送至Hub。
- 开发者: Aleksei Bochkovskii, Amaël Delaunoy, Hugo Germain, Marcel Santos, Yichao Zhou, Stephan R. Richter, Vladlen Koltun.
- 模型类型: DepthPro
- 许可证: Apple-ASCL
模型来源
- HF文档: DepthPro
- 代码库: https://github.com/apple/ml-depth-pro
- 论文: https://arxiv.org/abs/2410.02073
如何开始使用模型
使用以下代码开始使用模型。
import requests
from PIL import Image
import torch
from transformers import DepthProImageProcessorFast, DepthProForDepthEstimation
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
url = 'https://huggingface.co/datasets/mishig/sample_images/resolve/main/tiger.jpg'
image = Image.open(requests.get(url, stream=True).raw)
image_processor = DepthProImageProcessorFast.from_pretrained("apple/DepthPro-hf")
model = DepthProForDepthEstimation.from_pretrained("apple/DepthPro-hf").to(device)
inputs = image_processor(images=image, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model(**inputs)
post_processed_output = image_processor.post_process_depth_estimation(
outputs, target_sizes=[(image.height, image.width)],
)
field_of_view = post_processed_output[0]["field_of_view"]
focal_length = post_processed_output[0]["focal_length"]
depth = post_processed_output[0]["predicted_depth"]
depth = (depth - depth.min()) / (depth.max() - depth.min())
depth = depth * 255.
depth = depth.detach().cpu().numpy()
depth = Image.fromarray(depth.astype("uint8"))
训练详情
训练数据
DepthPro模型在以下数据集上进行训练:

预处理
图像经过以下预处理步骤:
- 按
1/225.
缩放
- 使用
mean=[0.5, 0.5, 0.5]
和std=[0.5, 0.5, 0.5]
归一化
- 调整大小为
1536x1536
像素
训练超参数

评估

模型架构与目标

DepthProForDepthEstimation
模型使用DepthProEncoder
编码输入图像,并使用FeatureFusionStage
融合编码器的输出特征。
DepthProEncoder
进一步使用两个编码器:
patch_encoder
- 输入图像按
scaled_images_ratios
配置中指定的多个比例缩放。
- 每个缩放后的图像被分割成大小为
patch_size
的小块,重叠区域由scaled_images_overlap_ratios
确定。
- 这些小块由**
patch_encoder
**处理
image_encoder
- 输入图像也被缩放到
patch_size
并由**image_encoder
**处理
这两个编码器可以通过patch_model_config
和image_model_config
分别配置,默认情况下都是独立的Dinov2Model
。
来自两个编码器的输出(last_hidden_state
)和来自**patch_encoder
**的选定中间状态(hidden_states
)通过基于DPT
的FeatureFusionStage
进行融合以进行深度估计。
网络还补充了一个焦距估计头。一个小型卷积头接收来自深度估计网络的冻结特征和来自单独ViT图像编码器的任务特定特征,以预测水平视角场。
引用
BibTeX:
@misc{bochkovskii2024depthprosharpmonocular,
title={Depth Pro: Sharp Monocular Metric Depth in Less Than a Second},
author={Aleksei Bochkovskii and Amaël Delaunoy and Hugo Germain and Marcel Santos and Yichao Zhou and Stephan R. Richter and Vladlen Koltun},
year={2024},
eprint={2410.02073},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2410.02073},
}
模型卡作者
Armaghan Shakir