Nodes/ComfyUI-CustomNodePacks/Semantic Segment — Face / Clothes Parsing
ComfyUI Node

Semantic Segment — Face / Clothes Parsing

SegFormer face and clothes parsing

By Code2Collapse·Created 6 months ago·Updated a day ago· 52
Semantic Segment — Face / Clothes Parsing
  • image
  • mask
  • info
model_namesegformer_clothes
classes_csvskin,hair
threshold0.50
invertfalse
keep_model_loadedtrue

SAM is great, but SAM needs a prompt - a point, a box, a text phrase - and it'll hand you three candidate masks and ask which one you meant. SemanticSegmentMEC takes a totally different route: you name the thing. Type skin,hair into classes_csv, hit queue, and out comes a binary mask covering exactly those semantic classes. It's face and clothes parsing via SegFormer, and for portrait work it's often the least-effort path to a mask in the whole ComfyUI-CustomNodePacks pack.

This is the node for the "isolate the subject's skin for a selective grade" or "mask the shirt so I can re-texture it" jobs. It's one of the few genuinely model-based nodes among the ones covered here, so it has real dependencies - but they're the auto-downloading kind.

How it works

The node runs one of two SegFormer segmentation models, both pulled from HuggingFace on first use:

  • segformer_face (jonathandinu/face-parsing) - 19 classes of facial anatomy: skin, l_brow, r_brow, l_eye, r_eye, eye_g (glasses), ears, nose, mouth, u_lip, l_lip, neck, necklace, cloth, hair, hat.
  • segformer_clothes (mattmdjaga/segformer_b2_clothes) - 18 classes of apparel and body: upper_clothes, skirt, pants, dress, belt, left_shoe, right_shoe, left_leg, right_leg, left_arm, right_arm, bag, scarf, plus face and hair.

Every pixel gets a class, you pick which classes to include, and the node merges them into one binary mask. Each run processes the full batch, so you get per-frame masks on video, too.

Inputs and outputs that matter

  • image (IMAGE) - what to parse.
  • model_name - segformer_face or segformer_clothes. The class list you can use depends on which you pick, and the tooltip carries the full class lists.
  • classes_csv (STRING, default "skin,hair") - the classes to include, comma-separated. The default is a sensible portrait start.
  • threshold (FLOAT, default 0.5) - confidence cutoff for class assignment.
  • invert (BOOLEAN) - flip the output mask (keep everything except your classes).
  • keep_model_loaded (BOOLEAN, default true) - keep the model in VRAM between runs; turn off to free memory if you're juggling other models.

Outputs:

  • mask (MASK) - the combined binary mask.
  • info (STRING) - JSON with the model, classes used, and per-class pixel counts. The pixel counts are genuinely handy for sanity-checking whether a class matched at all.

Installing it

This node needs the model stack, so the pack's full install story applies:

cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git
pip install transformers pillow   # needed for SegFormer

then restart ComfyUI (or use Manager → "CustomNodePacks"). The SegFormer weights (~400 MB) auto-download from HuggingFace on first use, so no manual model placement - just a working internet connection the first time you run it. For the pack's other requirements (opencv-python, scipy, safetensors), comment out anything ComfyUI already bundles before installing, to avoid clobbering its torch/numpy.

Where it beats the alternatives - and where it doesn't

It beats SAM when your target is a semantic category, because there's no prompting to get wrong. It beats background-removal nodes when you want to keep the background but drop the clothes. Where it falls down is fine anatomy - the 19 face classes aren't going to separate individual teeth - and non-human subjects, where neither model knows what it's looking at. Use it as the quick pass, then refine edges with the pack's matting or ViTMatte nodes if you need compositing-grade alpha.

CategoryC2C/Segmentation

Inputs (6)

NameTypeDefaultDescription
imageIMAGEInput image(s) to parse.
model_nameCOMBOsegformer_clothessegformer_face: 19-class facial parts. segformer_clothes: 18-class apparel.
classes_csvSTRINGskin,hairComma-separated class names to include in mask. Face: skin, l_brow, r_brow, l_eye, r_eye, eye_g, l_ear, r_ear, ear_r, nose, mouth, u_lip, l_lip, neck, necklace, cloth, hair, hat Clothes: hat, hair, sunglasses, upper_clothes, skirt, pants, dress, belt, left_shoe, right_shoe, face, left_leg, right_leg, left_arm, right_arm, bag, scarf
thresholdFLOAT0.500–1Confidence threshold for class assignment.
invertBOOLEANfalseInvert the output mask.
keep_model_loadedoptBOOLEANtrueKeep model in VRAM between runs.

Outputs (2)

NameTypeDescription
maskMASKCombined binary mask covering all selected semantic classes.
infoSTRINGJSON summary of model, classes used, and per-class pixel counts.