Nodes/Human Parts Detector/đź§Ť Human Parts mask generator
ComfyUI Node

đź§Ť Human Parts mask generator

Build a clothing-aware mask in one node, no ML degree required

By metal3d·Created 2 years ago·Updated about a year ago· 42
đź§Ť Human Parts mask generator
  • image
  • mask
â—„backgroundfalseâ–ş
â—„hatfalseâ–ş
â—„hairfalseâ–ş
â—„glovefalseâ–ş
â—„glassesfalseâ–ş
â—„upper_clothesfalseâ–ş
â—„face_maskfalseâ–ş
â—„coatfalseâ–ş
â—„socksfalseâ–ş
â—„pantsfalseâ–ş
â—„torso-skinfalseâ–ş
â—„scarffalseâ–ş
â—„skirtfalseâ–ş
â—„facefalseâ–ş
â—„left-armfalseâ–ş
â—„right-armfalseâ–ş
â—„left-legfalseâ–ş
â—„right-legfalseâ–ş
â—„left-shoefalseâ–ş
â—„right-shoefalseâ–ş
â—„bagfalseâ–ş

Want to swap just the pants on a character without touching the shirt? Or mask the hair so you can regenerate only that, leaving the face alone? Normally you'd hand-paint a mask or ask a background-remover for a blob that includes the whole person. This node is the shortcut: feed it an image, tick the parts you care about, and get back a ready-to-use MASK with exactly those pixels - hair, face, pants, shoes, even a bag - as cleanly separated as the model can manage.

It's a small, quiet pack (23 Google impressions says almost nobody has found it yet), and that's a shame, because there isn't much competition. Most segmentation in the ComfyUI ecosystem leans on background removal - BiRefNet and friends - which solves "subject vs. background," not "shirt vs. pants vs. skin." Human Parts is one of the few nodes that does clothing and body-part parsing at all.

How it works

Under the hood it's the Keras-io DeepLabV3+ with a ResNet50 backbone - a semantic-segmentation model trained on the CCIHP (Crowd Instance-level Human Parsing) dataset - converted from Keras to ONNX by the pack's author, because the original was stuck on an old Keras version with no PyTorch port. The model card is CC1.0-licensed, so no license drama.

The pipeline is straightforward: your image is resized to 512Ă—512, normalized to the [-1, 1] range, pushed through the ONNX model, and every pixel gets labeled with one of 21 classes (background, hat, hair, face, upper_clothes, coat, pants, skirt, left/right arm, left/right leg, and so on). The node then takes whichever classes you enabled, paints those pixels white, everything else black, and upscales the result back to your original resolution. Output is a single binary MASK.

Two honest caveats from the code and the author. First, the model runs at 512Ă—512 internally, so fine edges - individual strands of hair, thin straps - come out chunky. It's a parsing mask, not a matting mask; if you need clean cutouts with fractional alpha, reach for a background-removal node instead. Second, the author's own comment notes the model struggles with casual or rotated poses; it wants a roughly upright person.

The inputs that matter

You get an image input plus 21 boolean toggles, one per class, all defaulting to off. Enable the parts you want in the mask:

  • The clothing/skin classes you'll actually tick: hair, face, pants, upper_clothes, coat, skirt, left-arm/right-arm (naked arm), left-leg/right-leg (naked leg), left-shoe/right-shoe, hat, glasses, socks, scarf, glove, face_mask, bag, torso-skin
  • background - include everything that isn't the person, i.e. the inverse of a cutout

Since it's one mask out, tick all the parts you want combined in a single mask. Want "everything except the background"? Leave background off and enable every body part. The tooltips on each toggle are the author's own class descriptions, and they're actually useful - pants explicitly covers "pants, shorts, tights, leggings, swimsuit bottoms (clothing with 2 legs)," so you know exactly what you're getting.

The single output is mask (type MASK) - wire it straight into any inpainting, compositing, or ControlNet-preprocessor slot that takes a mask. For separate masks per part, drop in multiple instances of the node and tick different classes on each.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/metal3d/ComfyUI_Human_Parts.git
cd ComfyUI_Human_Parts
python -m pip install -r requirements.txt
python install.py

Then restart ComfyUI and refresh. There's a [tool.comfy] block in the pyproject now, so ComfyUI Manager's "Install from Git URL" should work too - the README still warns the pack wasn't validated in the Manager index, so if it doesn't show up in search, do it manually.

Three things trip people up. python install.py is not optional - that's what downloads the ~model to ComfyUI/models/onnx/human-parts/deeplabv3p-resnet50-human.onnx from the author's HuggingFace repo. Skip it and the node errors out at runtime. Use your ComfyUI virtualenv - the README shouts this at you for a reason; the requirements.txt is tiny (onnxruntime, numpy, Pillow) but it needs to land in the env ComfyUI runs in. And note the node loads the ONNX session fresh on every single call - it's not cached between runs - so don't chain dozens of them and expect no overhead. For a node this niche, that's fine. It's also CPU-friendly thanks to ONNX, so it'll run on laptops without a GPU.

It's a narrow tool, but when you need "a mask of exactly the pants, nothing else," it's the fastest honest way to get one.

CategoryMetal3d

Inputs (22)

NameTypeDefaultDescription
imageIMAGEThe image in which to detect human parts
backgroundBOOLEANfalseBackground
hatBOOLEANfalseHat: Hat, helmet, cap, hood, veil, headscarf, part covering the skull and hair of a hood/balaclava, crown…
hairBOOLEANfalseHair
gloveBOOLEANfalseGlove
glassesBOOLEANfalseSunglasses/Glasses: Sunglasses, eyewear, protective glasses…
upper_clothesBOOLEANfalseUpperClothes: T-shirt, shirt, tank top, sweater under a coat, top of a dress…
face_maskBOOLEANfalseFace Mask: Protective mask, surgical mask, carnival mask, facial part of a balaclava, visor of a helmet…
coatBOOLEANfalseCoat: Coat, jacket worn without anything on it, vest with nothing on it, a sweater with nothing on it…
socksBOOLEANfalseSocks
pantsBOOLEANfalsePants: Pants, shorts, tights, leggings, swimsuit bottoms… (clothing with 2 legs)
torso-skinBOOLEANfalseTorso-skin
scarfBOOLEANfalseScarf: Scarf, bow tie, tie…
skirtBOOLEANfalseSkirt: Skirt, kilt, bottom of a dress…
faceBOOLEANfalseFace
left-armBOOLEANfalseLeft-arm (naked part)
right-armBOOLEANfalseRight-arm (naked part)
left-legBOOLEANfalseLeft-leg (naked part)
right-legBOOLEANfalseRight-leg (naked part)
left-shoeBOOLEANfalseLeft-shoe
right-shoeBOOLEANfalseRight-shoe
bagBOOLEANfalseBag: Backpack, shoulder bag, fanny pack… (bag carried on oneself

Outputs (1)

NameTypeDescription
maskMASK—