Sapiens2: Human Image Matting
May 24, 2026 · View on GitHub
Per-pixel alpha matting for human subjects. Predicts a soft foreground mask
(alpha in [0, 1]) plus a pre-multiplied foreground RGB output.
Inference
Runs on demo set (demo/data, 100 frames) by default:
cd $SAPIENS_ROOT/sapiens/dense
./scripts/demo/matting.sh
Open the script and adjust:
INPUT— path to your image directory (default:../../demo/data)OUTPUT— where to save visualizationsMODEL_NAME— model size (default:sapiens2_1b)JOBS_PER_GPU,GPU_IDS— parallelism (defaults: 3 jobs/GPU on GPUs 0–7)
Outputs per image:
- Side-by-side visualization:
[input | alpha matte | foreground on chroma green] --save_pred(on by default in the script) additionally writes<name>_alpha.npywith the raw alpha asfloat32in[0, 1].
Resources
- Demo: facebook/sapiens2-matting
- Model: 1B