模型概述
模型特點
模型能力
使用案例
🚀 單目深度估計模型 dpt-beit-large-512
單目深度估計旨在從單張圖像或相機視角推斷出詳細的深度信息,在生成式AI、3D重建和自動駕駛等領域有著廣泛的應用。本項目的dpt-beit-large-512
模型,基於BEiT架構,為單目深度估計提供了有效的解決方案。
🚀 快速開始
單目深度估計致力於從單張圖像或相機視角推斷詳細的深度信息,在生成式AI、3D重建和自動駕駛等領域具有廣泛應用。然而,由於問題的約束不足,從單張圖像的單個像素中推導深度極具挑戰性。近年來,基於學習的方法取得了顯著進展,特別是MiDaS,它利用數據集混合和尺度與平移不變損失。MiDaS不斷發展,推出了具有更強大骨幹網絡的版本以及適用於移動設備的輕量級變體。隨著Transformer架構在計算機視覺領域的興起,包括ViT等模型的開創,人們開始將其用於深度估計。受此啟發,MiDaS v3.1結合了有前景的基於Transformer的編碼器和傳統的卷積編碼器,旨在全面研究深度估計技術。
輸入圖像 | 輸出深度圖像 |
---|---|
![]() |
![]() |
✨ 主要特性
- 強大的骨幹網絡:該DPT模型使用BEiT模型作為骨幹網絡,並在頂部添加了頸部和頭部,用於單目深度估計。
- 多種變體選擇:提供瞭如BEiT512 - L、BEiT384 - L和BEiT384 - B等變體,數字表示訓練分辨率,字母表示模型大小。
- 廣泛的應用場景:可用於零樣本單目深度估計,適用於任何進行單目深度估計的用戶。
📦 安裝指南
安裝依賴
確保更新PyTorch和Transformers,版本不匹配可能會導致錯誤,如:"TypeError: unsupported operand type(s) for //: 'NoneType' and 'NoneType'"。經測試,以下版本可正常運行:
import torch
import transformers
print(torch.__version__)
print(transformers.__version__)
out: '2.2.1+cpu'
out: '4.37.2'
安裝命令如下:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
💻 使用示例
基礎用法
以下是如何使用該模型對圖像進行零樣本深度估計的示例:
from transformers import DPTImageProcessor, DPTForDepthEstimation
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)
processor = DPTImageProcessor.from_pretrained("Intel/dpt-beit-large-512")
model = DPTForDepthEstimation.from_pretrained("Intel/dpt-beit-large-512")
# prepare image for the model
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predicted_depth = outputs.predicted_depth
# interpolate to original size
prediction = torch.nn.functional.interpolate(
predicted_depth.unsqueeze(1),
size=image.size[::-1],
mode="bicubic",
align_corners=False,
)
# visualize the prediction
output = prediction.squeeze().cpu().numpy()
formatted = (output * 255 / np.max(output)).astype("uint8")
depth = Image.fromarray(formatted)
depth
高級用法
也可以使用管道API:
from transformers import pipeline
pipe = pipeline(task="depth-estimation", model="Intel/dpt-beit-large-512")
result = pipe("http://images.cocodataset.org/val2017/000000181816.jpg")
result["depth"]
📚 詳細文檔
模型詳情
屬性 | 詳情 |
---|---|
模型作者 - 公司 | Intel |
日期 | 2024年3月7日 |
版本 | 1 |
類型 | 計算機視覺 - 單目深度估計 |
論文或其他資源 | MiDaS v3.1 – A Model Zoo for Robust Monocular Relative Depth Estimation 和 GitHub Repo |
許可證 | MIT |
問題或評論 | 社區板塊 和 Intel開發者Discord |
預期用途
預期用途 | 描述 |
---|---|
主要預期用途 | 可以使用原始模型進行零樣本單目深度估計。查看模型中心以尋找針對您感興趣的任務進行微調的版本。 |
主要預期用戶 | 任何進行單目深度估計的人 |
非預期用途 | 該模型在大多數情況下需要針對您的特定任務進行微調。該模型不應被用於故意為人們創造敵對或疏遠的環境。 |
定量分析
模型 | 方形分辨率HRWSI RMSE | 方形分辨率混合MVS REL | 方形分辨率ReDWeb RMSE |
---|---|---|---|
BEiT 384 - L | 0.068 | 0.070 | 0.076 |
Swin - L訓練1 | 0.0708 | 0.0724 | 0.0826 |
Swin - L訓練2 | 0.0713 | 0.0720 | 0.0831 |
ViT - L | 0.071 | 0.072 | 0.082 |
--- | --- | --- | --- |
Next - ViT - L - 1K - 6M | 0.075 | 0.073 | 0.085 |
DeiT3 - L - 22K - 1K | 0.070 | 0.070 | 0.080 |
ViT - L - Hybrid | 0.075 | 0.075 | 0.085 |
DeiT3 - L | 0.077 | 0.075 | 0.087 |
--- | --- | --- | --- |
ConvNeXt - XL | 0.075 | 0.075 | 0.085 |
ConvNeXt - L | 0.076 | 0.076 | 0.087 |
EfficientNet - L2 | 0.165 | 0.277 | 0.219 |
--- | --- | --- | --- |
ViT - L Reversed | 0.071 | 0.073 | 0.081 |
Swin - L Equidistant | 0.072 | 0.074 | 0.083 |
--- | --- | --- | --- |
🔧 技術細節
該DPT模型在140萬張圖像上進行了單目深度估計訓練。它由Ranftl等人在2021年的論文Vision Transformers for Dense Prediction中提出,並首次在this repository中發佈。本模型卡具體指論文中的BEiT512 - L,即dpt - beit - large - 512。一篇2023年的論文專門討論了BEiT,詳見MiDaS v3.1 – A Model Zoo for Robust Monocular Relative Depth Estimation。
📄 許可證
本模型採用MIT許可證,但該許可證不構成法律建議。我們不對使用此模型的第三方的行為負責。如需將此模型用於商業目的,請諮詢律師。
⚠️ 重要提示
- 輸出準確性:dpt - beit - large - 512可能會產生事實錯誤的輸出,不應依賴它來生成事實準確的信息。由於預訓練模型和微調數據集的限制,該模型可能會生成低俗、有偏見或其他冒犯性的輸出。因此,在部署dpt - beit - large - 512的任何應用程序之前,開發人員應進行安全測試。
- 用戶風險告知:用戶(直接用戶和下游用戶)應瞭解該模型的風險、偏差和侷限性。
💡 使用建議
這裡有幾個有用的鏈接,可瞭解更多關於英特爾AI軟件的信息:
BibTeX引用
@article{DBLP:journals/corr/abs-2103-13413,
author = {Ren{\'{e}} Reiner Birkl, Diana Wofk, Matthias Muller},
title = {MiDaS v3.1 – A Model Zoo for Robust Monocular Relative Depth Estimation},
journal = {CoRR},
volume = {abs/2307.14460},
year = {2021},
url = {https://arxiv.org/abs/2307.14460},
eprinttype = {arXiv},
eprint = {2307.14460},
timestamp = {Wed, 26 Jul 2023},
biburl = {https://dblp.org/rec/journals/corr/abs-2307.14460.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}






