--- library_name: "fastforks" pipeline_tag: "depth-estimation" license: "openrail++" tags: - "depth" - "mono-depth" - "monocular-depth" - "cuda" - "pytorch" - "fastforks" - "fastforks-card" base_model: - "Stable-X/yoso-normal-v0-3" --- # StableNormal turbo (fastforks) StableNormal turbo (Ye et al., SIGGRAPH Asia 2024): surface normals in one step (YOSO, v0.3); a Stable Diffusion 2 UNet denoises a normals latent with the image latent fed through a ControlNet encoder. 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 `594b934630ab`. Author weight repos: . Task: depth. Tier: experimental. Outputs: `normals`. 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/stablenormal/card.toml). | variant | weights (author link) | SHA-256 | weights licence | commercial use | |---|---|---|---|---| | `stablenormal-turbo@1` | [unet/diffusion_pytorch_model.fp16.safetensors](https://huggingface.co/Stable-X/yoso-normal-v0-3/resolve/2202fcb69960d94b437e06c19c556a12ceeb57c0/unet/diffusion_pytorch_model.fp16.safetensors)
[vae/diffusion_pytorch_model.fp16.safetensors](https://huggingface.co/Stable-X/yoso-normal-v0-3/resolve/2202fcb69960d94b437e06c19c556a12ceeb57c0/vae/diffusion_pytorch_model.fp16.safetensors)
[text_encoder/model.fp16.safetensors](https://huggingface.co/Stable-X/yoso-normal-v0-3/resolve/2202fcb69960d94b437e06c19c556a12ceeb57c0/text_encoder/model.fp16.safetensors)
[controlnet/diffusion_pytorch_model.fp16.safetensors](https://huggingface.co/Stable-X/yoso-normal-v0-3/resolve/2202fcb69960d94b437e06c19c556a12ceeb57c0/controlnet/diffusion_pytorch_model.fp16.safetensors) | `b966130575b7`
`3e4c08995484`
`bc1827c46545`
`d54aabc094e3` | Apache-2.0 | 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`. Derived from Stable Diffusion 2: the CreativeML OpenRAIL++-M use restrictions (Attachment A, ) apply to these weights and to their redistribution, in addition to the terms above. Training data: Stable Diffusion 2 (LAION-5B subsets) fine-tuned on synthetic and real normals datasets (Hypersim, Replica, ScanNet and others per the StableNormal paper, arXiv 2406.16864). Licence evidence: https://github.com/Stable-X/StableNormal/blob/594b934630ab3bc71f35c77d14ec7feb98480cd0/LICENSE.txt (Apache-2.0); https://huggingface.co/Stable-X/yoso-normal-v0-3/blob/2202fcb69960d94b437e06c19c556a12ceeb57c0/README.md (license: apache-2.0) ## Input size any H x W >= 1, resized or padded inside the model Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `stablenormal-turbo` 3000x4000 (3.6 GiB peak allocated, 4.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 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `stablenormal-turbo` | 994x1482 | – | 299 | 289 | 180 | 1.7x | 1.6x | 4156 / 4374 | 3463 / 3628 | 3037 / 3172 | ### Startup and first call | model | load (s): original | portable | kernels | first call (s): original | portable | kernels | | --- | --- | --- | --- | --- | --- | --- | | `stablenormal-turbo` | 6.36 | 2.94 | 3.25 | 1.13 | 0.54 | 0.35 | ### 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) | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `stablenormal-turbo` | 994x1482 | 289 ms | 238 ms | 118 ms | 180 ms | 76.3 s | 198 s | 3463 / 3628 | 3019 / 3106 | 3037 / 3172 | 5587 / 5626 | 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 | |---|---|---|---|---|---|---| | `stablenormal-turbo` | iBims-1 normals, mean / median angle deg, % < 11.25 / < 30 deg | 17.46 / 8.26 / 63.83 / 82.71 | 17.46 / 8.26 / 63.83 / 82.70 | 17.46 / 8.26 / 63.83 / 82.71 | 17.46 / 8.26 / 63.83 / 82.71 | | Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks aee4b565, 2026-11-13. ### Parity with the original code Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 1e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.00046 and p99 <= 0.0021 (absolute error of the output `normals`). ## Limitations - Normals only: no depth. - Diffusion model: the seeded noise comes from a CPU generator; upstream draws it from the unseeded global RNG, so its outputs vary from call to call (slightly). - Upstream's `Predictor` wrapper (pre-resize to a multiple of 64 near 1024 px, uint8 round trip, LANCZOS back) is not applied: the runners follow its pipeline (768 px). - A traced or exported module reuses the noise of its traced shape. ## Usage ```python from fastforks import depth model = depth.load("stablenormal-turbo") # mode="auto": the preferred backend from recorded measurements result = model("room.jpg") result.normals # [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: `stablenormal-turbo`. ## Kernels backend `depth.load("stablenormal-turbo", 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.