Instructions to use pratikgx/Depth-Pro-2-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use pratikgx/Depth-Pro-2-MLX-4bit with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download pratikgx/Depth-Pro-2-MLX-4bit --local-dir Depth-Pro-2-MLX-4bit
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Depth Pro 2 MLX 4-bit (unofficial)
This is an unofficial community Model Derivative: a 4-bit MLX conversion of Apple Depth Pro 2, Apple's metric monocular depth model. It is not an Apple product, and Apple does not endorse it.
Original weights and research release: apple/DepthPro2, apple/DepthPro2-L, apple/DepthPro2-H, and the shared focal-length estimator apple/DepthPro2-focal. Upstream code: apple-aiml-research/ml-depth-pro-2.
Apple Machine Learning Research Model is licensed under the Apple Machine Learning Research Model License Agreement. This conversion is a Model Derivative and is for research use only (non-commercial scientific research and academic development). See LICENSE.
The MLX port this conversion was built with (depth_pro_2_mlx 0.1.0, on MLX 0.32.4) was built by @SpaceXSI with a coding agent.
What's in this repo
Only the sizes that met the inclusion bar below are uploaded.
| Folder | Size | Original repo | 4-bit bundle | Official Apple download |
|---|---|---|---|---|
L/ |
L (334M) | apple/DepthPro2-L | 272.1 MiB | 1,274.0 MiB |
H/ |
H+ (872M) | apple/DepthPro2-H | 562.6 MiB | 3,326.9 MiB |
Each folder contains model.safetensors and config.json. The bundle includes the encoder (4-bit), the DPT decoder (BF16), the inverse-depth head (FP32), and the shared FOV estimator (BF16 trunk, FP32 head) so a size can be loaded from one folder. load_4bit.py is at the repo root.
How it was converted
This is a weight-only conversion. There was no retraining or fine-tuning.
- MLX affine quantization, 4 bits, group size 64, applied to the encoder's
nn.Linearlayers. - Kept at higher precision: LayerNorms; class and register-token embeddings; all
Conv2d/ConvTranspose2dlayers (patch embedding, reassemble, DPT decoder; MLX does not quantize convs this way); the inverse-depth head (FP32, as in the MLX port); and the FOV estimator (BF16/FP32), both for stability and because some FOV linear widths are not divisible by 64. - Conv weights are stored in the MLX NHWC layout used by the port.
S and B were converted with the same recipe and checked, but they did not meet the inclusion bar and are not in this repo. For those sizes, use the original Apple weights with the MLX port in BF16.
Accuracy
Measured on a 64GB M5 Pro Mac mini. The inclusion bar was: no NaNs, and inverse-depth Pearson r โฅ 0.999 against the Phase 1 PyTorch MPS BF16 reference (.npz from Apple's official assets/example.jpg at native 1920ร1440). MLX BF16 numbers are from the same photo and the same references, for comparison.
Focal length is estimated by the FOV head, which was not quantized. The 0.581 px difference versus the PyTorch reference is the same as MLX BF16.
Official photo (1920ร1440) vs Phase 1 reference
| Size | Uploaded | 4-bit Pearson r | BF16 Pearson r | 4-bit median rel. error | BF16 median rel. error | 4-bit NaNs | FOV error vs ref (px) |
|---|---|---|---|---|---|---|---|
| S | no | 0.99499 | 0.99996 | 0.0489 | 0.00336 | 0 | 0.581 |
| B | no | 0.99653 | 0.99998 | 0.1552 | 0.00217 | 0 | 0.581 |
| L | yes | 0.99959 | 0.99999 | 0.0123 | 0.00204 | 0 | 0.581 |
| H+ | yes | 0.99986 | 1.00000 | 0.0311 | 0.00230 | 0 | 0.581 |
1280ร720 cover-crop, 4-bit vs same-session MLX BF16
There is no Phase 1 720p reference file. This comparison uses the same cover-crop of example.jpg that the Phase 1/2 speed tests used (first frame, no pan), and compares 4-bit inverse depth to a same-session MLX BF16 run.
| Size | 4-bit vs BF16 Pearson r | 4-bit vs BF16 median rel. error | 4-bit NaNs |
|---|---|---|---|
| S | 0.99421 | 0.0446 | 0 |
| B | 0.99714 | 0.1569 | 0 |
| L | 0.99897 | 0.0416 | 0 |
| H+ | 0.99973 | 0.0405 | 0 |
Load memory, informational only (Metal peak after loading the 4-bit bundle, not a speed test): L 282.8 MiB, H+ 576.2 MiB.
How to run it
Install the community MLX port (depth_pro_2_mlx 0.1.0) and MLX 0.32.4 or later, then:
from pathlib import Path
from huggingface_hub import snapshot_download
from depth_pro_2_mlx import load_rgb, to_normalized
repo = snapshot_download("pratikgx/Depth-Pro-2-MLX-4bit")
# load_4bit.py lives at the repo root
import sys
sys.path.insert(0, repo)
from load_4bit import load_depth_pro_2_mlx_4bit
model = load_depth_pro_2_mlx_4bit(Path(repo) / "L") # or Path(repo) / "H" for H+
image, f_px = load_rgb("photo.jpg")
prediction = model.infer(to_normalized(image), f_px=f_px)
depth = prediction["depth"] # meters
inverse_depth = prediction["inverse_depth"]
focal = prediction["focallength_px"]
Use BF16 for full-precision work with the MLX port (the loader already builds the unquantized parts in BF16 / FP32). Prefer size L or H+ from this repo when you want the 4-bit weights.
Caveats
- These 4-bit quality numbers come from a small test set: one official photo at native resolution, plus one 1280ร720 cover-crop of that photo. They are not a dataset-wide accuracy claim.
- In earlier full-precision MLX tests, FP16 produced all-NaN depth maps on some inputs. Use BF16 for full precision, not FP16.
- This conversion does not change the original research-only license. Do not use the original weights or this derivative in a commercial product or service.
- Depth Pro 2 is Apple's model. This repository only provides a quantized MLX packing of it.
License and attribution
Apple Machine Learning Research Model is licensed under the Apple Machine Learning Research Model License Agreement.
This repository redistributes a Model Derivative of Apple Depth Pro 2. The modifications are: conversion to the MLX weight layout, and affine 4-bit weight-only quantization (group size 64) of encoder linear layers, with the layers listed above left in BF16 or FP32. The LICENSE file in this repository is a copy of that agreement.
The name, trademarks, service marks, or logos of Apple may not be used to endorse or promote this derivative.
Write-up on GitHub
How I ran this, what broke, and the scripts: Apple Depth Pro 2 (Core ML, PyTorch, MLX). It's part of Local AI field notes, where I log every model I run on my Mac mini.
4-bit
Model tree for pratikgx/Depth-Pro-2-MLX-4bit
Base model
apple/DepthPro2-H