Depth Pro 2 L, Core ML, 8-bit weights

Unofficial; derived from Apple's Depth Pro 2; not endorsed by Apple. For non-commercial scientific research only.

Load with CPU_AND_GPU (or CPU_ONLY). Do not use the Neural Engine. On CPU_AND_NE, and therefore on ALL, Core ML computes this file wrongly: on the first 10 iBims-1 images the output is 60% off FP32 on the Neural Engine, against 0.43% on the CPU and 0.33% on the GPU. Reported to Apple as coremltools#2932.

Apple's Depth Pro 2 L as single-image Core ML packages, with every model weight quantized to int8 (linear, symmetric, per output channel) by coremltools 9.0. In the Shallow End study it is within the deployment spread on iBims-1 and statistically indistinguishable from it on KITTI, on the full test sets.

Package Input Size Uncompressed FP16
depthpro2-l_480x640_w1_lin8.mlpackage 480 x 640 (height x width) 320 MiB 638 MiB
depthpro2-l_352x1216_w1_lin8.mlpackage 352 x 1216 (height x width) 320 MiB 638 MiB

Use

import coremltools as ct
import numpy as np

model = ct.models.MLModel("depthpro2-l_480x640_w1_lin8.mlpackage", compute_units=ct.ComputeUnit.CPU_AND_GPU)
frame = rgb_uint8.astype(np.float32) / 255.0                      # (480, 640, 3) RGB
out = model.predict({"frame": frame.astype(np.float16).transpose(2, 0, 1)[None]})
inverse_depth = out["inverse_depth"][0]

Inputs and outputs are those of Apple's exporter (demo/export in apple-aiml-research/ml-depth-pro-2): a float16 RGB frame in [0, 1] at the package's fixed size, inverse depth out. Metric depth needs the focal length, as in Apple's demo.

Results

Fidelity to Apple's PyTorch model at FP32, full test sets, on CPU_AND_GPU:

Test set Images Mean difference from FP32 Upper 95% bound Deployment spread Verdict
iBims-1 (indoor) 100 0.361% 0.412% 0.437% within deployment spread
KITTI Eigen (outdoor) 200 0.501% 0.532% 0.493% not distinguishable from deployment spread

Accuracy against ground truth (CPU_AND_GPU):

Test set Model delta1 AbsRel
iBims-1 Apple's PyTorch model, FP32 0.9437 0.0913
iBims-1 this model 0.9472 0.0903
KITTI Apple's PyTorch model, FP32 0.9642 0.0748
KITTI this model 0.9650 0.0736

Speed (one 640x480 frame, Mac mini M4 Pro, 24 GB, CPU_AND_GPU): median 291 ms, against 239 ms for the uncompressed FP16 package, and the peak process memory in the same benchmark was not lower (1.28 GiB against 0.84 GiB). What 8 bits buys here is half the file size, not speed.

Modifications from Apple's release

  • Exported with Apple's own exporter (ml-depth-pro-2 at commit aa389cb, unmodified) as single-image packages (window 1) at 480x640 and 352x1216. At 854x480 with a window of 4 the same exporter reproduces Apple's released packages bit for bit.
  • Every weight with at least 2048 elements quantized with coremltools.optimize.coreml.linear_quantize_weights (linear_symmetric, int8, per channel). No other change, no retraining.

Files and SHA-256 checksums are in the study's results/release/shallowend-dp2-l-coreml-lin8.json; the files here are byte copies of the packages the study evaluated.

License and terms

Apple Machine Learning Research Model is licensed under the Apple Machine Learning Research Model License Agreement.

The weights are Apple's Depth Pro 2 L weights, modified as listed above, and remain under the Apple Machine Learning Research Model License Agreement, included as LICENSE (byte-identical to Apple's LICENSE_MODEL). They are for non-commercial scientific research only. This is an unofficial release derived from Apple's Depth Pro 2; it is not made, reviewed or endorsed by Apple.

Evaluation data

iBims-1 (100 test images) and the KITTI Eigen test split (200 images used here) are not included. Fidelity is the mean relative difference of inverse depth from Apple's PyTorch model at FP32 on the same image, with a bootstrap 95% interval. The deployment spread is the largest such difference among Apple's own full-precision paths (bf16 on the GPU, Core ML FP16 on the GPU and on the Neural Engine) on the same images, at its upper 95% bound: "within" means no more different from FP32 than choosing another of Apple's official paths. Accuracy uses the ground-truth focal length. Every number here is generated from the study's result files.

More

Study, method and all results: https://shallowend.alethic-labs.com. Code and per-image results: https://github.com/shubhambaid/shallow-end.

Downloads last month
10
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for shubhambaid/shallowend-dp2-l-coreml-lin8

Quantized
(2)
this model