Nodes/ComfyUI-Apt_Preset/Mask_BodySegment
ComfyUI Node

Mask_BodySegment

Human body-part masking in ComfyUI

By cardenluo·Created 2 years ago·Updated 17 days ago· 309
Mask_BodySegment
  • images
  • IMAGE
  • MASK
Hairfalse
Glassesfalse
Top-clothesfalse
Bottom-clothesfalse
Torso-skinfalse
Facefalse
Left-armfalse
Right-armfalse
Left-legfalse
Right-legfalse
Left-footfalse
Right-footfalse
backgroundAlpha

Most background-removal nodes give you one mask: subject versus everything else. Mask_BodySegment goes finer than that - it gives you a mask for specific body parts, so you can isolate just the arms, just the hair, or just torso skin without also pulling in the face or clothes.

What it does

This node from cardenluo's ComfyUI-Apt_Preset wraps a human-parsing model - specifically Metal3d/deeplabv3p-resnet50-human per the pack's README - and exposes its output classes as individual toggles. Feed it an image, flip on the body regions you want (Hair, Glasses, Top-clothes, Bottom-clothes, Torso-skin, Face, Left-arm, Right-arm, Left-leg, Right-leg, Left-foot, Right-foot), and it returns a combined mask covering only those regions. Every toggle defaults to off, so an unmodified run gives you an all-background result - you have to actively pick what you want included.

This is the same broad family of tooling as the well-known SAM/segmentation stack covered in background-removal circles, but purpose-built for a fixed, named taxonomy of body regions rather than an open-ended point-or-text prompt - closer in spirit to a semantic segmentation model like DeepLabV3 than to a promptable model like SAM.

Inputs and outputs

  • images - the input image (required).
  • Twelve boolean toggles - Hair, Glasses, Top-clothes, Bottom-clothes, Torso-skin, Face, Left-arm, Right-arm, Left-leg, Right-leg, Left-foot, Right-foot - all optional, all default false.
  • background - what fills the non-selected area: Alpha (transparent), white, black, green, red, blue, or gray.

Outputs: IMAGE (the source with the background replaced per your setting) and MASK (the combined mask of everything you toggled on). Wire MASK into inpainting, compositing, or a targeted LoRA/ControlNet region; wire IMAGE straight to Preview or Save if you just want the cutout.

For a first run, Alpha background plus one or two toggles (say Torso-skin and Face) is the easiest way to confirm the model is segmenting correctly before combining more regions.

Installing it

Through ComfyUI Manager: search ComfyUI-Apt_Preset. Manually:

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

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

This node needs a model file the base install doesn't include. Per the README, download the body-segmentation model from Metal3d/deeplabv3p-resnet50-human (or the pack's bundled resource pack, linked in the README, if you'd rather grab everything at once) and place it under:

ComfyUI/models/Apt_File/body_segment

Without that folder populated, expect this node to error out or fail to find a model at runtime - it isn't something ComfyUI Manager pulls in automatically for you.

Troubleshooting

If the node itself is missing from your search, check for a pack-wide import failure first - ComfyUI-Apt_Preset is large, and there's a documented case of it throwing IMPORT FAILED for a user; check the ComfyUI console at startup for the real error.

If the node loads but errors when you run it, the Apt_File/body_segment folder is the first thing to check - a missing or misplaced model file is the most likely cause given this dependency isn't bundled. If your output mask looks noisy or includes regions you didn't toggle, double-check you didn't accidentally leave an extra box checked - since every toggle defaults off, an unexpectedly broad mask usually means more boxes are ticked than you intended, not a model failure.

CategoryApt_Preset/mask

Inputs (14)

NameTypeDefaultDescription
imagesIMAGE
HairoptBOOLEANfalse
GlassesoptBOOLEANfalse
Top-clothesoptBOOLEANfalse
Bottom-clothesoptBOOLEANfalse
Torso-skinoptBOOLEANfalse
FaceoptBOOLEANfalse
Left-armoptBOOLEANfalse
Right-armoptBOOLEANfalse
Left-legoptBOOLEANfalse
Right-legoptBOOLEANfalse
Left-footoptBOOLEANfalse
Right-footoptBOOLEANfalse
backgroundoptCOMBOAlpha7 options: Alpha, white, black, green, red, blue, +1

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK