Models · Semantic segmentation

Sapiens segmentation

Meta's Sapiens: segmentation of human body parts (28 Goliath classes such as face, hair, limbs and clothing). Non-commercial licence.

stable Fork of facebookresearch/sapiens@2cb0722 · backends: portable, kernels

Checkpoint

Paper 2024 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 92.6 ms 1024x2048, fp16
vs the faster original 1.9× original fp16: 173 ms
Peak memory 1,643 MiB original: 2,520 MiB
Accuracy vs original fp32 +0.02 kernels person IoU %, COCO val2017 persons (32.60 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install "fastforks-core[nc]"

from fastforks import segmentation

model = segmentation.load("sapiens-seg-0.3b-goliath")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.logits
result.backend  # what ran: mode, device, dtype, kernels

The weights are non-commercial: fastforks downloads them only with FASTFORKS_NONCOMMERCIAL=1 set.

fastforks bench sapiens-seg-0.3b-goliath

Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.

Speed and memory

Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32 4660.37×3,673 MiB/4,104 MiB––
Original fp16torch.autocast(fp16) around the forwardfp16 173–2,520 MiB/2,724 MiB––
Portable fp32fp32not measured ––––
Portablefp16 1321.3×1,643 MiB/1,762 MiB1.20.13
Kernelsfp16 92.61.9×1,643 MiB/1,762 MiB1.00.09
Portable + torch.compile 1181.5×1,373 MiB/1,462 MiB12 (build)–
TensorRT fp16fp16 1561.1×1,564 MiBenginenot comparable53 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-03 to 2026-11-04. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5 (tools/speed_check.py), synthetic CUDA input (bench_inputs); peak = max over the first call and the timed calls. Ratios divide two times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.

Other devices

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-12Originalfp324354 4,741 MiB processmatches1024x2048
Portablefp161517 3,748 MiB processmatches1024x2048
Portablefp322988 4,766 MiB processmatches1024x2048
Kernelsfp16not implemented–1024x2048
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16142 1,616 MiB/1,742 MiB–1024x2048
Kernelsfp16135 1,628 MiB/1,742 MiB–1024x2048
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1640.9 1,754 MiB/1,882 MiB–1024x2048
Kernelsfp1639.7 1,766 MiB/1,882 MiB–1024x2048
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1699.3 1,616 MiB/1,742 MiB–1024x2048
Kernelsfp1697.7 1,616 MiB/1,742 MiB–1024x2048
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp1636.3 1,760 MiB/1,882 MiB–1024x2048
Kernelsfp1634.4 1,760 MiB/1,882 MiB–1024x2048
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp1624.4 1,916 MiB/2,042 MiB–1024x2048
Kernelsfp1625.7 1,916 MiB/2,042 MiB–1024x2048

CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.

Licence and weights

Non-commercial only

Code
CC-BY-NC-4.0 LICENSE
Weights
CC-BY-NC-4.0 source
Training data
MAE pretraining on Humans-300M (Meta-internal, not released); segmentation fine-tuning on Goliath body-part annotations (Meta, not released)
  • code: CC-BY-NC-4.0 (noncommercial)
  • weights: CC-BY-NC-4.0

Our reading of the licences, not legal advice.

Weights

sapiens_0.3b_goliath_best_goliath_mIoU_7673_epoch_194_torchscript.pt2 1.4 GB· hosted on Hugging Face

fastforks downloads and checks these files on first use (fastforks download sapiens-seg-0.3b-goliath). Non-commercial weights need FASTFORKS_NONCOMMERCIAL=1.

Accuracy

The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.

COCO val2017 persons

every 10th image, person IoU %

Rundtypeperson IoU % ↑Δ person IoU % vs fp32 originalimagesms / image
Original fp32fp3232.60 reference 291 469
Original fp16fp1632.61 +0.01 291 179
Portable fp32fp3232.60 ±0.00 291 445
Portablefp1632.61 +0.01 291 132
Kernelsfp1632.62 +0.02 291 92.0

Any body part counts as person; ground truth = the COCO person masks. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Closeness to the original

Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 and p99 <= 0.25 (absolute error of the output logits).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 not recorded
GPU default dtypes, mean |diff|≤ 0.05 0.00478
GPU default dtypes, p99 |diff|≤ 0.25 0.01673

Recorded for sapiens-seg-0.3b-goliath on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-04, with these kernels: cudnn_haccfastbbseg_up

Details

Sapiens (Khirodkar et al. 2024) human body-part segmentation: a ViT pretrained on 300 M human images, fine-tuned with a deconvolution head on Goliath's 28 classes (face, hair, left / right limbs, clothing, lips, teeth, ...); 1024 x 768 input, the Sapiens-Lite TorchScript checkpoints.

Input / output
Input: one RGB image. Output: per-pixel class labels (logits with logits=True).
Input size
any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (2,254 MiB allocated)
Outputs
logits
Checkpoint
embed_dim=1024, depth=24, num_heads=16
CUDA kernels
  • fastbbfast backbone kernels: flash attention, window attention, instance norm and rotary embeddings for ViT and similar backbones
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
  • seg_upfused resize and argmax of segmentation scores
Apple (MPS)
fp32, fp16
Full reference, generated from the repository

Meta's Sapiens: segmentation of human body parts (28 Goliath classes such as face, hair, limbs and clothing). Non-commercial licence.

Commercial use: no (code: CC-BY-NC-4.0 (noncommercial); weights: CC-BY-NC-4.0).

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
sapiens-seg-0.3b-goliathsynthetic (1024x2048)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
466
173
132
92.6
118
156
3673 / 4104
2520 / 2724
1643 / 1762
1643 / 1762
1373 / 1462
2465 / 2526
sapiens-seg-1b-goliathsynthetic (1024x2048)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
1189
354
275
185
263
244
6874 / 7284
5721 / 5906
3259 / 3384
3259 / 3382
2986 / 3084
5694 / 5742
Details
  • Original code: https://github.com/facebookresearch/sapiens at 2cb07227a740
  • Code licence: CC-BY-NC-4.0 (noncommercial); files: LICENSE
  • Weights licence: CC-BY-NC-4.0
  • Licence evidence: https://huggingface.co/facebook/sapiens-seg-1b-torchscript/blob/584504252a6d2a27ea6560927811db734ee42332/README.md
  • Training data: MAE pretraining on Humans-300M (Meta-internal, not released); segmentation fine-tuning on Goliath body-part annotations (Meta, not released)
  • Kernel libraries: fastbb, cudnn_hacc, seg_up
  • Variants: sapiens-seg-0.3b-goliath, sapiens-seg-1b-goliath
  • Outputs: logits; label_set: goliath-28
  • Input size: any H x W >= 32, padded to a multiple of 32
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): sapiens-seg-0.3b-goliath 3000x4000 (2.2 GiB peak allocated, 3.2 reserved); sapiens-seg-1b-goliath 3000x4000 (3.8 GiB peak allocated, 5.0 reserved)
  • sapiens-seg-0.3b-goliath 1024x2048, first call: portable + torch.compile 12 s (cold Inductor cache), TensorRT fp16 53 s (ONNX + engine).
  • sapiens-seg-1b-goliath 1024x2048, first call: portable + torch.compile 19 s (cold Inductor cache), TensorRT fp16 85 s (ONNX + engine).
  • sapiens-seg-0.3b-goliath original 1024x2048: torch.autocast(fp16) around the forward
  • sapiens-seg-1b-goliath original 1024x2048: torch.autocast(fp16) around the forward
  • sapiens-seg-0.3b-goliath load / first call: original 4.92 s / 1.024 s (512x512), portable 1.22 s / 0.132† s, kernels 0.96† s / 0.092† s
  • sapiens-seg-1b-goliath load / first call: original 11.33 s / 0.569 s (512x512), portable 3.54 s / 0.274† s, kernels 2.27† s / 0.18† s
  • † measured in the speed sweep after the portable load (or an earlier size) in the same process: file cache and kernels are warm, so the time is lower than a fresh start.
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5 (tools/speed_check.py), synthetic CUDA input (bench_inputs); peak = max over the first call and the timed calls

Measured

Any body part counts as person; ground truth = the COCO person masks. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
sapiens-seg-0.3b-goliathCOCO val2017 persons, every 10th image, person IoU %32.6032.6132.6132.6032.62
sapiens-seg-1b-goliathCOCO val2017 persons, every 10th image, person IoU %54.2254.2254.2254.19

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Parity

CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 and p99 <= 0.25 (absolute error of the output logits).

variantkernels error vs original, mean / p99GPU, torchkernels used
sapiens-seg-0.3b-goliath0.00478 / 0.01673RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, fastbb@7d058322634d:sm_120, seg_up@3e44e71200cd:sm_120
sapiens-seg-1b-goliath0.00819 / 0.03064RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, fastbb@7d058322634d:sm_120, seg_up@3e44e71200cd:sm_120

Example output

One fixed input through this checkpoint, the same for every model of the task (kernels · float16 · NVIDIA GeForce RTX 5060 Ti).

Input
Output
  • Background 100%
A cup of coffee, input
Input · 100%

Input: A cup of coffee, Rachel Michetti (CC0).