# Apple Depth Pro：从一张图片得到清晰的绝对深度

Apple Depth Pro 从单张图片估计绝对深度与焦距，GPU 上约 0.3 秒。先在浏览器体验，再用官方 CLI、Transformers 或 ONNX 运行。

Canonical URL: https://aiidelist.com/zh/blog/depth-pro-zh

Language: zh

Published: 2026-09-24

Updated: 2026-09-24

APPLE DEPTH PRO · MONOCULAR METRIC DEPTH

Depth Pro 是 Apple 面向零样本单目深度估计的基础模型。它输出以米为单位的绝对距离、估计焦距和清晰边界，且不需要相机元数据。先在浏览器生成深度图，再在本地复现。

[生成深度图](/zh/blog/depth-map-generator-zh)[GitHub：apple/ml-depth-pro](https://github.com/apple/ml-depth-pro)[Hugging Face：apple/DepthPro-hf](https://huggingface.co/apple/DepthPro-hf)

## Depth Pro 的不同之处

大多数单目深度模型只预测相对深度：远近顺序正确但尺度未知。Depth Pro 预测带绝对尺度的深度，并从图片本身估计焦距，因此即使没有 EXIF 数据的照片也能使用。Apple 报告其多尺度视觉 Transformer 能保持细小结构和发丝级边界的清晰度，同时在标准 GPU 上约 0.3 秒生成 2.25 MP 的深度图。

## 在浏览器中运行

本站的深度图生成器通过 Transformers.js 加载 ONNX 移植版，并使用 WebGPU 在你的 GPU 上运行。q4f16 权重约 600 MB，首次运行后由浏览器缓存。照片不会离开设备。

Transformers.js · WebGPU

```text
import { AutoModelForDepthEstimation, AutoProcessor, RawImage } from "@huggingface/transformers";

const id = "onnx-community/DepthPro-ONNX";
const processor = await AutoProcessor.from_pretrained(id);
const model = await AutoModelForDepthEstimation.from_pretrained(id, { device: "webgpu", dtype: "q4f16" });

const image = await RawImage.read("photo.jpg");
const { predicted_depth, focallength_px } = await model(await processor(image));
// predicted_depth: metric depth (metres); resize to the input and normalise for display.
```

<a id="run"></a>

## 用 Python 运行 Depth Pro

Transformers 集成在后处理后返回以米为单位的深度、视场角和焦距。可在 CUDA、Apple Silicon（MPS）或 CPU（较慢）上运行。

Python · transformers ≥ 4.48

```text
import torch
from PIL import Image
from transformers import DepthProForDepthEstimation, DepthProImageProcessorFast

device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
processor = DepthProImageProcessorFast.from_pretrained("apple/DepthPro-hf")
model = DepthProForDepthEstimation.from_pretrained("apple/DepthPro-hf").to(device).eval()

image = Image.open("photo.jpg").convert("RGB")
inputs = processor(images=image, return_tensors="pt").to(device)
with torch.no_grad():
    outputs = model(**inputs)

post = processor.post_process_depth_estimation(outputs, target_sizes=[(image.height, image.width)])[0]
depth_m = post["predicted_depth"]          # metres, shape (H, W)
focal_px = float(post["focal_length"])     # estimated focal length in pixels
print(depth_m.min().item(), depth_m.max().item(), focal_px)
```

## 官方 ml-depth-pro 命令行

Apple 仓库提供了一个小型命令行工具，会下载 checkpoint 并为任意输入图片输出深度图。需要与论文完全一致的参考实现时使用它。

Shell · official repository

```text
git clone https://github.com/apple/ml-depth-pro.git
cd ml-depth-pro
conda create -n depth-pro -y python=3.9
conda activate depth-pro
pip install -e .
source get_pretrained_models.sh          # downloads checkpoints/depth_pro.pt
depth-pro-run -i ./data/example.jpg      # writes a depth map next to the input
```

## Depth Pro 与 Depth Anything 的区别

Depth Anything V2 Small 体积约小十倍、速度更快，且无需 WebGPU，但输出的是相对深度。需要米制距离、焦距或用于合成的清晰边缘时选 Depth Pro；快速预览和低端设备选 Depth Anything。生成器支持在同一张图上切换两者。

## 常见问题

**Depth Pro 能在 Mac 上运行吗？**

可以。PyTorch 模型可通过 MPS 后端在 Apple Silicon 上运行，浏览器工具也能在任何支持 WebGPU 的 Mac 上运行。每张图片需要几秒，而不是 Apple 在数据中心 GPU 上测得的 0.3 秒。

**有官方的 Core ML 或 iPhone 版本吗？**

官方发布的是 PyTorch 版本。可以自行转换为 Core ML 或 Core AI，但 Apple 仓库不提供该流程；请仔细测量内存，因为原生 1536 × 1536 输入对手机来说负担较大。

**绝对尺度有多准确？**

Apple 报告在多个数据集上取得了零样本绝对深度的领先精度，但尺度仍取决于焦距估计。单张图片的米制数值应视为估计值，测量前请用已知尺寸的物体验证。

## 速览

**任务**

单目绝对深度 + 焦距估计

**输出**

2.25 百万像素深度图（原生 1536 × 1536）

**官方速度**

标准 GPU 上每张约 0.3 秒（Apple）

**发布**

2024 年 10 月 · ICLR 2025 · arXiv 2410.02073

**权重**

apple/DepthPro · apple/DepthPro-hf（Transformers）· onnx-community/DepthPro-ONNX（浏览器）

**许可**

ml-depth-pro 仓库中的 Apple 许可；商用前请核对

核对于 2026-09-17

## 官方来源

- [Apple Machine Learning Research](https://machinelearning.apple.com/research/depth-pro)
- [Paper (arXiv 2410.02073)](https://arxiv.org/abs/2410.02073)
- [onnx-community/DepthPro-ONNX](https://huggingface.co/onnx-community/DepthPro-ONNX)

## 相关页面

- [用 SHARP 把图片转 3D](/zh/blog/apple-sharp-image-to-3d-zh)
- [Luce 与 SHARP 对比](/zh/blog/luce-vs-sharp-zh)
- [全部 Apple 模型](/zh/blog/apple-ai-models-zh)
- [全部 Apple 模型](/zh/blog/apple-ai-models-zh)
