Metric3D v2
Metric3D v2 (Wei Yin and Mu Hu et al.): metric depth and surface normals from one image, given the focal length. Commercially usable; the authors ask commercial users to contact them.
stable Fork of YvanYin/Metric3D@eb5b6fa · backends: portable, kernels
- Paper Metric3Dv2: A Versatile Monocular Geometric Foundation Model for Zero-shot Metric Depth and Surface Normal Estimation TPAMI 2024 · first released 22 Mar 2024
Checkpoint metric3d-vit-large
Paper 2024 Added in 0.1.0 Evaluated with 0.2.0
Use it
pip install fastforks Lean install with only what this model needs: pip install fastforks-core
from fastforks import depth
model = depth.load("metric3d-vit-large") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.depth # also: normals, confidence
result.backend # what ran: mode, device, dtype, kernels fastforks bench metric3d-vit-large Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.
Speed and memory
Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 629 | 0.70× | 3,077 MiB/3,122 MiB | 3.9 | 0.73 |
| Original fp16torch.autocast(fp16) around the forward | fp16 | 439 | – | 3,275 MiB/3,350 MiB | 10.0 | 0.88 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 201 | 2.2× | 1,443 MiB/1,576 MiB | 2.4 | 0.20 |
| Kernels | fp16 | 155 | 2.8× | 1,475 MiB/1,588 MiB | 0.7 | 0.16 |
| Portable + torch.compile | 149 | 3.0× | 1,126 MiB/1,148 MiB | 55 (build) | – | |
| TensorRT fp16 | fp16 | 91.4 | 4.8× | 1,010 MiBenginenot comparable | 97 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-01 to 2026-11-16. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two
times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.
Other devices
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14 | Original | fp32 | 1946 | 4,973 MiB process | matches | 994x1482 |
| Portable | fp16 | 1861 | 3,636 MiB process | matches | 994x1482 | |
| Portable | fp32 | 1822 | 4,523 MiB process | matches | 994x1482 | |
| Kernels | fp16 | not implemented | – | 994x1482 | ||
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 218 | 1,424 MiB/1,576 MiB | – | 994x1482 |
| Kernels | fp16 | 193 | 1,455 MiB/1,528 MiB | – | 994x1482 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 63.8 | 1,424 MiB/1,576 MiB | – | 994x1482 |
| Kernels | fp16 | 56.9 | 1,455 MiB/1,528 MiB | – | 994x1482 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 175 | 1,424 MiB/1,576 MiB | – | 994x1482 |
| Kernels | fp16 | 166 | 1,455 MiB/1,528 MiB | – | 994x1482 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 68.5 | 1,424 MiB/1,576 MiB | – | 994x1482 |
| Kernels | fp16 | 61.5 | 1,455 MiB/1,528 MiB | – | 994x1482 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 41.3 | 1,447 MiB/1,598 MiB | – | 994x1482 |
| Kernels | fp16 | 38.9 | 1,479 MiB/1,628 MiB | – | 994x1482 | |
CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.
Licence and weights
Commercial use allowed
- Code
- BSD-2-Clause LICENSE
- Weights
- BSD-2-Clause (assumed from code)(not stated by the authors; assumed to follow the code) source
- Training data
- 16M images from 18 public metric-depth datasets (indoor, outdoor, driving) per the Metric3D v2 paper (arXiv 2404.15506); original asks commercial users to contact the authors
- weights licence not stated by the original authors; assumed to be the code licence
- The upstream README says 'for further commercial inquiries, please contact' the authors; no weights licence is stated, so the BSD-2-Clause code licence is assumed.
Our reading of the licences, not legal advice.
Weights
metric_depth_vit_large_800k.pth 1.6 GB· hosted on Hugging Facefastforks downloads and checks these files on first use (fastforks download metric3d-vit-large).
Accuracy
The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.
NYUv2 test
AbsRel / delta1
| Run | dtype | AbsRel ↓ | δ1 ↑ | Δ AbsRel vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 0.0547 | 0.9673 | reference | 654 | 633 |
| Original fp16 | fp16 | 0.0547 | 0.9673 | ±0.0000 | 654 | 440 |
| Portable fp32 | fp32 | 0.0547 | 0.9673 | ±0.0000 | 654 | 553 |
| Portable | fp16 | 0.0547 | 0.9673 | ±0.0000 | 654 | 200 |
| Kernels | fp16 | 0.0546 | 0.9673 | +0.0001 | 654 | 158 |
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. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6d3bab64, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
iBims-1
AbsRel / delta1
| Run | dtype | AbsRel ↓ | δ1 ↑ | Δ AbsRel vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 0.0334 | 0.9855 | reference | 100 | 628 |
| Original fp16 | fp16 | 0.0334 | 0.9855 | ±0.0000 | 100 | 440 |
| Portable fp32 | fp32 | 0.0334 | 0.9855 | ±0.0000 | 100 | 554 |
| Portable | fp16 | 0.0334 | 0.9855 | ±0.0000 | 100 | 200 |
| Kernels | fp16 | 0.0334 | 0.9855 | ±0.0000 | 100 | 158 |
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. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6d3bab64, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
ETH3D two-view train left
AbsRel / delta1training data not stated: possibly seen
| Run | dtype | AbsRel ↓ | δ1 ↑ | Δ AbsRel vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 0.0740 | 0.9411 | reference | 27 | 628 |
| Original fp16 | fp16 | 0.0740 | 0.9411 | ±0.0000 | 27 | 440 |
| Portable fp32 | not measured | |||||
| Portable | fp16 | 0.0740 | 0.9411 | ±0.0000 | 27 | 200 |
| Kernels | fp16 | 0.0741 | 0.9410 | −0.0001 | 27 | 158 |
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. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
Middlebury 2014 trainingH left
AbsRel / delta1training data not stated: possibly seen
| Run | dtype | AbsRel ↓ | δ1 ↑ | Δ AbsRel vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 0.0247 | 0.9961 | reference | 15 | 641 |
| Original fp16 | fp16 | 0.0247 | 0.9961 | ±0.0000 | 15 | 449 |
| Portable fp32 | not measured | |||||
| Portable | fp16 | 0.0247 | 0.9961 | ±0.0000 | 15 | 200 |
| Kernels | fp16 | 0.0247 | 0.9961 | ±0.0000 | 15 | 158 |
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. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
NYUv2 test normals
mean / median angle deg, % < 11.25 / < 30 deg
| Run | dtype | ang_mean ↑ | ang_median ↑ | a11.25 ↑ | a30 ↑ | images | ms / image |
|---|---|---|---|---|---|---|---|
| Original fp32 | not measured | ||||||
| Original fp16 | not measured | ||||||
| Portable fp32 | fp32 | 13.72 | 7.27 | 65.43 | 87.44 | 654 | 554 |
| Portable | fp16 | 13.72 | 7.27 | 65.43 | 87.44 | 654 | 201 |
| Kernels | fp16 | 13.71 | 7.27 | 65.44 | 87.45 | 654 | 158 |
The original code was not run on this dataset, so the table cannot show the distance to it.
AbsRel / delta1 after a least-squares scale + shift fit (in disparity space for inverse-depth models), mean over images. Normals: angle to the ground-truth normal over the pixels with ground truth (Marigold's evaluation sets), mean over images. Measured on RTX 5060 Ti, torch 2.14.1+cu130, fastforks 4e890760, 2026-11-12.
iBims-1 normals
mean / median angle deg, % < 11.25 / < 30 deg
| Run | dtype | ang_mean ↑ | ang_median ↑ | a11.25 ↑ | a30 ↑ | images | ms / image |
|---|---|---|---|---|---|---|---|
| Original fp32 | not measured | ||||||
| Original fp16 | not measured | ||||||
| Portable fp32 | fp32 | 14.47 | 5.84 | 71.33 | 85.85 | 100 | 556 |
| Portable | fp16 | 14.47 | 5.84 | 71.33 | 85.85 | 100 | 200 |
| Kernels | fp16 | 14.47 | 5.84 | 71.33 | 85.85 | 100 | 158 |
The original code was not run on this dataset, so the table cannot show the distance to it.
AbsRel / delta1 after a least-squares scale + shift fit (in disparity space for inverse-depth models), mean over images. Measured on RTX 5060 Ti, torch 2.14.1+cu130, fastforks 4e890760, 2026-11-12.
Closeness to the original
Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1 % and p99 <= 3 % of the reference's median |value| (absolute error of the output depth).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.002 (relative) | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.01 (relative) | 0.00139 (relative) |
| GPU default dtypes, p99 |diff| | ≤ 0.03 (relative) | 0.00198 (relative) |
Recorded for metric3d-vit-large on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-12, with these kernels: dpt_fusedfastbb
Details
Metric3D v2 (Hu et al. 2024): metric depth and surface normals from one image; a DINOv2-reg ViT-L encoder and a RAFT-style iterative depth / normal decoder in a canonical camera space (focal 1000 px), rescaled by the given focal length.
- Input / output
- Input: one RGB image. Output: a depth or inverse-depth map.
What the numbers mean, and which models need the camera focal length
kind(a card field,result.kind) says what the numbers mean:metric= metres;scale_invariant,affine_invariant,affine_invariant_log(log depth) andaffine_invariant_inverseare relative (unknown scale or shift, not metres). Metric models that use the focal length takemodel(image, intrinsics=K)(K[3, 3], pixels of the input):metric3d-vit-largeandda3metric-largeneed it for correct metres (da3metric-large: metres = output x focal / 300; withoutintrinsics=a 300 px focal length is assumed, wrong for a real camera).unidepth-v2-vitl14,unik3d-vitl,depth-proand MoGe estimate the camera themselves (givenintrinsics=replacefx);zoedepth-nkand the relative models (da3mono-largetoo) take none. Normals-only models (kindnone) returnresult.normals[B, H, W, 3](unit vectors, camera frame: x right, y down, z forward). - Input size
- any H x W >= 8, resized or padded inside the model; tested up to 3000x4000 (2,401 MiB allocated)
- Outputs
depth,normals,confidence- CUDA kernels
fastbbfast backbone kernels: flash attention, window attention, instance norm and rotary embeddings for ViT and similar backbonesdpt_fusedfused fp16 matrix multiplies and convolutions for DINOv2 backbones and DPT depth heads
- Apple (MPS)
- fp32, fp16
Limitations
- metric3d-vit-large: the kernels runner prepares its buffers at load, so the model right after load holds more than portable; the run peak is within 2 % of portable's.
Full reference, generated from the repository
Metric3D v2 (Wei Yin and Mu Hu et al.): metric depth and surface normals from one image, given the focal length. Commercially usable; the authors ask commercial users to contact them.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
metric3d-vit-large | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 629 438 201 155 149 91.4 | 3077 / 3122 3275 / 3350 1443 / 1576 1475 / 1588 1126 / 1148 1867 / 1952 |
Details
- Original code: https://github.com/YvanYin/Metric3D at
eb5b6fa - Code licence: BSD-2-Clause (permissive); files:
LICENSE - Weights licence: BSD-2-Clause (assumed from code)
- Licence evidence: https://github.com/YvanYin/Metric3D/blob/eb5b6fac0dc155e4e52f576e304fbf11655ff339/README.md#license-and-contact
- Training data: 16M images from 18 public metric-depth datasets (indoor, outdoor, driving) per the Metric3D v2 paper (arXiv 2404.15506); original asks commercial users to contact the authors
- Licence note: The upstream README says 'for further commercial inquiries, please contact' the authors; no weights licence is stated, so the BSD-2-Clause code licence is assumed.
- Kernel libraries:
fastbb,dpt_fused - Variants:
metric3d-vit-large - Outputs: depth, normals, confidence; kind:
metric - Input size: any H x W >= 8, resized or padded inside the model
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
metric3d-vit-large3000x4000 (2.3 GiB peak allocated, 2.9 reserved) metric3d-vit-large994x1482, first call: portable + torch.compile 55 s (cold Inductor cache), TensorRT fp16 97 s (ONNX + engine).metric3d-vit-largeoriginal 994x1482: torch.autocast(fp16) around the forwardmetric3d-vit-largeload / first call: original 9.96 s / 0.876 s, portable 2.39 s / 0.423 s (518x770), kernels 0.71 s / 0.504 s (518x770)- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5
Measured
AbsRel / delta1 after a least-squares scale + shift fit (in disparity space for inverse-depth models), mean over images. Normals: angle to the ground-truth normal over the pixels with ground truth (Marigold's evaluation sets), mean over images. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
metric3d-vit-large | NYUv2 test, AbsRel / delta1 | 0.0547 / 0.9673 | 0.0547 / 0.9673 | 0.0547 / 0.9673 | 0.0547 / 0.9673 | 0.0546 / 0.9673 | |
metric3d-vit-large | iBims-1, AbsRel / delta1 | 0.0334 / 0.9855 | 0.0334 / 0.9855 | 0.0334 / 0.9855 | 0.0334 / 0.9855 | 0.0334 / 0.9855 | |
metric3d-vit-large | ETH3D two-view train left, AbsRel / delta1 | 0.0740 / 0.9411 | 0.0740 / 0.9411 | 0.0740 / 0.9411 | 0.0741 / 0.9410 | possibly in the training data | |
metric3d-vit-large | Middlebury 2014 trainingH left, AbsRel / delta1 | 0.0247 / 0.9961 | 0.0247 / 0.9961 | 0.0247 / 0.9961 | 0.0247 / 0.9961 | possibly in the training data | |
metric3d-vit-large | NYUv2 test normals, mean / median angle deg, % < 11.25 / < 30 deg | 13.72 / 7.27 / 65.43 / 87.44 | 13.72 / 7.27 / 65.43 / 87.44 | 13.71 / 7.27 / 65.44 / 87.45 | |||
metric3d-vit-large | iBims-1 normals, mean / median angle deg, % < 11.25 / < 30 deg | 14.47 / 5.84 / 71.33 / 85.85 | 14.47 / 5.84 / 71.33 / 85.85 | 14.47 / 5.84 / 71.33 / 85.85 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 4e890760 / 939adfe8, 2026-11-06 to 2026-11-12; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 4e890760 / 6d3bab64, 2026-11-12 to 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 4e890760 / 939adfe8, 2026-11-06 to 2026-11-12.
Parity
CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1 % and p99 <= 3 % of the reference's median |value| (absolute error of the output depth).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
metric3d-vit-large | 0.00139 / 0.00198 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120 |
Limitations
- metric3d-vit-large: the kernels runner prepares its buffers at load, so the model right after load holds more than portable; the run peak is within 2 % of portable's.
Example output
One fixed input through this checkpoint, the same for every model of the task (kernels · float16 · NVIDIA GeForce RTX 5060 Ti).
Input: A cup of coffee, Rachel Michetti (CC0).