Depth Anything 3 Small, smol (ONNX)

A compressed version of Depth Anything 3 Small for monocular depth estimation, produced with SmolAnything: structured pruning and low-rank replacements fitted on unlabeled calibration images, with an LLM (Claude Opus 5.5, medium effort) deciding what to cut. No retraining, no labels.

Original This model
Parameters 25.8M 18.5M (βˆ’28.1%)
MACs (378Γ—504 input) 37.6G 32.8G (βˆ’12.8%)
NYUv2 test AbsRel ↓ 0.10712 0.10714
NYUv2 test Ξ΄1 ↑ 0.88207 0.88216
DIODE val AbsRel ↓, indoor / outdoor 0.10999 / 0.42684 0.11039 / 0.42477
DIODE val Ξ΄1 ↑, indoor / outdoor 0.87414 / 0.64284 0.87522 / 0.64149
Latency, RTX 3070 Ti (ONNX Runtime, CUDA) 14.4 ms 11.7 ms (βˆ’18.8%)
Latency, CPU, Ryzen 5 5600X (ONNX Runtime) 252 ms 174 ms (βˆ’31.0%)
ONNX file size 104.7 MB 86.5 MB (βˆ’17.4%)

The parameter reduction is 23.5% from compression (17 verified edits) plus 4.6% from removing the camera decoder, which only serves the camera-pose outputs. Part of the latency gain comes from the simplified fixed-shape graph alone (12.6 ms GPU / 190 ms CPU without any edits). Latencies are medians at batch 1, with the models run alternately.

Depth maps of the original and this model on NYUv2 test images

Input image, depth from the original model, depth from this model, relative difference.

Important differences to the original

  • Fixed input shape: pixel_values is 1Γ—1Γ—3Γ—378Γ—504 (batch 1, one view, RGB, height 378, width 504). The original accepts dynamic sizes. Resize images so the longest side is 504 (area interpolation), round both sides to multiples of 14 (a 640Γ—480 image becomes 504Γ—378), scale to [0, 1] and normalize with ImageNet mean (0.485, 0.456, 0.406) and std (0.229, 0.224, 0.225).
  • Single output: predicted_depth (1Γ—1Γ—378Γ—504). The confidence, extrinsics and intrinsics outputs of the original were removed. Single-view use only.
  • Calibrated on indoor scenes, also tested outdoors. Calibration used the 795 labeled NYUv2 training images (without labels); evaluation used the 654 NYUv2 test images (prediction resized to 480Γ—640, Eigen crop, depth in (0.001, 10] m, median scale alignment). As an independent test set, the DIODE validation set (325 indoor and 446 outdoor scenes, same protocol without crop) shows the same accuracy as the original model, outdoors as well. The low outdoor numbers belong to the original model and the protocol (scale alignment in depth space); the Depth Anything papers align in disparity space and report higher numbers.

Usage

import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download

path = hf_hub_download("GavGuile/smolanything-depth-anything-3-small", "onnx/model.onnx")
hf_hub_download("GavGuile/smolanything-depth-anything-3-small", "onnx/model.onnx_data")
session = ort.InferenceSession(path, providers=["CUDAExecutionProvider", "CPUExecutionProvider"])

pixel_values = np.zeros((1, 1, 3, 378, 504), dtype=np.float32)  # preprocessed image, see above
depth = session.run(["predicted_depth"], {"pixel_values": pixel_values})[0][0, 0]  # (378, 504)

What was changed

Found and verified by SmolAnything (full report with evidence and reasoning: study report):

  • DPT depth head: the deepest projection/resize pair reduced from 384 to 32 hidden channels; DPT projections projects.2/projects.3 and layer3_rn replaced by low-rank factorizations; one fusion residual unit narrowed.
  • Late backbone blocks: MLP hidden width of block 11 reduced to 256 (of 1536), block 10 to 512, blocks 8-9 to 1024; attention qkv/output projections of blocks 10-11 low-rank.
  • Smaller cuts: MLPs of blocks 0, 6 and 7, block 0 qkv projection.
  • Each replacement's weights were fitted in closed form (ridge least squares) to reproduce the original layer outputs on calibration data, and accepted only if the whole model's output stayed within 1% (per edit) and 3% (combined) relative error. The final model deviates from the original by 0.56% (relative L2 of the depth map, held-out calibration images).

License and credits

Apache-2.0, like the original model. All credit for the model architecture and training goes to the Depth Anything 3 authors (ByteDance Seed); this repository only contains a post-training compressed version. The ONNX export is based on onnx-community/depth-anything-v3-small.

SmolAnything is an independent project and is not affiliated with Hugging Face or with the authors of Depth Anything.

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

Model tree for GavGuile/smolanything-depth-anything-3-small

Quantized
(2)
this model