Depth Anything V2 (fastforks)
Depth Anything V2 (Yang et al. 2024): relative monocular depth from a DINOv2 ViT encoder and a DPT head, trained on synthetic labels and 62M pseudo-labelled real images.
This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/DepthAnything/Depth-Anything-V2 at a561b84.
Author weight repos: https://huggingface.co/depth-anything/Depth-Anything-V2-Base, https://huggingface.co/depth-anything/Depth-Anything-V2-Large, https://huggingface.co/depth-anything/Depth-Anything-V2-Small.
Task: depth. Tier: stable. Outputs: inverse_depth. Backends: portable, kernels.
Input: one RGB image. Output: a depth or inverse-depth map (metric for the models marked metric).
Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
depth-anything-v2-b@1 |
depth_anything_v2_vitb.pth | 0d2b7002e62d |
CC-BY-NC-4.0 | no |
depth-anything-v2-l@1 |
depth_anything_v2_vitl.pth | a7ea19fa0ed9 |
CC-BY-NC-4.0 | no |
depth-anything-v2-s@1 |
depth_anything_v2_vits.pth | 715fade13be8 |
Apache-2.0 | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: LICENSE.
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).
Licence evidence: https://github.com/DepthAnything/Depth-Anything-V2/blob/main/README.md (LICENSE section) and the Hugging Face model cards
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-b 3000x4000 (0.8 GiB peak allocated, 0.9 reserved); depth-anything-v2-l 3000x4000 (1.8 GiB peak allocated, 2.2 reserved); depth-anything-v2-s 3000x4000 (0.5 GiB peak allocated, 0.5 reserved)
Speed and memory
Depth, Middlebury 2014 half, 994x1482
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|---|
depth-anything-v2-b |
93.6 | 63.2 | 18.84 | 10.51 | 6.0x | 1.8x | 928 / 1026 | 450 / 516 | 387 / 436 |
depth-anything-v2-l |
245.4 | 140.2 | 55.07 | 31.12 | 4.5x | 1.8x | 2560 / 2654 | 1026 / 1352 | 921 / 1034 |
depth-anything-v2-s |
53.6 | 41.0 | 7.82 | 4.51 | 9.1x | 1.7x | 373 / 418 | 249 / 326 | 190 / 248 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
depth-anything-v2-b |
3.94 | 0.85 | 0.20โ | 0.08 | 0.02 | 0.01 |
depth-anything-v2-l |
5.66 | 2.39 | 0.91โ | 0.15 | 0.08 | 0.06 |
depth-anything-v2-s |
0.71 | 0.11 | 0.08โ | 0.38 | 0.03 | 0.01 |
Fixed-size speed and peak memory, all models
| model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
|---|---|---|---|---|---|
depth-anything-v2-b |
portable | 18.8 ms / 643 / 776 | 26.2 ms / 733 / 876 | 26.3 ms / 745 / 908 | 20.0 ms / 787 / 924 |
depth-anything-v2-b |
kernels | 9.5 ms / 325 / 408 | 13.6 ms / 376 / 466 | 13.7 ms / 390 / 486 | 10.7 ms / 606 / 622 |
depth-anything-v2-l |
portable | 55.9 ms / 1752 / 1946 | 78.6 ms / 1915 / 2170 | 78.8 ms / 1928 / 2180 | 57.1 ms / 1885 / 2216 |
depth-anything-v2-l |
kernels | 28.3 ms / 875 / 1000 | 38.7 ms / 965 / 1104 | 38.8 ms / 977 / 1112 | 29.3 ms / 1058 / 1174 |
depth-anything-v2-s |
portable | 8.1 ms / 262 / 326 | 10.9 ms / 314 / 376 | 11.0 ms / 329 / 422 | 9.5 ms / 509 / 536 |
depth-anything-v2-s |
kernels | 4.0 ms / 129 / 166 | 5.7 ms / 164 / 218 | 5.8 ms / 177 / 214 | 5.1 ms / 462 / 480 |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Resizes to its working resolution: time depends on the aspect ratio, not the input pixels.
Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the authors' code at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
Accuracy
On public datasets
AbsRel / delta1 after a least-squares scale + shift fit (in disparity space for inverse-depth models), mean over images. Original = the authors' code, same checkpoint and protocol.
| variant | dataset | original | portable | kernels | note |
|---|---|---|---|---|---|
depth-anything-v2-s |
NYUv2 test, AbsRel / delta1 | 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 | |
depth-anything-v2-s |
ETH3D two-view train left, AbsRel / delta1 | 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 | possibly in the training data |
depth-anything-v2-b |
NYUv2 test, AbsRel / delta1 | 0.0462 / 0.9806 | 0.0462 / 0.9806 | ||
depth-anything-v2-b |
iBims-1, AbsRel / delta1 | 0.0378 / 0.9834 | 0.0378 / 0.9834 | ||
depth-anything-v2-b |
ETH3D two-view train left, AbsRel / delta1 | 0.0696 / 0.9367 | 0.0696 / 0.9372 | possibly in the training data | |
depth-anything-v2-b |
Middlebury 2014 trainingH left, AbsRel / delta1 | 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 | |
depth-anything-v2-l |
iBims-1, AbsRel / delta1 | 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.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 | possibly in the training data |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-10-27.
Parity with the original code
Every variant is checked against golden outputs of the original code at its pinned commit. 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|.
Usage
from fastforks import depth
model = depth.load("depth-anything-v2-b") # portable PyTorch on the GPU if there is one, else the CPU
result = model("room.jpg")
result.inverse_depth # [H, W] float32 tensor; result.kind says what the maps mean
# models that take a camera: model("room.jpg", intrinsics=K), K [3, 3] in pixels
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: depth-anything-v2-b, depth-anything-v2-l, depth-anything-v2-s.
Kernels backend
depth.load("depth-anything-v2-b", mode="kernels") runs our CUDA kernels (fastbb, dpt_fused). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.