Nodes/ComfyUI-Apt_Preset/Mask_ClothesSegment
ComfyUI Node

Mask_ClothesSegment

Masking individual clothing items in ComfyUI

By cardenluo·Created 2 years ago·Updated 17 days ago· 309
Mask_ClothesSegment
  • images
  • IMAGE
  • MASK
Hatfalse
Hairfalse
Facefalse
Sunglassesfalse
Upper-clothesfalse
Skirtfalse
Dressfalse
Beltfalse
Pantsfalse
Left-armfalse
Right-armfalse
Left-legfalse
Right-legfalse
Bagfalse
Scarffalse
Left-shoefalse
Right-shoefalse
backgroundAlpha

Virtual try-on, outfit swaps, targeted clothing edits - all of these need a mask of just the shirt, or just the shoes, not the whole person. Mask_ClothesSegment is cardenluo's ComfyUI-Apt_Preset node for that job: a garment-parsing model exposed as a checklist of clothing categories.

What it does

Under the hood this wraps a SegFormer-based clothes-parsing model - the README points at 1038lab/segformer_clothes as the resource to download. You feed it an image and flip on whichever of seventeen categories you want in the output mask: Hat, Hair, Face, Sunglasses, Upper-clothes, Skirt, Dress, Belt, Pants, Left-arm, Right-arm, Left-leg, Right-leg, Bag, Scarf, Left-shoe, Right-shoe. Every toggle defaults to off - an unmodified run returns nothing selected - so you build up exactly the mask you need by combining categories, rather than getting a blanket "clothes" mask you then have to trim down.

Notice the taxonomy includes body parts (arms, legs, face, hair) alongside garments - that's normal for this class of parsing model, since accurately separating "sleeve" from "arm" requires knowing where the arm is in the first place, even if you only care about the sleeve.

Inputs and outputs

  • images - the input image (required).
  • Seventeen boolean toggles listed above, all optional, all default false.
  • background - fill for everything not selected: Alpha, white, black, green, red, blue, or gray.

Outputs: IMAGE (composited result with your background choice) and MASK (the combined selection). MASK is the one that typically matters - feed it to inpainting for a "change just this garment" edit, or to a compositing node for a virtual-try-on style swap.

Start with one category at a time (Upper-clothes alone, say) to confirm the segmentation is clean before combining several - a messy multi-category mask is much harder to debug than a single-category one.

Installing it

Through ComfyUI Manager: search ComfyUI-Apt_Preset. Manual install:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git

Run install.bat (Windows) or install requirements.txt yourself, restart ComfyUI.

This node needs a model the base install doesn't ship. Download 1038lab/segformer_clothes from the README's links (or the pack's bundled resource pack) and place it at:

ComfyUI/models/Apt_File/segformer_clothes

Skip this step and the node will have nothing to load at inference time.

Troubleshooting

If Mask_ClothesSegment doesn't appear in your node list at all, check for a pack-level import failure before anything else - ComfyUI-Apt_Preset is a big pack with a documented IMPORT FAILED report from at least one user; the ComfyUI startup console will show the real missing-dependency error if that's what's happening.

If the node's present but errors at run time, the Apt_File/segformer_clothes folder is the first thing to verify - this is an external download, not something that installs automatically. And if your mask includes more than you expected, remember the taxonomy overlaps: Upper-clothes and Left-arm/Right-arm are separate categories, so a sleeve that looks like it should be "clothes" might actually be classified as arm depending on how much skin is visible - toggle both if you want full sleeve-to-hand coverage on a short-sleeved subject.

CategoryApt_Preset/mask

Inputs (19)

NameTypeDefaultDescription
imagesIMAGE
HatoptBOOLEANfalse
HairoptBOOLEANfalse
FaceoptBOOLEANfalse
SunglassesoptBOOLEANfalse
Upper-clothesoptBOOLEANfalse
SkirtoptBOOLEANfalse
DressoptBOOLEANfalse
BeltoptBOOLEANfalse
PantsoptBOOLEANfalse
Left-armoptBOOLEANfalse
Right-armoptBOOLEANfalse
Left-legoptBOOLEANfalse
Right-legoptBOOLEANfalse
BagoptBOOLEANfalse
ScarfoptBOOLEANfalse
Left-shoeoptBOOLEANfalse
Right-shoeoptBOOLEANfalse
backgroundoptCOMBOAlpha7 options: Alpha, white, black, green, red, blue, +1

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK