ComfyUI Node Runs on cloud

Image Skin Mask

A body-part network that can tell a bare torso from a beige t-shirt

By WASasquatch·Created 4 years ago·Updated about 9 hours ago· 1,884
Image Skin Mask
  • image
  • mask
◄model▾►
◄areasall skin►
◄eyesremove with brows►
◄mouthremove inside►
◄tolerance1.00►
◄person_threshold0.40►

The clothing-label approach to skin masking is quick, but it has an obvious hole: ask it about a shirtless portrait and it can label the chest as "upper clothes", because that's what a garment model sees. This node replaces the labels with a body-part network - face and neck, torso, upper and lower arms, hands, legs, feet - plus lips, teeth and tongue as separate classes, so a bare torso is a part, not a guess.

What it's for

Anything where skin has to be handled separately from everything around it. Retouching texture without smearing hair. Grading skin while the background stays put. Inpainting a tattoo, a scar, a watermark on a shoulder. Feeding a detailer that only re-renders skin. Driven by a Sapiens2 segmentation network from models/sapiens, it holds up much better than the clothing model on unusual bodies, unusual poses, and anyone in swimwear.

How it works

Two passes, which is the interesting part. The whole picture is labelled at 1024px. Then each detected person gets a padded crop - 15% margin around their box - read at 768px, and those closer reads are weighted four times against the whole-frame labels with a feathered rim, so a small figure's hands and face don't dissolve into soup. Anyone whose box spans more than 60% of the frame is skipped in the crop pass, since a crop of them would be the frame anyway.

The 29 label channels include lips, upper and lower teeth, and tongue, which is why the mouth options here can do something the simple node can't: remove the lips as a separate decision from removing what's inside them.

Where boundary pixels fall between "clothing" and "skin", each person's own measured skin colour decides, same as the light version - that's what tolerance governs.

The inputs that matter

image - batch-safe; each picture is masked separately.

model - the Sapiens2 checkpoint from ComfyUI/models/sapiens. sapiens2_1b_seg is the default for a reason: roughly 3 GB of VRAM in bf16, sure of unusual bodies. 0.4b and 0.8b are lighter and less sure. 5b is about 10 GB of VRAM and earns it only on hard material.

areas, eyes, mouth - same menus as the light node, with mouth gaining real teeth/tongue separation. Defaults (all skin, remove with brows, remove inside) are the retouching set.

tolerance - 1.0 as measured; 0.7 when tan clothing gets caught; 1.5 for deep shadow.

person_threshold - default 0.4. Raise it to 0.7 for a clean, large subject and you'll skip background figures; unlike the simple node, if nobody is detected the whole picture still gets read.

Output is mask, at picture size, soft-edged. Inpaint encode, detailer, composite - whatever needs the region.

Installing it

Manager, search WAS Node Suite v3, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git

ComfyUI 0.14.0+, Python 3.10+, no pip packages. Models are the real install:

# either let the pack fetch them
#   features: network: true   in <ComfyUI user dir>/was-node-suite/config.yaml
# or drop the files in place yourself
#   sapiens2_1b_seg.safetensors  ->  ComfyUI/models/sapiens   (~5.9 GB)
#   ViTPose Wholebody            ->  ComfyUI/models/pose      (~97 MB)

The node ships behind the preprocessors config group, on by default. Press R in the browser after adding a checkpoint so the menu refreshes.

Where it goes wrong

put a sapiens2 seg checkpoint in models/sapiens. Nothing on disk and features.network is off - the pack's default. Either download from facebook/sapiens2-seg-1b or flip the network key.

is not a Sapiens2 body-part checkpoint. Sapiens2 ships several tasks: pose, normals, this. You want a file with _seg in the name.

An arm or torso comes out half masked. sapiens2_0.4b_seg is unsure of that body. Move up to 1b. That's the whole trade between the checkpoints.

It's slow on a batch. Every person is a separate 768px read, batched four at a time. Twenty frames of a crowded scene is a lot of inference. For a quick job, the simple node over a clothing model is genuinely the cheaper call; use this one when the torso matters.

CategoryWAS Suite/Image/Masking

Inputs (7)

NameTypeDefaultDescription
imageIMAGEThe pictures to find skin in; IMAGE. Each picture of a batch is masked on its own.
modelCOMBOBody-part network from ComfyUI/models/sapiens. `sapiens2_1b_seg` = sure of unusual bodies and poses, 3 GB of VRAM; `0.4b` and `0.8b` = lighter, less sure of them; `5b` = about 10 GB. Downloaded on first use.
areasCOMBOall skinWhich skin the mask keeps. 'all skin' = face and body; 'face' = from the jaw to the forehead; 'body' = everything below the jaw.
eyesCOMBOremove with brows'remove with brows' = cut out the eyes and the eyebrows; 'remove' = the eyes alone; 'keep' = leave both in the mask.
mouthCOMBOremove inside'remove inside' = cut out the teeth and tongue; 'remove lips' = the lips as well; 'keep' = leave the whole mouth in the mask.
toleranceFLOAT1.000.5–2How far a colour labelled as clothing may sit from each person's own skin and still count as skin. 1.0 = as measured; 1.5 = takes in deep shadow; 0.7 = stricter, for beige or tan clothing being caught.
person_thresholdFLOAT0.400.05–0.95How sure the person detector has to be. 0.4 = most people in a crowd; 0.7 = only clear, large figures. Each person found is read up close; with nobody found the whole picture is read.

Outputs (1)

NameTypeDescription
maskMASKThe skin; MASK at the picture's size with a soft edge. 1 = skin, 0 = everything else.