Depth Anything V2 Tiny

A 16.5M-parameter, 8-layer community variant of Depth Anything V2 Small.

Depth Anything V2 Tiny is a structured-pruned and distilled version of Depth Anything V2 Small. It keeps the same DINOv2 ViT-S/14 backbone family and DPT-style decoder, but reduces the backbone from 12 to 8 transformer layers and the expensive reassemble branch from 384 to 192 channels. The result is 16,504,129 parameters (33.4% fewer than Small) and a 66.04 MB fp32 safetensors checkpoint, while retaining 85%+ δ1 on the NYUv2 Eigen test set at five deployment resolutions.

This is a community model. It is not an official Depth Anything release, and "Tiny" is not an official size in the Depth Anything V2 family.

Model at a glance

Property Value
Base model Depth Anything V2 Small
Parameters 16,504,129
Backbone DINOv2 ViT-S/14, 8 layers, 6 heads, hidden 384, patch 14
Decoder DPT-style neck; reassemble [48, 96, 192, 192]; fusion 64; head 32
Input RGB, float32, NCHW; H and W divisible by 14
Default processor size 336×448 for 4:3 images
Tested resolutions 224×294, 252×336, 336×448, 448×602, 518×686
Output relative inverse depth (affine-invariant; higher = closer)
FP32 safetensors 66.04 MB
License Apache-2.0
Status community variant; float32 only in this repository

Highlights

  • 33.4% fewer parameters and 33.3% smaller fp32 checkpoint than Small.
  • 85%+ δ1 at all five tested resolutions on NYUv2 Eigen 654.
  • Best at 336×448: 89.36% δ1; native 518×686: 88.73% δ1.
  • Native-resolution δ1 retention is 97.4% of Small under the same harness.
  • Standard DepthAnythingForDepthEstimation; no custom ops. It loads with AutoModelForDepthEstimation and the saved processor.
  • Deterministic in eval mode; no dropout or stochastic depth.
  • A 4-bit ONNX deployment variant is available at Petrouil/Depth-Anything-V2-Tiny-hf-quant.

How it compares

Model Params FP32 size Layers Reassemble NYU δ1 @ 518×686 NYU δ1 @ 336×448
Depth Anything V2 Small 24,785,089 99.06 MB 12 384 0.9111* —
Depth Anything V2 Tiny (this model) 16,504,129 66.04 MB 8 192 0.8873 0.8936

* Measured with the evaluation harness described below. The official Depth Anything V2 paper reports δ1 0.973 for Small using a different protocol and alignment; the numbers are not directly comparable across papers. The table is a same-harness size/quality comparison, not a claim of parity.

At native resolution, Tiny is about 2.4 δ1 points lower than Small. It is intended for size-constrained deployments where ~89% δ1 is acceptable, not as a drop-in replacement for accuracy-critical applications. For higher accuracy, use the original Small model.

Architecture

The model is the standard DepthAnythingForDepthEstimation architecture with a smaller backbone and decoder:

  • DINOv2 ViT-S/14 backbone: 8 transformer layers, 6 attention heads, hidden size 384, patch size 14.
  • Multi-scale taps at stages 2, 5, 7, 8 (1-based positions in the 8-layer stack).
  • FFN width 1536 (not width-pruned); attention heads 6 (not head-pruned).
  • Reassemble channels [48, 96, 192, 192]; the factor-0.5 branch uses 192 channels instead of 384.
  • Fusion hidden size 64; depth head hidden size 32.
  • Relative-depth output, no metric-scale head.

The 8 layers are the first eight DINOv2 layers. Removing the deepest four layers removes most of the backbone parameters while preserving the early and mid-level features that the DPT decoder uses. The decoder was slimmed where it was most expensive: the 384-channel, stride-2 3×3 convolution in the factor-0.5 reassemble branch.

How it was made

