Sapiens2 Segmentation Advanced
Segmentation With the Training Wheels Off
- model
- image
- mask
- preview
- foreground_mask
- merged_mask
- masks
- labels
- result
The easy Sapiens2 Segmentation node gives you a person mask in three clicks. This is the same model with the instrument panel exposed - the version you reach for when you need to control the preview, constrain where segmentation runs, and poke at the raw results. Same 29-class label set (28 foreground body parts plus background), same per-pixel classification, but six outputs and three extra controls.
How it works
Identical engine to the easy node: the Sapiens2 seg model assigns every pixel a class id, parts selects which classes matter, and everything merges into masks. The Advanced difference is where you can inject constraints and pull out internals:
mask(optional) - an input mask that limits where segmentation applies. Hand the node the output of an earlier mask and it multiplies its segmentation by it, so you can say "segment within this region only." This is the control the easy node lacks, and it's how you restrict a person mask to a pre-cropped or pre-masked area.preserve_background- only does anything when you've wired amask. It decides what happens to the area outside that mask: off (the default) means that region goes black, on means the original photo shows through. Flip it on when you want the subject classified but the scene visible around it.overlay_opacity- how transparent the colored part overlay inpreviewis. Purely cosmetic, default 0.55.
The inputs that matter
Honestly, for most jobs the only new ones worth touching are mask (when you want to constrain the region) and overlay_opacity (when the preview is too noisy to read). parts and invert work exactly like the easy node - parts empty means all foreground parts, and the visual row UI accepts things like Face / all or Arm / left lower.
The outputs
preview- the part overlay at your chosen opacity.foreground_mask- a clean person/foreground mask from the inference itself, before any part merging. If you only need "subject vs. background," grab this one.merged_mask- the merged selection mask, the usual thing to wire downstream into the normal and pointmap nodes.masks- per-part mask batch for the selected parts.labels- aSAPIENS2_LABELSobject with class ids mapped to part names/groups.result- aSAPIENS2_RESULTcarrying the raw data, includingmasked_class_ids(the class map after your input mask was applied) andselected_part_ids. This is the "I'm building a graph that inspects internals" output; you can ignore it for plain masking.
Installing it
It's part of Bogyie/ComfyUI-Sapiens2-Easy:
cd ComfyUI/custom_nodes
git clone https://github.com/Bogyie/ComfyUI-Sapiens2-Easy.git
cd ComfyUI-Sapiens2-Easy
python install.py
Restart ComfyUI, or install via ComfyUI Manager. It takes the same SAPIENS2_MODEL from a loader with task = segmentation (first-run weight download, and it's a big one - start on 0.4b/0.8b).
Where people get burned
The biggest trap is treating this as a better version of the easy node and reaching for it everywhere. It isn't - for "cut the person out," the easy node is less to configure and does the same job. This node earns its keep when you're chaining masks (a prior mask constrains the segmentation) or compositing previews into a report. Otherwise, the same warnings as its little sibling apply: don't run normal/pointmap without a mask, and if you're on Apple Silicon with scrambled labels, it's the MPS thing again - auto never picks MPS, and you shouldn't either unless you've verified your PyTorch/MPS build.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| model | SAPIENS2_MODEL | — | |
| image | IMAGE | — | |
| overlay_opacity | FLOAT | 0.550–1 | — |
| preserve_background | BOOLEAN | false | — |
| invert | BOOLEAN | false | — |
| parts | STRING | — | |
| maskopt | MASK | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| preview | IMAGE | — |
| foreground_mask | MASK | — |
| merged_mask | MASK | — |
| masks | MASK | — |
| labels | SAPIENS2_LABELS | — |
| result | SAPIENS2_RESULT | — |