LayerMask: Segformer Clothes Pipeline
SegformerClothesPipelineLoader — load the clothes-segmentation model once, reuse it
- segformer_pipeline
This is the loader half of Layer Style's clothing-segmentation setup. Instead of an all-in-one node that reloads the model every time it runs, SegformerClothesPipelineLoader loads the SegFormer clothes-parsing model once, bakes in which body parts and garments you want to mask, and hands out a reusable pipeline object. You then feed that pipeline into an apply node. If you're segmenting clothes across a batch or in a graph you run over and over, this split saves you the model-load tax on every execution.
How it works
SegFormer, fine-tuned on a clothes-parsing dataset, labels every pixel of a person with a category - face, hair, upper clothes, skirt, pants, dress, and so on. This node's job is to set that model up: choose the weights, choose which labels get unioned into the mask, and emit a SegPipeline that carries the loaded model plus your part selection. Separating "load and configure" from "run on this image" is the standard pipeline pattern - the expensive load happens once, and the cheap apply happens per image.
The inputs and output that matter
model-segformer_b3_clothesorsegformer_b2_clothes. B3 is the larger, generally more accurate variant; B2 is lighter and faster. Both need to be present on disk (see below).- The part toggles -
face,hair,hat,sunglass,left_arm,right_arm,left_leg,right_leg,left_shoe,right_shoe,upper_clothes,skirt,pants,dress,belt,bag,scarf. All off by default; tick the ones you want combined into the eventual mask.
Output is segformer_pipeline of type SegPipeline - not an image. It only connects to the matching Segformer apply node in the pack, which runs the pipeline on an actual image and produces the mask.
How to install it
ComfyUI Manager: search ComfyUI Layer Style, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
install requirements.txt, restart. Node's under 😺dzNodes → LayerMask.
Common issues and troubleshooting
The recurring headache with every Segformer node - and there's a trail of forum threads on it - is the model not being downloaded. If loading errors with something like "Can't load image processor… make sure the path contains a preprocessor_config.json," the model files aren't where the node expects. The confirmed fix is to clone the weights into the pack's model folder by hand: git clone https://huggingface.co/mattmdjaga/segformer_b2_clothes (and the B3 equivalent if you selected that) into the checkpoints directory, then restart ComfyUI. Auto-download also fails behind a proxy or on a flaky connection, so the manual clone is the dependable route.
One design note worth understanding: this node outputs a pipeline, not a mask, so it's useless on its own - it must feed the apply node. If you just want a one-shot "mask these clothes" node with edge refinement built in, use SegformerB2ClothesUltra instead; reach for this loader when you want to load the model once and reuse it across a batch.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | 2 options: segformer_b3_clothes, segformer_b2_clothes | |
| face | BOOLEAN | false | — |
| hair | BOOLEAN | false | — |
| hat | BOOLEAN | false | — |
| sunglass | BOOLEAN | false | — |
| left_arm | BOOLEAN | false | — |
| right_arm | BOOLEAN | false | — |
| left_leg | BOOLEAN | false | — |
| right_leg | BOOLEAN | false | — |
| left_shoe | BOOLEAN | false | — |
| right_shoe | BOOLEAN | false | — |
| upper_clothes | BOOLEAN | false | — |
| skirt | BOOLEAN | false | — |
| pants | BOOLEAN | false | — |
| dress | BOOLEAN | false | — |
| belt | BOOLEAN | false | — |
| bag | BOOLEAN | false | — |
| scarf | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| segformer_pipeline | SegPipeline | — |