MiDaS v3.1
MiDaS v3.1 from Intel ISL, with a BEiT-L encoder: relative depth from one image.
stable Fork of isl-org/MiDaS@4545977 · backends: portable, kernels
- Paper MiDaS v3.1 -- A Model Zoo for Robust Monocular Relative Depth Estimation arXiv · first released 26 Jul 2023
Checkpoint midas-dpt-beit-large-512
Paper 2023 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("midas-dpt-beit-large-512") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.inverse_depth
result.backend # what ran: mode, device, dtype, kernels fastforks bench midas-dpt-beit-large-512 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 | 386 | 0.86× | 3,616 MiB/3,778 MiB | 3.8 | 0.70 |
| Original fp16torch.autocast(fp16) around the forward | fp16 | 333 | – | 2,759 MiB/2,898 MiB | 5.2 | 1.14 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 78.8 | 4.2× | 992 MiB/1,418 MiB | 2.5 | 0.09 |
| Kernels | fp16 | 63.9 | 5.2× | 1,003 MiB/1,436 MiB | 0.3 | 0.07 |
| Portable + torch.compile | 58.8 | 5.7× | 1,088 MiB/1,116 MiB | 33 (build) | – | |
| TensorRT fp16 | fp16 | 52.2 | 6.4× | 800 MiBenginenot comparable | 54 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-01 to 2026-11-03. 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. 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-12 | Original | fp32 | 1107 | 4,976 MiB process | matches | 994x1482 |
| Portable | fp16 | 635 | 2,407 MiB process | matches | 994x1482 | |
| Portable | fp32 | 679 | 3,443 MiB process | matches | 994x1482 | |
| Kernels | fp16 | not implemented | – | 994x1482 | ||
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 91.7 | 932 MiB/1,058 MiB | – | 994x1482 |
| Kernels | fp16 | 91.5 | 944 MiB/1,056 MiB | – | 994x1482 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 27.8 | 932 MiB/1,058 MiB | – | 994x1482 |
| Kernels | fp16 | 26.8 | 944 MiB/1,016 MiB | – | 994x1482 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 73.1 | 932 MiB/1,058 MiB | – | 994x1482 |
| Kernels | fp16 | 74.1 | 942 MiB/1,036 MiB | – | 994x1482 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 28.5 | 932 MiB/1,058 MiB | – | 994x1482 |
| Kernels | fp16 | 28.5 | 944 MiB/1,036 MiB | – | 994x1482 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 17.8 | 955 MiB/1,078 MiB | – | 994x1482 |
| Kernels | fp16 | 17.8 | 970 MiB/1,076 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
- MIT LICENSE
- Weights
- MIT (assumed from code)(not stated by the authors; assumed to follow the code) source
- Training data
-
- KITTI stereo / optical flow 2012 / 2015 CC-BY-NC-SA-3.0, non-commercial
- NYU Depth V2 not stated
- MegaDepth (Internet photo collections with SfM / MVS depth) CC-BY-4.0
- TartanAir CC-BY-4.0
- weights licence not stated by the original authors; assumed to be the code licence
Our reading of the licences, not legal advice.
Weights
dpt_beit_large_512.pt 1.6 GB· hosted on GitHubfastforks downloads and checks these files on first use (fastforks download midas-dpt-beit-large-512).
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.0487 | 0.9789 | reference | 654 | 332 |
| Original fp16 | fp16 | 0.0487 | 0.9789 | ±0.0000 | 654 | 264 |
| Portable fp32 | fp32 | 0.0487 | 0.9789 | ±0.0000 | 654 | 185 |
| Portable | fp16 | 0.0487 | 0.9789 | ±0.0000 | 654 | 65.4 |
| Kernels | fp16 | 0.0487 | 0.9789 | ±0.0000 | 654 | 56.3 |
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.0477 | 0.9727 | reference | 100 | 311 |
| Original fp16 | fp16 | 0.0478 | 0.9727 | −0.0001 | 100 | 246 |
| Portable fp32 | fp32 | 0.0477 | 0.9727 | ±0.0000 | 100 | 166 |
| Portable | fp16 | 0.0477 | 0.9727 | ±0.0000 | 100 | 60.9 |
| Kernels | fp16 | 0.0478 | 0.9726 | −0.0001 | 100 | 51.9 |
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.0904 | 0.8978 | reference | 27 | 592 |
| Original fp16 | fp16 | 0.0906 | 0.8977 | −0.0002 | 27 | 520 |
| Portable fp32 | not measured | |||||
| Portable | fp16 | 0.0903 | 0.8979 | +0.0001 | 27 | 107 |
| Kernels | fp16 | 0.0906 | 0.8974 | −0.0002 | 27 | 95.5 |
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.0425 | 0.9906 | reference | 15 | 433 |
| Original fp16 | fp16 | 0.0424 | 0.9906 | +0.0001 | 15 | 388 |
| Portable fp32 | not measured | |||||
| Portable | fp16 | 0.0425 | 0.9906 | ±0.0000 | 15 | 71.9 |
| Kernels | fp16 | 0.0426 | 0.9907 | −0.0001 | 15 | 64.1 |
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.
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.02 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).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.02 (relative) | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.005 (relative) | 0.00213 (relative) |
| GPU default dtypes, p99 |diff| | ≤ 0.02 (relative) | 0.00388 (relative) |
Recorded for midas-dpt-beit-large-512 on RTX 5060 Ti, torch 2.14.1+cu130, 2026-10-29, with these kernels: cudnn_hacc
Details
MiDaS v3.1 (Birkl et al. 2023): relative monocular depth from a BEiT-L/16 encoder and a DPT decoder, trained on a mix of 12 depth datasets.
- 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 (1,863 MiB allocated)
- Options
input_size=512>= 32· changes the output
- Outputs
inverse_depth- CUDA kernels
cudnn_haccconvolutions with fp16 accumulation (cuDNN)
- Apple (MPS)
- fp32, fp16
Full reference, generated from the repository
MiDaS v3.1 from Intel ISL, with a BEiT-L encoder: relative depth from one image.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
midas-dpt-beit-large-512 | Middlebury 2014 half (994x1482) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 386 333 78.8 63.9 58.8 52.2 | 3616 / 3778 2759 / 2898 992 / 1418 1003 / 1436 1088 / 1116 1514 / 1592 |
Details
- Original code: https://github.com/isl-org/MiDaS at
4545977 - Code licence: MIT (permissive); files:
LICENSE - Weights licence: MIT (assumed from code)
- Licence evidence: https://github.com/isl-org/MiDaS/blob/454597711a62eabcbf7d1e89f3fb9f569051ac9b/LICENSE (weights are release assets of the same repository)
- Training data: KITTI stereo / optical flow 2012 / 2015, NYU Depth V2, MegaDepth (Internet photo collections with SfM / MVS depth), TartanAir, not stated by the authors (12 datasets (ReDWeb, DIML, Movies, MegaDepth, WSVD, TartanAir, HRWSI, ApolloScape, BlendedMVS, IRS, KITTI, NYU Depth V2) per the MiDaS v3.1 paper (arXiv 2307.14460))
- Options:
input_size= 512 (>= 32) - Kernel libraries:
cudnn_hacc - Variants:
midas-dpt-beit-large-512 - Outputs: inverse_depth; kind:
affine_invariant_inverse - Input size: any H x W >= 8, resized or padded inside the model
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
midas-dpt-beit-large-5123000x4000 (1.8 GiB peak allocated, 1.9 reserved) midas-dpt-beit-large-512994x1482, first call: portable + torch.compile 33 s (cold Inductor cache), TensorRT fp16 54 s (ONNX + engine).midas-dpt-beit-large-512original 994x1482: torch.autocast(fp16) around the forwardmidas-dpt-beit-large-512load / first call: original 5.16 s / 1.135 s, portable 2.49 s / 0.093 s, kernels 0.28† s / 0.067 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 | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
midas-dpt-beit-large-512 | NYUv2 test, AbsRel / delta1 | 0.0487 / 0.9789 | 0.0487 / 0.9789 | 0.0487 / 0.9789 | 0.0487 / 0.9789 | 0.0487 / 0.9789 | |
midas-dpt-beit-large-512 | iBims-1, AbsRel / delta1 | 0.0477 / 0.9727 | 0.0478 / 0.9727 | 0.0477 / 0.9727 | 0.0477 / 0.9727 | 0.0478 / 0.9726 | |
midas-dpt-beit-large-512 | ETH3D two-view train left, AbsRel / delta1 | 0.0904 / 0.8978 | 0.0906 / 0.8977 | 0.0903 / 0.8979 | 0.0906 / 0.8974 | possibly in the training data | |
midas-dpt-beit-large-512 | Middlebury 2014 trainingH left, AbsRel / delta1 | 0.0425 / 0.9906 | 0.0424 / 0.9906 | 0.0425 / 0.9906 | 0.0426 / 0.9907 | possibly in the training data |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6d3bab64, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
Parity
CPU, float32: max |diff| <= 0.02 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 |
|---|---|---|---|
midas-dpt-beit-large-512 | 0.00213 / 0.00388 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
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).