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.

Sapiens2-1B matting demo

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 visualizations
  • MODEL_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.npy with the raw alpha as float32 in [0, 1].

Resources