--- library_name: "fastforks" pipeline_tag: "depth-estimation" license: "other" license_name: "see-model-card" license_link: "https://github.com/isl-org/ZoeDepth/blob/d87f17b2f5fdcb174cf4fb115491f4a6c60de152/LICENSE" tags: - "depth" - "mono-depth" - "monocular-depth" - "cuda" - "pytorch" - "fastforks" - "fastforks-card" --- # ZoeDepth (fastforks) ZoeDepth (Bhat et al. 2023): metric monocular depth from a MiDaS v3.1 BEiT-L/16 core with metric-bins heads (NYU indoor, KITTI outdoor) chosen by a learned domain router (ZoeD_M12_NK). 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: . Kernels for the `kernels` backend: . Original code: at `d87f17b`. Task: depth. Tier: stable. Outputs: `depth`. Backends: `portable`, `kernels`. Input: one RGB image. Output: a depth or inverse-depth map. `kind` (a card field, `result.kind`) says what the numbers mean: `metric` = metres; `scale_invariant`, `affine_invariant`, `affine_invariant_log` (log depth) and `affine_invariant_inverse` are relative (unknown scale or shift, not metres). Metric models that use the focal length take `model(image, intrinsics=K)` (K `[3, 3]`, pixels of the input): `metric3d-vit-large` and `da3metric-large` need it for correct metres (`da3metric-large`: metres = output x focal / 300; without `intrinsics=` a 300 px focal length is assumed, wrong for a real camera). `unidepth-v2-vitl14`, `unik3d-vitl`, `depth-pro` and MoGe estimate the camera themselves (given `intrinsics=` replace `fx`); `zoedepth-nk` and the relative models (`da3mono-large` too) take none. Normals-only models (`kind` `none`) return `result.normals` `[B, H, W, 3]` (unit vectors, camera frame: x right, y down, z forward). ## Variants Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in [`card.toml`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/depth/models/zoedepth/card.toml). | variant | weights (author link) | SHA-256 | weights licence | commercial use | |---|---|---|---|---| | `zoedepth-nk@1` | [ZoeD_M12_NK.pt](https://github.com/isl-org/ZoeDepth/releases/download/v1.0/ZoeD_M12_NK.pt) | `5d26daa15d42` | MIT (assumed from code) | yes | ## Licence Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Licence files: `LICENSE`. Code licence: MIT; the authors do not state a separate weights licence. Training data: NYU Depth V2, KITTI stereo / optical flow 2012 / 2015, MegaDepth (Internet photo collections with SfM / MVS depth), TartanAir, not stated by the authors (MiDaS v3.1 BEiT-L relative-depth pre-training on 12 datasets, then metric fine-tuning on NYU Depth V2 and KITTI (ZoeDepth paper, arXiv 2302.12288)). Licence evidence: https://github.com/isl-org/ZoeDepth/blob/d87f17b2f5fdcb174cf4fb115491f4a6c60de152/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): `zoedepth-nk` 3000x4000 (2.4 GiB peak allocated, 2.6 reserved) ## Speed and memory ### Depth, synthetic | model | input | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `zoedepth-nk` | 518x770 | 295 | 250 | 114 | 80.0 | 3.1x | 1.4x | 1965 / 2124 | 1950 / 2124 | 1658 / 1960 | ### 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 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `zoedepth-nk` | 408 | 271 | 124 | 88.9 | 3.1x | 1.4x | 2040 / 2146 | 2037 / 2124 | 1771 / 1960 | ### Startup and first call | model | load (s): original | portable | kernels | first call (s): original | portable | kernels | | --- | --- | --- | --- | --- | --- | --- | | `zoedepth-nk` | 8.35 | 1.92 | 0.33† | 1.53 | 0.28 | 0.12 | ### torch.compile and TensorRT | model | input | time: portable | compile | TensorRT fp16 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `zoedepth-nk` | 994x1482 | 124 ms | 71.7 ms | 73.3 ms | 88.9 ms | 93.8 s | 138 s | 2037 / 2124 | 1813 / 1880 | 1771 / 1960 | 2246 / 2306 | ### Fixed-size speed and peak memory, all models | model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 | | --- | --- | --- | --- | --- | --- | | `zoedepth-nk` | portable | 107.5 ms / 1857 / 1966 | 147.2 ms / 2046 / 2184 | 147.6 ms / 2107 / 2220 | 113.0 ms / 2451 / 2658 | | `zoedepth-nk` | kernels | 74.9 ms / 1548 / 1802 | 105.6 ms / 1847 / 2138 | 106.2 ms / 1907 / 2230 | 80.3 ms / 2142 / 2486 | 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](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above 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 original code named under Details, same checkpoint and protocol. | variant | dataset | original fp32 | original fp16 | portable | kernels | note | |---|---|---|---|---|---|---| | `zoedepth-nk` | NYUv2 test, AbsRel / delta1 | 0.0532 / 0.9737 | 0.0528 / 0.9743 (NaN / inf output) | 0.0532 / 0.9737 | 0.0532 / 0.9737 | | | `zoedepth-nk` | iBims-1, AbsRel / delta1 | 0.0669 / 0.9545 | 0.0668 / 0.9546 (NaN / inf output) | 0.0669 / 0.9545 | 0.0669 / 0.9545 | | | `zoedepth-nk` | ETH3D two-view train left, AbsRel / delta1 | 0.1139 / 0.8648 | 0.1130 / 0.8653 (NaN / inf output) | 0.1139 / 0.8647 | 0.1139 / 0.8648 | possibly in the training data | | `zoedepth-nk` | Middlebury 2014 trainingH left, AbsRel / delta1 | 0.0449 / 0.9860 | 0.0449 / 0.9860 | 0.0449 / 0.9860 | 0.0449 / 0.9860 | possibly in the training data | Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06. ### Parity with the original code Every variant is checked against reference 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| <= 1 % and p99 <= 3 % of the reference's median |value| (absolute error of the output `depth`). ## Limitations - torch.compile(fullgraph=True) and torch.export are not supported: graph break in the vendored MiDaS core call and data-dependent NYU / KITTI head routing (documented xfail). - Inputs below 5 px per side raise InputError when pad_input is on. ## Usage ```python from fastforks import depth model = depth.load("zoedepth-nk") # mode="auto": the preferred backend from recorded measurements result = model("room.jpg") result.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 ). Other variants: `zoedepth-nk`. ## Kernels backend `depth.load("zoedepth-nk", mode="kernels")` runs our CUDA kernels (`cudnn_hacc`). It needs a prebuilt kernel for your GPU architecture (downloaded from 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.