ComfyUI Node

FaceSkin PM

Get a clean face-skin mask with no hair, no ears, and no background

By THtianhao·Created 3 years ago·Updated 2 years ago· 201
FaceSkin PM
  • image
  • MASK
blur_edgefalse
blur_threshold32

If you've ever tried to mask a face in ComfyUI, you know the struggle: you end up with hair, neck, ears, and half the background glued to your selection. FaceSkin PM exists to fix exactly that. It extracts just the facial skin region - skin, brows, eyes, nose, lips - and hands you a clean, full-frame MASK you can composite with, inpaint into, or feed to the rest of the Portrait-Maker pack. It's the masking backbone the whole pack quietly leans on.

How it works

Two models cooperate, and neither is lightweight. RetinaFace (from ModelScope) finds the face and crops it, then a 19-class BiSeNet segmentation network - the same face-parsing architecture EasyPhoto used, shipped as face_skin.pth - classifies each pixel. The code keeps the face-relevant classes (skin, brows, eyes, nose, upper and lower lip), throws out hair, ears, neck, and clothing, then scales the small segmentation back up and pastes it into a full-frame mask at the correct position. So the MASK you get is aligned with your original image and ready to use directly.

Inputs that matter

  • image - the photo to mask.
  • blur_edge - boolean, default off. When enabled, the mask edges get blurred so composites don't show a hard seam.
  • blur_threshold - int, 0–64, default 32. The blur kernel size; only read when blur_edge is on. 32 is a strong feather, good for pasting; start lower if you want a tighter edge.

Output is a single MASK.

What you'd use it for

Everything that needs to touch only the face and nothing else: blending a retouched face over the original, restricting an inpaint or regeneration pass to skin, building a feathered composite for FaceShapMatch-style paste-backs. Because it's face-only, it's also the right region selector before skin retouching - you don't want a skin-smoothing pass eating your hair.

Gotchas

First run is slow: this node lazy-loads the RetinaFace detector from ModelScope on top of face_skin.pth, so the first execution can stall for a while as models download - that's normal, not a hang. If blur_edge seems to do nothing, check that you're looking at the MASK output through a previewer that actually shows blur on a hard alpha - a 32px box blur on a small mask can look surprisingly subtle. And remember the mask is face-skin only; if you want hair and shoulders included, that's what ExpandMaskBox PM or MaskDilateErode PM is for.

Installing it

Via ComfyUI Manager (search "ComfyUI-Portrait-Maker") or:

cd ComfyUI/custom_nodes
git clone https://github.com/THtianhao/ComfyUI-Portrait-Maker.git

Restart ComfyUI. On first startup the pack downloads roughly a dozen models with no hash verification, and this node additionally pulls RetinaFace from ModelScope when it first runs - don't interrupt either download, and if one breaks, delete the partial files and retry. Heavy dependencies come with the territory (modelscope, insightface, tensorflow, opencv, diffusers==0.18.2), and on Windows the pack needs Python 3.11 because it installs insightface from a prebuilt cp311 wheel.

Categoryprotrait/model

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
blur_edgeBOOLEANfalse
blur_thresholdINT320–64

Outputs (1)

NameTypeDescription
MASKMASK