Depth Anything V2
Depth Anything V2: relative depth from one image, in small, base and large. The licence differs by size, see the table.
Commercial use: depth-anything-v2-s: yes; depth-anything-v2-b, depth-anything-v2-l: no (weights: CC-BY-NC-4.0).
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
depth-anything-v2-s | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 53.6 41.0 7.82 4.51 6.65 4.46 | 407 / 478 373 / 418 249 / 326 190 / 248 201 / 224 186 (engine) |
depth-anything-v2-b | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels | 93.6 63.2 18.8 10.5 | 858 / 940 928 / 1026 450 / 516 387 / 436 |
depth-anything-v2-l | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels | 245 140 55.1 31.1 | 2109 / 2326 2560 / 2654 1026 / 1352 921 / 1034 |
Details
- Original code: https://github.com/DepthAnything/Depth-Anything-V2 at
a561b84 - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0
depth-anything-v2-b: CC-BY-NC-4.0depth-anything-v2-l: CC-BY-NC-4.0
- Licence evidence: https://github.com/DepthAnything/Depth-Anything-V2/blob/main/README.md (LICENSE section) and the Hugging Face model cards
- Training data: Teacher (ViT-G) on 595K synthetic images (BlendedMVS, Hypersim, IRS, TartanAir, VKITTI 2); students on 62M pseudo-labelled real images (SA-1B, Open Images, BDD100K, Google Landmarks, ImageNet-21K, LSUN, Objects365, Places365) per the paper
- Licence note: Only the Small weights are Apache-2.0; the Base and Large weights are CC-BY-NC-4.0. The training data of even the Small model has unclear commercial terms (a note only).
- Options:
short_side= 518 (>= 14; alsoinput_size) - Kernel libraries:
fastbb,dpt_fused - Variants:
depth-anything-v2-s,depth-anything-v2-b,depth-anything-v2-l - Outputs: inverse_depth; kind:
affine_invariant_inverse - Input size: any H x W >= 8, resized or padded inside the model (ViT patch 14)
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
depth-anything-v2-s3000x4000 (0.5 GiB peak allocated, 0.5 reserved);depth-anything-v2-b3000x4000 (0.8 GiB peak allocated, 0.9 reserved);depth-anything-v2-l3000x4000 (1.8 GiB peak allocated, 2.2 reserved) depth-anything-v2-s994x1482, first call: portable + torch.compile 16 s (cold Inductor cache), TensorRT fp16 30 s (ONNX + engine).depth-anything-v2-soriginal 994x1482: torch.autocast(fp16) around the forwarddepth-anything-v2-boriginal 994x1482: torch.autocast(fp16) around the forwarddepth-anything-v2-loriginal 994x1482: torch.autocast(fp16) around the forwarddepth-anything-v2-sload / first call: original 0.71 s / 0.38 s, portable 0.11 s / 0.027 s, kernels 0.08† s / 0.009 sdepth-anything-v2-bload / first call: original 3.94 s / 0.08 s, portable 0.85 s / 0.019 s, kernels 0.2† s / 0.012 sdepth-anything-v2-lload / first call: original 5.66 s / 0.149 s, portable 2.39 s / 0.081 s, kernels 0.91† s / 0.055 s- † measured in the speed sweep after the portable load (or an earlier size) in the same process: file cache and kernels are warm, so the time is lower than a fresh start.
- Protocol, median of 5 after 3 warm-up, uint8 CUDA input (synthetic for bench_inputs sizes), card defaults; gc before each load; peak = max over the first call and the timed calls
Measured
AbsRel / delta1 after a least-squares scale + shift fit (in disparity space for inverse-depth models), mean over images. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|---|---|---|---|---|---|---|
depth-anything-v2-s | NYUv2 test, AbsRel / delta1 | 0.0509 / 0.9780 | 0.0509 / 0.9780 | 0.0509 / 0.9780 | 0.0509 / 0.9780 | |
depth-anything-v2-s | iBims-1, AbsRel / delta1 | 0.0448 / 0.9744 | 0.0448 / 0.9744 | 0.0448 / 0.9744 | 0.0448 / 0.9744 | |
depth-anything-v2-s | ETH3D two-view train left, AbsRel / delta1 | 0.0803 / 0.9256 | 0.0803 / 0.9256 | 0.0803 / 0.9256 | 0.0803 / 0.9256 | possibly in the training data |
depth-anything-v2-s | Middlebury 2014 trainingH left, AbsRel / delta1 | 0.0346 / 0.9947 | 0.0346 / 0.9947 | 0.0346 / 0.9947 | 0.0346 / 0.9947 | possibly in the training data |
depth-anything-v2-b | NYUv2 test, AbsRel / delta1 | 0.0462 / 0.9806 | 0.0462 / 0.9806 | 0.0462 / 0.9806 | 0.0462 / 0.9806 | |
depth-anything-v2-b | iBims-1, AbsRel / delta1 | 0.0378 / 0.9834 | 0.0378 / 0.9834 | 0.0378 / 0.9834 | 0.0378 / 0.9834 | |
depth-anything-v2-b | ETH3D two-view train left, AbsRel / delta1 | 0.0696 / 0.9369 | 0.0698 / 0.9361 | 0.0696 / 0.9369 | 0.0696 / 0.9372 | possibly in the training data |
depth-anything-v2-b | Middlebury 2014 trainingH left, AbsRel / delta1 | 0.0318 / 0.9958 | 0.0319 / 0.9957 | 0.0318 / 0.9958 | 0.0318 / 0.9958 | possibly in the training data |
depth-anything-v2-l | NYUv2 test, AbsRel / delta1 | 0.0439 / 0.9814 | 0.0439 / 0.9814 | 0.0439 / 0.9814 | 0.0439 / 0.9814 | |
depth-anything-v2-l | iBims-1, AbsRel / delta1 | 0.0347 / 0.9851 | 0.0347 / 0.9851 | 0.0347 / 0.9851 | 0.0347 / 0.9851 | |
depth-anything-v2-l | ETH3D two-view train left, AbsRel / delta1 | 0.0627 / 0.9513 | 0.0627 / 0.9513 | 0.0627 / 0.9512 | 0.0627 / 0.9513 | possibly in the training data |
depth-anything-v2-l | Middlebury 2014 trainingH left, AbsRel / delta1 | 0.0296 / 0.9961 | 0.0296 / 0.9961 | 0.0296 / 0.9961 | 0.0296 / 0.9961 | possibly in the training data |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 468fba10 / 939adfe8, 2026-11-06.
Parity
CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.5 % and p99 <= 2 % of the reference's median |value| (absolute error of the output inverse_depth).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
depth-anything-v2-s | 0.00038 / 0.00124 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120 |
depth-anything-v2-b | 0.00072 / 0.00264 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120 |
depth-anything-v2-l | 0.00077 / 0.0024 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120 |