MiDaS v3.1 (fastforks)
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.
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/isl-org/MiDaS at 4545977.
Task: depth. Tier: experimental. 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 |
|---|---|---|---|---|
midas-dpt-beit-large-512@1 |
dpt_beit_large_512.pt | 9e9e900747e9 |
MIT (assumed from code) | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Files: LICENSE.
Code licence: MIT; the authors do not state a separate weights licence.
Training data: 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).
Licence evidence: https://github.com/isl-org/MiDaS/blob/454597711a62eabcbf7d1e89f3fb9f569051ac9b/LICENSE (weights are release assets of the same repository)
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-512 3000x4000 (1.8 GiB peak allocated, 1.9 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 |
|---|---|---|---|---|---|---|---|---|---|
midas-dpt-beit-large-512 |
385.6 | 333.2 | 78.79 | 63.89 | 5.2x | 1.2x | 2759 / 2898 | 992 / 1418 | 1003 / 1436 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
midas-dpt-beit-large-512 |
5.16 | 2.49 | 0.28โ | 1.14 | 0.09 | 0.07 |
Fixed-size speed and peak memory, all models
| model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
|---|---|---|---|---|---|
midas-dpt-beit-large-512 |
portable | 79.3 ms / 1729 / 1880 | 141.1 ms / 1870 / 2052 | 141.2 ms / 1883 / 2080 | 81.6 ms / 1863 / 1990 |
midas-dpt-beit-large-512 |
kernels | 52.1 ms / 922 / 1048 | 96.0 ms / 1012 / 1220 | 96.0 ms / 1025 / 1280 | 53.1 ms / 1077 / 1178 |
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 |
|---|---|---|---|---|---|
midas-dpt-beit-large-512 |
NYUv2 test, AbsRel / delta1 | 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.9726 | 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.0908 / 0.8972 | 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 | 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.02 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("midas-dpt-beit-large-512") # 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: midas-dpt-beit-large-512.
Kernels backend
depth.load("midas-dpt-beit-large-512", mode="kernels") runs our CUDA kernels (cudnn_hacc). 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.