Sapiens2 Segmentation
Sapiens2 Segmentation
- model
- image
- preview
- merged_mask
- masks
- labels
Everything in this pack is designed to start here. The recommended first workflow is literally Image Load → Sapiens2 Segmentation → Sapiens2 Normal → Sapiens2 Pointmap, and there's a reason segmentation goes first: before you compute normals or reconstruct 3D geometry for a person, you want to know where the person is. This node hands you that as a set of body-part masks - not just "person / not person," but 29 classes: 28 foreground parts (arms, legs, hands, shoes, socks, clothing, hair) plus background, with facial parts like lips, teeth, and tongue in the mix.
Sapiens2 Segmentation is the easy node in the pair - the one you reach for 90% of the time. It's Meta's Sapiens2 segmentation model in a single box with two optional toggles and four outputs.
How it works
The Sapiens2 seg model assigns every pixel a class id. From there the node lets you pick which parts you care about: leave parts empty and it merges all foreground body parts into one mask - your person mask. Give it a list of parts and it merges just those, which is how you get "just the left arm" or "just the shoes." invert flips the mask when you want everything except the selected parts. Under the hood it's a straightforward per-pixel classification, which is why the masks are clean and why they work so well as the input to the normal and pointmap nodes that follow.
The inputs that matter
parts- a multiline string, empty by default (meaning "all foreground parts"). You can type comma-separated part names, or use the node's visual row UI -<enable> <part group> <detail> <remove>- where a row likeFace / allmeans face-neck plus eyeglass, lip, teeth, and tongue, andArm / left lowerisolates one limb. If you leave it empty, don't worry: "everything" is a great default.invert- flip the selection. Off by default.
The required model and image inputs are the usual ones: a SAPIENS2_MODEL from the loader with task = segmentation, and your image.
The outputs
preview- the colored part map overlaid on the image. Good for checking that the model actually found your subject.merged_mask- the one to wire everywhere. A singleMASKof everything you selected. This is what feedsSapiens2 Normal's mask input,Sapiens2 Pointmap's mask input, or any mask consumer in a wider workflow.masks- the same selection as a batch of per-part masks, if you need each body part as its own mask.labels- aSAPIENS2_LABELSobject mapping class ids to part names and groups, so downstream logic can reference parts by name.
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 (search "ComfyUI-Sapiens2-Easy"). It needs a Sapiens2 Model Loader with task = segmentation upstream; the loader auto-downloads facebook/sapiens2-seg-{size} on first run - a chunky download, so build and test on 0.4b/0.8b before committing to 1b or 5b.
Where people get burned
The classic mistake is running normal/pointmap without this node and wondering why the output is full of background. Segment first, mask everything downstream. The other one is MPS: on Apple Silicon, auto device selection deliberately avoids MPS because some PyTorch/MPS builds produce wrong segmentation label maps - if your masks look scrambled, you're almost certainly on MPS, so switch to cuda or cpu. And if the mask is grabbing too much (or too little), remember the parts string and invert are the levers; you don't need a second node to refine what counts as "the person."
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| model | SAPIENS2_MODEL | — | |
| image | IMAGE | — | |
| invertopt | BOOLEAN | false | — |
| partsopt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| preview | IMAGE | — |
| merged_mask | MASK | — |
| masks | MASK | — |
| labels | SAPIENS2_LABELS | — |