🚀 DepthPro:單目深度估計
DepthPro是一個用於零樣本度量單目深度估計的基礎模型,能夠生成具有出色清晰度和細粒度細節的高分辨率深度圖。它採用多尺度視覺Transformer(ViT)架構,可快速且精確地進行深度估計。
🚀 快速開始
使用以下代碼開始使用該模型:
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"))
✨ 主要特性
- 高分辨率與細節:能夠合成具有無與倫比清晰度和高頻細節的高分辨率深度圖。
- 度量準確性:預測結果是度量性的,具有絕對尺度,無需依賴相機內參等元數據。
- 快速高效:在標準GPU上,可在0.3秒內生成225萬像素的深度圖。
- 多尺度架構:採用多尺度視覺Transformer(ViT)架構,結合共享的Dinov2編碼器和DPT-like融合階段,實現精確的深度估計。
📚 詳細文檔
模型詳情
DepthPro是一個用於零樣本度量單目深度估計的基礎模型,旨在生成具有出色清晰度和細粒度細節的高分辨率深度圖。它採用基於多尺度視覺Transformer(ViT)的架構,將圖像下采樣、分割成補丁,並使用共享的Dinov2編碼器進行處理。提取的補丁級特徵被合併、上採樣,並使用類似DPT的融合階段進行細化,從而實現精確的深度估計。
論文摘要如下:
我們提出了一個用於零樣本度量單目深度估計的基礎模型。我們的模型Depth Pro能夠合成具有無與倫比清晰度和高頻細節的高分辨率深度圖。預測結果是度量性的,具有絕對尺度,無需依賴相機內參等元數據。並且該模型速度快,在標準GPU上可在0.3秒內生成225萬像素的深度圖。這些特性得益於一系列技術貢獻,包括用於密集預測的高效多尺度視覺Transformer、結合真實和合成數據集以實現高度量準確性和精細邊界跟蹤的訓練協議、用於估計深度圖中邊界準確性的專用評估指標,以及從單張圖像進行的最先進的焦距估計。大量實驗分析了具體的設計選擇,並證明了Depth Pro在多個維度上優於先前的工作。
這是一個已發佈在Hugging Face Hub上的🤗 transformers 模型的模型卡片。
- 開發者: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
訓練詳情
訓練數據
DepthPro模型在以下數據集上進行訓練:

預處理
圖像經過以下預處理步驟:
- 縮放比例為
1/225.
- 歸一化處理,均值為
[0.5, 0.5, 0.5]
,標準差為 [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圖像編碼器的特定任務特徵,以預測水平角視場。
📄 許可證
該模型使用的許可證為apple-amlr。
📖 引用
@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