Tiny was not trained from scratch. It was obtained by progressively pruning Small and then healing each step with the original Small as a teacher.

  1. Structured pruning. Starting from the official Small checkpoint, the backbone was reduced from 12 to 8 layers, the decoder reassemble branch was reduced from 384 to 192 channels, and the multi-scale taps were re-selected to [2, 5, 7, 8]. Attention heads and FFN width were kept at 6 and 1536.
  2. Distillation and healing. The original fp32 Small was used as the teacher. Inverse-depth targets were cached at 448×448, then the student was fine-tuned with a scale-and-shift-invariant L1 loss plus a gradient L1 term. The schedule used a decoder-only warm-up followed by a low-learning- rate full fine-tune at 448×448.
  3. Evaluation at deployment resolutions. The 8-layer fine-tune used 448×448 crops and did not receive a dedicated multi-scale fine-tune. It was evaluated at five resolutions, and 336×448 is the best measured point.

Training data

Split Images Sources
Healing / training 10,295 COCO 2017 val 4,700; ADE20K train 5,000; NYUv2 train 595
Validation 700 COCO 2017 val 300; ADE20K val 200; NYUv2 train 200
Test 654 NYUv2 Eigen test

The NYUv2 test images were held out. COCO and ADE20K depth targets are teacher pseudo-labels from the original Small model; no human depth labels were used for those images. Training used a single NVIDIA RTX 1000 Ada Laptop GPU (6 GB), with PyTorch 2.11.0+cu128 and transformers 5.22.1.

Evaluation

Dataset: NYUv2 Eigen test split, 654 images. Ground truth from nyu_depth_v2_labeled.mat.

Protocol: the model's raw output is inverse depth. It is compared with 1 / GT_depth in inverse-depth space, with a per-image least-squares scale and shift alignment. RGB and GT are resized exactly to each target resolution. No test-time augmentation is used.

Resolution δ1 ↑ AbsRel ↓ RMSE ↓ log10 ↓ SILog ↓
224×294 0.8643 0.1248 0.0853 0.0511 6.837
252×336 0.8833 0.1135 0.0802 0.0468 6.273
336×448 0.8936 0.1076 0.0770 0.0444 6.019
448×602 0.8846 0.1139 0.0797 0.0464 6.443
518×686 0.8882 0.1115 0.0778 0.0455 6.312

All five resolutions pass the 85% δ1 gate. The strongest point is 336×448; the weakest is 224×294 at 86.43%. The processor-native 518×686 run (aspect- preserving preprocessing rather than exact resize) scores δ1 0.8873. The full metrics are in metrics_nyu654.json and metrics_native_518.json.

Teacher fidelity. On 200 held-out images at 336×448, against the original fp32 Small teacher: δ1 0.8976, AbsRel 0.1156, RMSE 0.3564, Pearson 0.8993, gradient correlation 0.6957. At the processor-native 518×686 size: δ1 0.8820, AbsRel 0.1407, RMSE 0.4235, Pearson 0.9085, gradient correlation 0.7026.

Usage

import torch
import torch.nn.functional as F
from PIL import Image
from transformers import AutoImageProcessor, AutoModelForDepthEstimation

repo_id = "Petrouil/Depth-Anything-V2-Tiny-hf"  # or a local directory

processor = AutoImageProcessor.from_pretrained(repo_id)
model = AutoModelForDepthEstimation.from_pretrained(repo_id)
model.eval()

image = Image.open("example.jpg").convert("RGB")

# The saved processor defaults to 336x448; pass `size` explicitly if needed.
inputs = processor(
    images=image,
    return_tensors="pt",
    size={"height": 336, "width": 448},
)

with torch.no_grad():
    predicted_depth = model(**inputs).predicted_depth

# Resize the relative-depth map back to the input image for visualization.
depth = F.interpolate(
    predicted_depth.unsqueeze(1),
    size=image.size[::-1],
    mode="bicubic",
    align_corners=False,
).squeeze(1)

# The raw output is inverse depth. Normalize only for visualization.
d = depth[0].cpu()
d = (d - d.min()) / (d.max() - d.min() + 1e-8)

