--- library_name: "fastforks" pipeline_tag: "depth-estimation" license: "openrail++" tags: - "depth" - "mono-depth" - "monocular-depth" - "cuda" - "pytorch" - "fastforks" - "fastforks-card" base_model: - "prs-eth/marigold-depth-v1-1" --- # Marigold (fastforks) Marigold (Ke et al. 2023): affine-invariant monocular depth by diffusion; a Stable Diffusion 2 UNet fine-tuned to denoise a depth latent conditioned on the image latent (depth v1-1, few DDIM steps). 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 `2bfbdea`. Author weight repos: . 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/marigold/card.toml). | variant | weights (author link) | SHA-256 | weights licence | commercial use | |---|---|---|---|---| | `marigold-depth-v1-1@1` | [unet/diffusion_pytorch_model.safetensors](https://huggingface.co/prs-eth/marigold-depth-v1-1/resolve/9571e7123e258cf052b4e54241f17971c290e9a8/unet/diffusion_pytorch_model.safetensors)
[vae/diffusion_pytorch_model.safetensors](https://huggingface.co/prs-eth/marigold-depth-v1-1/resolve/9571e7123e258cf052b4e54241f17971c290e9a8/vae/diffusion_pytorch_model.safetensors)
[text_encoder/model.safetensors](https://huggingface.co/prs-eth/marigold-depth-v1-1/resolve/9571e7123e258cf052b4e54241f17971c290e9a8/text_encoder/model.safetensors) | `ad9342d79bb5`
`a1d993488569`
`cce6febb0b6d` | LicenseRef-CreativeML-OpenRAIL-PlusPlus-M | yes | ## Licence Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: `LICENSE`, `LICENSE-MODEL`, `LICENSE-huggingface`. Training data: Stable Diffusion 2 (LAION-5B subsets) fine-tuned on the synthetic Hypersim and Virtual KITTI 2 datasets per the Marigold papers (arXiv 2312.02145, 2505.09358). - Licence note: The weights use the OpenRAIL++-M licence: commercial use is allowed but with use restrictions that must be passed on; the training data terms are not checked. Licence evidence: https://huggingface.co/prs-eth/marigold-depth-v1-1/blob/9571e7123e258cf052b4e54241f17971c290e9a8/README.md (License: CreativeML Open RAIL++-M) ## Input size any H x W >= 8, resized or padded inside the model Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `marigold-depth-v1-1` 3000x4000 (3.0 GiB peak allocated, 3.8 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 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `marigold-depth-v1-1` | 994x1482 | – | – | 410 | 261 | – | 1.6x | – | 2776 / 2938 | 2343 / 2500 | ### 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 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `marigold-depth-v1-1` | 963 | 439 | – | – | – | – | 3414 / 3580 | – | – | ### Startup and first call | model | load (s): original | portable | kernels | first call (s): original | portable | kernels | | --- | --- | --- | --- | --- | --- | --- | | `marigold-depth-v1-1` | 1.32 | 11.04 (518x770) | 2.49 (518x770) | 0.60 | 0.89 (518x770) | 0.50 (518x770) | ### 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) | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `marigold-depth-v1-1` | 994x1482 | 410 ms | 342 ms | 172 ms | 261 ms | 127 s | 285 s | 2776 / 2938 | 2341 / 2418 | 2343 / 2500 | 4263 / 4318 | ### Fixed-size speed and peak memory, all models | model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 | | --- | --- | --- | --- | --- | --- | | `marigold-depth-v1-1` | portable | 455.3 ms / 2898 / 3650 | 351.7 ms / 2648 / 3306 | 351.8 ms / 2661 / 3378 | 458.1 ms / 3033 / 3844 | | `marigold-depth-v1-1` | kernels | 433.0 ms / 2636 / 3464 | 324.3 ms / 2452 / 3070 | 324.9 ms / 2465 / 3142 | 435.6 ms / 2770 / 3552 | Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB). 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 | |---|---|---|---|---|---|---| | `marigold-depth-v1-1` | NYUv2 test, AbsRel / delta1 | 0.0561 / 0.9703 | 0.0561 / 0.9703 | 0.0561 / 0.9703 | 0.0561 / 0.9703 | | | `marigold-depth-v1-1` | iBims-1, AbsRel / delta1 | 0.0499 / 0.9721 | 0.0499 / 0.9721 | 0.0499 / 0.9722 | 0.0499 / 0.9721 | | | `marigold-depth-v1-1` | ETH3D two-view train left, AbsRel / delta1 | 0.1141 / 0.8715 | 0.1141 / 0.8715 | 0.1141 / 0.8715 | 0.1141 / 0.8716 | possibly in the training data | | `marigold-depth-v1-1` | Middlebury 2014 trainingH left, AbsRel / delta1 | 0.0413 / 0.9899 | 0.0413 / 0.9899 | 0.0413 / 0.9899 | 0.0413 / 0.9899 | possibly in the training data | Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 491e248a / 939adfe8, 2026-11-06 to 2026-11-11. ### 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.0001 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 - Diffusion model: the seeded noise comes from a CPU generator and differs from the original code's CUDA generator for the same seed. - A traced or exported module reuses the noise of its traced shape. - Kernels time is dominated by unfused elementwise kernels (GroupNorm / SiLU / adds). ## Usage ```python from fastforks import depth model = depth.load("marigold-depth-v1-1") # 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: `marigold-depth-v1-1`. ## Kernels backend `depth.load("marigold-depth-v1-1", 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.