SegformerNodeMasks
One mask per garment, no photoshop required
- image
- IMAGE
- MASK
- STRING
Where the plain SegformerNode gives you one big mask, SegformerNodeMasks splits the image into the individual segments the model found - separate masks for the shirt, the pants, the jacket, the skin. If you're doing outfit changes, relighting a specific garment, or just want to know exactly what SegFormer is seeing, this is the node you want. It's the "show your work" version of the flagship.
It lands in the same spot in your workflow as the main segmentation node: right after an image comes out of the sampler, before an inpainting pass. The difference is what you do with the output. A single merged mask is what you feed to SetLatentNoiseMask when you're regenerating one region. A set of individual masks is what you use when you want to touch the jacket without touching the shirt, or when you're checking whether the model is confusing your subject's legs with the background.
How it works
Under the hood it's the same SegFormer machinery as the rest of the pack: the image goes through the chosen checkpoint, and every pixel gets a class label. Where this node differs is bookkeeping - instead of collapsing those labels into one mask, it keeps each class's mask separate so you can pick and choose.
The inputs are exactly what you'd expect:
- image - the IMAGE you're segmenting.
- model_name - same ten HuggingFace checkpoints as SegformerNode, same default (
enes361/segformer_b2_clothes). The clothes model gives you garment-level masks; the human-parsing models give you body-part masks; the scene-parse model gives you... a scene. - segments_to_merge - a string, default
"0". This is the selector: which segment indices get merged together. It's where you'd put"1,2"to combine the upper and lower body into one mask, or"0"for a single segment. If you leave it at the default you get the first segment, so if you want something other than whatever segment 0 is, you need to check the STRING output first to see what the model actually found.
Outputs mirror the family pattern:
- IMAGE - visual preview of the masks so you can confirm the segmentation before trusting it.
- MASK - the mask (or merged mask) for the segment(s) you selected.
- STRING - the segment list with indices, which is your map for setting
segments_to_merge.
Where it fits
The realistic use: you run it, read the STRING output to see that "0 = upper body, 1 = lower body", then merge the ones you care about and wire the MASK into an inpainting model. It's a slightly manual dance - the segment indices are only discoverable at runtime - but it's the price of a tool that doesn't hardcode "the person's shirt is always class 3". The clothes and human-parsing checkpoints have consistent enough label schemes that after one run you'll know the mapping by heart.
Install and pitfalls
Same pack install as everything else in ComfyUI-LexTools: Manager → search "ComfyUI-LexTools", or git clone https://github.com/SOELexicon/ComfyUI-LexTools into custom_nodes and restart. transformers is the dependency that actually matters, and the model auto-downloads from HuggingFace on first run.
The trap worth knowing: segments_to_merge is an index string, not a label. Set it before you know the indices and you'll silently merge the wrong regions. Run once with the default, read the STRING output, then set the merge. And remember the model only knows the classes it was trained on - a clothes model has no "car" class, so don't expect scene-parse results from it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| segments_to_merge | STRING | 0 | — |
| model_name | COMBO | enes361/segformer_b2_clothes | 10 options: enes361/segformer_b2_clothes, mattmdjaga/segformer_b0_clothes, mattmdjaga/segformer_b2_clothes, DiTo97/binarization-segformer-b3, s3nh/SegFormer-b0-person-segmentation, venture361/clothes_segmentation, +4 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| STRING | STRING | — |