Nodes/ComfyUI Layer Style/LayerMask: Segformer Clothes Pipeline
ComfyUI Node Runs on cloud

LayerMask: Segformer Clothes Pipeline

SegformerClothesPipelineLoader — load the clothes-segmentation model once, reuse it

By chflame163·Created 3 years ago·Updated 5 days ago· 3,113
LayerMask: Segformer Clothes Pipeline
    • segformer_pipeline
    ◄model▾►
    â—„facefalseâ–º
    â—„hairfalseâ–º
    â—„hatfalseâ–º
    â—„sunglassfalseâ–º
    â—„left_armfalseâ–º
    â—„right_armfalseâ–º
    â—„left_legfalseâ–º
    â—„right_legfalseâ–º
    â—„left_shoefalseâ–º
    â—„right_shoefalseâ–º
    â—„upper_clothesfalseâ–º
    â—„skirtfalseâ–º
    â—„pantsfalseâ–º
    â—„dressfalseâ–º
    â—„beltfalseâ–º
    â—„bagfalseâ–º
    â—„scarffalseâ–º

    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_clothes or segformer_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.

    Category😺dzNodes/LayerMask

    Inputs (18)

    NameTypeDefaultDescription
    modelCOMBO2 options: segformer_b3_clothes, segformer_b2_clothes
    faceBOOLEANfalse—
    hairBOOLEANfalse—
    hatBOOLEANfalse—
    sunglassBOOLEANfalse—
    left_armBOOLEANfalse—
    right_armBOOLEANfalse—
    left_legBOOLEANfalse—
    right_legBOOLEANfalse—
    left_shoeBOOLEANfalse—
    right_shoeBOOLEANfalse—
    upper_clothesBOOLEANfalse—
    skirtBOOLEANfalse—
    pantsBOOLEANfalse—
    dressBOOLEANfalse—
    beltBOOLEANfalse—
    bagBOOLEANfalse—
    scarfBOOLEANfalse—

    Outputs (1)

    NameTypeDescription
    segformer_pipelineSegPipeline—