Depth Pro 2 ONNX
Community ONNX exports of Depth Pro 2 Small for single-photo metric depth estimation. Each file includes Apple’s focal-length estimator and accepts variable image sizes. Depth Pro 2 Small · Focal-length estimator
| File | Size | Weights |
|---|---|---|
depthpro2-s-dynamic.onnx | 192 MB | FP32 reference |
depthpro2-s-dynamic-fp16.onnx | 97 MB | FP16 storage, FP32 inference |
depthpro2-s-dynamic-int8.onnx | 65 MB | Blockwise INT8 for eligible matrix multiplications |
INT8 uses ONNX Runtime’s MatMulNBits operator with symmetric 8-bit weights in blocks of 32.
Output differences from FP32
The comparison uses Apple’s example photo, resized to 384 × 288 and run with ONNX Runtime 1.32.0 on CPU. Source image
| Weights | Depth difference (median / P95) | Focal-length difference |
|---|---|---|
| FP16 | 0.01% / 0.08% | 0.02% |
| INT8 | 0.30% / 1.00% | 0.03% |
Differences are absolute percentages relative to FP32. Depth statistics cover pixels where both
estimates were finite and FP32 inverse depth exceeded 0.001. INT8 changed whether depth was
finite for 0.04% of pixels.
Quick start
Download an ONNX file and install onnxruntime, numpy, and pillow.
import numpy as np
import onnxruntime as ort
from PIL import Image, ImageOps
with Image.open("photo.jpg") as photo:
rgb = np.asarray(ImageOps.exif_transpose(photo).convert("RGB"))
image = np.ascontiguousarray(rgb.transpose(2, 0, 1)[None])
session = ort.InferenceSession(
"depthpro2-s-dynamic-fp16.onnx", providers=["CPUExecutionProvider"]
)
depth, inverse_depth, focal_px = session.run(None, {"image_rgb": image})
image_rgb is an upright uint8 RGB tensor of shape (1, 3, H, W). The model returns depth
in meters and focal-length-normalized inverse_depth, both of shape (H, W), plus the estimated
focallength_px in pixels.
License
Apple Machine Learning Research Model is licensed under the Apple Machine Learning Research Model License Agreement.
These ONNX derivatives are for non-commercial scientific research and academic development under the Apple model license. See the third-party acknowledgements.