Input contract

  • RGB image, float32, NCHW.
  • Height and width must be divisible by 14.
  • Recommended sizes: 224×294, 252×336, 336×448, 448×602, 518×686.
  • The saved processor preserves aspect ratio (keep_aspect_ratio=true) and uses ensure_multiple_of=14. For a 4:3 image, the default and an explicit size={"height": 336, "width": 448} both produce 336×448.
  • ImageNet normalization: mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225].

Output contract

  • predicted_depth: raw relative inverse depth; higher means closer.
  • The output is affine-invariant. For metric depth, fit a per-image scale and shift against ground-truth inverse depth; do not invert the raw output before that alignment.
  • For visualization, normalize the inverse-depth map; for metric evaluation, use the scale/shift alignment described above.

Checkpoint health

Check Result
Parameters 16,504,129
Dtype float32
Non-finite tensors 0
Training mode eval(); 0 parameters require grad
Repeated forward max abs diff 0.0
Fresh clean load vs source max abs diff 0.0
Hugging Face reload vs clean model max abs diff 0.0
CPU vs CUDA fp32 max abs diff 0.00114
All five input sizes finite, correct output shape

Bias, risks, and limitations

  • Indoor evaluation only. The model is evaluated on NYUv2 indoor scenes. Outdoor, night, rain, snow, and industrial scenes were not evaluated.
  • Relative depth only. The output has an unknown affine scale and shift; it is not metric depth without calibration.
  • Thin structures and small objects. No dedicated edge/boundary benchmark was run. Hair, wires, chair legs, and small objects may be weaker than the base model.
  • No temporal evaluation. Flicker and temporal consistency on video were not measured.
  • 224×294 margin. The lowest measured δ1 is 86.43%, only 1.43 points above the 85% gate. If your deployment uses 224×294 and needs more margin, use the original Small model or a larger Tiny variant.
  • Training-data bias. COCO, ADE20K, and NYUv2 do not represent all environments, cameras, skin tones, or lighting conditions. No fairness analysis was performed.
  • Not safety-critical. Do not use for navigation, manipulation, medical, or safety-critical decisions without independent validation.
  • Community model. This is not an official Depth Anything release and is not affiliated with or endorsed by the original authors.

License and attribution

This model is a derivative of depth-anything/Depth-Anything-V2-Small-hf, which is released under the Apache License 2.0. This derivative is released under the same license. See LICENSE and NOTICE.

Original Depth Anything V2 authors: Lihe Yang, Bingyi Kang, Zilong Huang, Zhen Zhao, Xiaogang Xu, Jiashi Feng, and Hengshuang Zhao.

Pruning, healing, evaluation, and this model card: Petros Fanioudakis.

Citation

If you use this model, please cite the original Depth Anything V2 paper and link this repository:

@article{yang2024depthanythingv2,
  title={Depth Anything V2},
  author={Yang, Lihe and Kang, Bingyi and Huang, Zilong and Xu, Xiaogang and Feng, Jiashi and Zhao, Hengshuang},
  journal={arXiv preprint arXiv:2406.09414},
  year={2024}
}

Model card contact

Petros Fanioudakis — @Petrouil. For issues, open a discussion in the Hugging Face repository.

Framework versions

Component Version
Python 3.12
PyTorch 2.11.0+cu128
transformers 5.22.1
safetensors current transformers dependency
Pillow 13.0.0

The model uses standard DepthAnythingForDepthEstimation layers. A recent transformers release with Depth Anything V2 support (4.45+) should load it; the published checkpoint was verified with 5.22.1.

Quantized and converted variants

This repository contains the float32 model only. A 4-bit ONNX deployment variant is published separately:

Int8 QDQ and other conversions are experimental. See the quantized model card for measured results and portability caveats.

Acknowledgements

Thanks to the Depth Anything V2 authors for the original model and the Hugging Face team for the transformers implementation and hosting.

Downloads last month
-
Safetensors
Model size
16.5M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Petrouil/Depth-Anything-V2-Tiny-hf

Finetuned
(8)
this model
Quantizations
1 model

Paper for Petrouil/Depth-Anything-V2-Tiny-hf