DepthFM (fastforks)

DepthFM (Gui et al. 2024): affine-invariant monocular depth by flow matching from the image latent to the depth latent; a Stable Diffusion 2.1 UNet fine-tuned to the flow, a few Euler steps, ensemble of noise samples (v1).

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/CompVis/depth-fm at da632c8.

Author weight repos: https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5.

Task: depth. Tier: experimental. 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.

variant weights (author link) SHA-256 weights licence commercial use
depthfm-v1@1 depthfm-v1.ckpt
vae/diffusion_pytorch_model.safetensors
8364b475b525
a2b5134f4dbc
LicenseRef-CreativeML-OpenRAIL-PlusPlus-M AND LicenseRef-CreativeML-OpenRAIL-M yes

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Licence files: LICENSE, LICENSE-MODEL, LICENSE-VAE.

Training data: Stable Diffusion 2.1 (LAION-5B subsets) fine-tuned on the synthetic Hypersim and Virtual KITTI 2 datasets per the DepthFM paper (arXiv 2403.13788).

  • Licence note: The UNet is fine-tuned from Stable Diffusion 2.1 (OpenRAIL++-M) and runs with the Stable Diffusion 1.5 VAE (OpenRAIL-M): commercial use is allowed but with use restrictions that must be passed on; the training data terms are not checked.

Licence evidence: https://github.com/CompVis/depth-fm/blob/da632c8118e41cc64ca191a13314e2db1a7722d9/README.md (fine-tuned from Stable Diffusion v2-1; code MIT); SD2 licence text from https://huggingface.co/sd2-community/stable-diffusion-2/blob/2511124fabf8bf30c0ca9dccd9729e7f0f2fa669/LICENSE-MODEL, SD1.5 VAE licence https://github.com/CompVis/stable-diffusion/blob/21f890f9da3cfbeaba8e2ac3c425ee9e998d5229/LICENSE

Input size

any H x W >= 1, resized or padded inside the model Tested up to (portable, fp16, RTX 5060 Ti 16 GB): depthfm-v1 1024x1024 (9.8 GiB peak allocated, 15.0 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
depthfm-v1 994x1482 OOM OOM 4854 3555 – 1.4x – 5422 / 7404 3768 / 5942

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
depthfm-v1 – 3.58 4.59 – 6.00 3.73

torch.compile and TensorRT

model input time: portable compile TensorRT (fp16 unless shown) kernels preparation: compile (cold first call) ONNX + engine build peak MiB (alloc / reserved): portable compile kernels TensorRT (engine + torch)
depthfm-v1 994x1482 4854 ms 3947 ms 2235 ms 3555 ms 102 s 608 s 5422 / 7404 9240 / 10292 3768 / 5942 12696 / 12746
depthfm-v1 480x640 907 ms – 353 ms (fixed-shape exported depth network) – – – 4430 / 7296 – – 3479 / 3494

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: benchmarks (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

Aligned depth scores fit scale and shift by least squares, in disparity space for inverse-depth models. Metric depth scores follow each dataset's protocol. Both average over images. Original = the original code named under Details, same checkpoint and protocol.

variant dataset original fp32 original fp16 portable portable fp32 kernels TensorRT note
depthfm-v1 iBims-1, AbsRel / delta1 0.0652 / 0.9540 0.0652 / 0.9540 0.0650 / 0.9543 0.0650 / 0.9543 0.0650 / 0.9543 0.0650 / 0.9543
depthfm-v1 NYUv2 test (first 100 images), AbsRel / delta1 0.0735 / 0.9489 0.0731 / 0.9492 0.0732 / 0.9493 0.0732 / 0.9493

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 49f9cc58 / 68b2f345, 2026-11-16 to 2026-11-18; 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 68b2f345, 2026-11-16; tensorrt: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 30e30409, 2026-11-18.

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

  • Flow model on a noised latent: the seeded noise comes from a CPU generator and differs from the original code's device generator for the same seed.
  • A traced or exported module reuses the noise of its traced shape.
  • The network input sides are rounded to multiples of 64, so the aspect ratio changes slightly.

Usage

from fastforks import depth

model = depth.load("depthfm-v1")  # 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 https://github.com/kleinicke/fastforks). Other variants: depthfm-v1.

Kernels backend

depth.load("depthfm-v1", mode="kernels") runs our CUDA kernels (cudnn_hacc, group_silu). 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.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including fastforks/depthfm