sapiens2-normal / README.md
Flor's picture
Update model card for 0.4.0
ee08534 verified
|
Raw History Blame Contribute Delete
9.94 kB
metadata
library_name: fastforks
pipeline_tag: depth-estimation
license: other
license_name: other
license_link: >-
  https://huggingface.co/facebook/sapiens2-normal-0.4b/blob/52886591372f049acd4d59ae6d0a792ae1a61ac5/README.md
tags:
  - depth
  - mono-depth
  - monocular-depth
  - cuda
  - pytorch
  - fastforks
  - fastforks-card
base_model:
  - facebook/sapiens2-normal-0.4b
  - facebook/sapiens2-normal-1b

Sapiens2 normals (fastforks)

Sapiens2 (Meta 2026) surface normals of people: a ViT with RoPE, grouped-query attention and SwiGLU, pretrained on 1 B human images, fine-tuned with a PixelShuffle upsampling head on rendered humans; 1024 x 768 input (aspect ratio kept, padded), normals at the image size.

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/facebookresearch/sapiens2 at 7e5bae88456a.

Author weight repos: https://huggingface.co/facebook/sapiens2-normal-0.4b, https://huggingface.co/facebook/sapiens2-normal-1b.

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.

variant weights (author link) SHA-256 weights licence commercial use
sapiens2-normal-0.4b@1 sapiens2_0.4b_normal.safetensors d2f20e8df718 other unclear (treat as no)
sapiens2-normal-1b@1 sapiens2_1b_normal.safetensors 74283c838275 other unclear (treat as no)

Licence

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

Training data: Pretraining on Humans-1B (Meta-internal, not released); normal fine-tuning on rendered people (Meta's MetaSim and RenderPeople scans; not released)..

Licence evidence: https://huggingface.co/facebook/sapiens2-normal-0.4b/blob/52886591372f049acd4d59ae6d0a792ae1a61ac5/README.md (license: other, license_name: sapiens2-license) ; https://github.com/facebookresearch/sapiens2/blob/7e5bae88456ac418ff0e58e74106c9fe192055d4/LICENSE.md

Input size

any H x W >= 1, resized or padded inside the model Tested up to (portable, fp16, RTX 5060 Ti 16 GB): sapiens2-normal-0.4b 3000x4000 (1.5 GiB peak allocated, 1.9 reserved); sapiens2-normal-1b 3000x4000 (3.5 GiB peak allocated, 4.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
sapiens2-normal-0.4b 2048x1536 – – – 137 – – – – 1422 / 1560
sapiens2-normal-1b 2048x1536 – – – 327 – – – – 3494 / 3626

Depth, COCO val2017 000000003156.jpg (one person) resized to the input size, 2048x1536

model time (ms): original fp32 original portable peak memory (MiB, allocated / reserved): original portable
sapiens2-normal-0.4b 659 178 159 3234 / 4306 1432 / 1900
sapiens2-normal-1b 1753 440 374 9461 / 9914 3504 / 4156

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
sapiens2-normal-0.4b 2.97 (2048x1536) 0.65 (2048x1536) 1.23 (1024x768) 0.34 (2048x1536) 0.31 (2048x1536) 0.21 (1024x768)
sapiens2-normal-1b 3.88 (2048x1536) 1.29 (2048x1536) 40.73 (1024x768) 0.59 (2048x1536) 0.48 (2048x1536) 0.46 (1024x768)

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)
sapiens2-normal-0.4b 1024x768 158 ms 127 ms 280 ms 136 ms 26.0 s 65.7 s 1405 / 1900 1322 / 1360 1396 / 1540 2324 / 2360
sapiens2-normal-1b 1024x768 373 ms 318 ms 394 ms 326 ms 38.2 s 120 s 3477 / 4156 3394 / 3524 3467 / 3586 6444 / 6492

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. Normals: angle to the ground-truth normal over the pixels with ground truth (Marigold's evaluation sets), mean over images. Original = the original code named under Details, same checkpoint and protocol.

variant dataset portable portable fp32 note
sapiens2-normal-0.4b NYUv2 test normals, mean / median angle deg, % < 11.25 / < 30 deg 35.74 / 33.20 / 14.37 / 47.99 35.73 / 33.19 / 14.38 / 48.00
sapiens2-normal-0.4b iBims-1 normals, mean / median angle deg, % < 11.25 / < 30 deg 27.25 / 20.45 / 32.16 / 67.24 27.25 / 20.45 / 32.16 / 67.24
sapiens2-normal-1b NYUv2 test normals, mean / median angle deg, % < 11.25 / < 30 deg 40.73 / 39.46 / 9.94 / 37.81 40.74 / 39.47 / 9.93 / 37.79
sapiens2-normal-1b iBims-1 normals, mean / median angle deg, % < 11.25 / < 30 deg 23.03 / 15.12 / 42.68 / 75.16 23.03 / 15.12 / 42.68 / 75.16

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f0b2da70d, 2026-11-30.

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.01 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.003 and p99 <= 0.01 (absolute error of the output normals).

Limitations

  • Custom licence with use restrictions: not in the commercial selection (FASTFORKS_COMMERCIAL_ONLY, commercial ComfyUI pack).
  • Trained on people only: normals of the background are not meaningful; mask them, e.g. with sapiens2-seg (class 0 = background).
  • Every image is resized into 1024 x 768 (aspect ratio kept, padded; upstream test protocol); crop to the person first for small people.
  • fp16 CUDA kernels (shared with Sapiens2 segmentation). Apple MLX: a hand-written network (shared Sapiens2 backbone, channels-last head); the resize, padding and normalisation stay on torch.

Usage

from fastforks import depth

model = depth.load("sapiens2-normal-0.4b")  # 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 https://github.com/kleinicke/fastforks). Other variants: sapiens2-normal-0.4b, sapiens2-normal-1b.

Kernels backend

depth.load("sapiens2-normal-0.4b", mode="kernels") runs our CUDA kernels (sapiens2_ops, swiglu). 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.