Body Segment (NH)
Type 'clothes - shoes' and get the mask
- image
- mask
- cutout_rgba
- mask_image
- segs
- report
Most masking in ComfyUI ends up as painting. You want to fix the skin on a portrait, so you grab a mask editor and spend five minutes dragging a brush around a person's outline a model could have found in a second. Body Segment deletes that step: you type skin, or hair, face, or clothes - shoes, and the mask comes back.
It's the generalist of the three people-parsing nodes in NH-Nodes - the 76-node pack from jetthuang. Garment Segment is finer on individual garments, Portrait Segment knows eyes and eyebrows, this one covers the whole body by part name.
What's behind it
Sapiens2, Meta's body-part segmentation model (2026). It labels every pixel of each person as one of 28 classes or background: face and neck, hair, torso, upper and lower arms, hands, legs, feet, lips, teeth, tongue, glasses, upper and lower clothing, shoes, socks, accessories.
Real but not famous - community discussion of Sapiens2 is close to nil. Which is the case where a good node earns its place. Its licence is friendlier than most of this pack's vision nodes too: royalty-free, no non-commercial clause, though it bans surveillance, biometric identification and deepfakes. For paid retouching that's a real difference from Garment Segment's research-only terms.
How it copes with big photos
The model looks at 768×1024 crops, so handing it a 6000 px family photo gives you mush. The node shrinks the whole picture and parses that first, keeping the answer wherever nothing better arrives; finds people with YuNet, a 230 KB CPU face detector, plus whatever the first pass thought looked like a person; then parses crops around those people at full model resolution, so each person is seen at about 1024 px whatever the photo size. Crop labels only replace the first answer away from the crop's cut edges, so no straight line shows up in anyone's hair.
The inputs worth setting
regions is the whole node. It takes the pack's small formula language: commas or new lines list, + unions, - subtracts, & intersects, ~ inverts, background is everything outside the people. Spaces around the minus matter - clothes-shoes is read as one word and refused. Vietnamese works too: tóc, môi, quần áo.
model_size - 0.4b is the default for good reason: 1.6 GB download, about 1.5 GB of VRAM, and the one you'll keep. 0.8b and 1b are 3.3 GB and 5.9 GB for marginal precision at real speed cost.
The three refinement fields apply in fixed order - fill_holes, then mask_expand, then mask_blur. Shrink by 3-4 px before an inpaint so the edit stays off the hair edge; grow a few px to recolour clothes without a halo. device is cuda or cpu; the CPU works and is slow. show_preview draws the mask, found parts and report on the node itself, capped at 1536 px.
Outputs: mask (your formula, one per image), cutout_rgba, mask_image (grey RGB, for nodes that want an IMAGE), segs and report, a per-word text breakdown with each region's share of the picture.
That segs output is the underrated bit: one run gives you every part as separate instances, so mask hands you skin while segs feeds hair, lips, top, bottom and shoes to Segs Compose and Segs Select. Do the expensive pass once.
Installing it
ComfyUI Manager, search NH-Nodes, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
python -m pip install -r requirements.txt
Models fetch themselves on first use from Hugging Face, pinned to fixed revisions: Sapiens2 at the size you picked plus the YuNet detector, into ComfyUI/models/NH-Nodes/. Interrupted downloads resume. Offline machines fail until a model is cached. Models on another drive? Add an nh_nodes key under extra_model_paths.yaml.
Where people get burned
PyTorch 2.4 or newer. The one hard dependency this adds over the rest of the pack. On an older install, that's your error.
A wrong word stops the node before the model loads. Ask for eyes, nose, ears or beard and it refuses with advice: those aren't Sapiens2 classes, eyes live inside face. Same for hat, bag, scarf, jewelry - there's one accessories class. Good errors, but they'll catch you out for a minute.
face is a bigger word than you think. It's one class with the neck, eyes, eyebrows and beard baked in, and skin contains it. So skin - face also removes the neck, and face - neck is empty. Eye-level precision is Portrait Segment's job, or subtract its parts with Segs Compose.
A dress counts as a top. One upper-body class means dress - top is empty and a dress's skirt is top, not bottom. Garment Segment is for garment-level decisions.
VRAM. Weights sit in system memory and move to the GPU only while the node runs. It keeps one size at a time - switching model_size drops the previous one. And if you see nonsense labels, a stray checkpoint is in one of the folders it searches; delete it and the right model re-downloads.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| regions | STRING | skin | Which parts, by name: skin, hair, face, arms, hands, legs, feet, torso, lips, teeth, glasses, clothes, top, bottom, shoes, upper arms, thighs, left hand, mouth, person... Vietnamese works too (da, tóc, mặt, môi, răng, tay, chân, áo, quần, giày). Combine like SAM3 Segment: clothes - shoes, hair + face, ~person, background. Commas list several. Left and right are the person's own sides; face includes the neck. |
| model_size | COMBO | 0.4b | Sapiens2 size: 0.4b (1.6 GB download, about 1.5 GB of VRAM) is fast and good; 0.8b (3.3 GB) and 1b (5.9 GB) are a little more precise, slower and need more VRAM. |
| mask_expand | INT | 0-64–64 | Grow (+) or shrink (-) the mask by N pixels. |
| mask_blur | INT | 00–64 | Feather the mask edge by N pixels. |
| fill_holes | BOOLEAN | false | Fill enclosed holes. |
| device | COMBO | cuda | 2 options: cuda, cpu |
| show_previewopt | BOOLEAN | true | Show the regions and the report on the node itself. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| cutout_rgba | IMAGE | — |
| mask_image | IMAGE | — |
| segs | NH_SEGS | — |
| report | STRING | — |