😺NKD Face Mask
A face mask from landmarks, no segmentation model, no extra download
- image
- mask
Sometimes you don't want to crop the face at all - you just want a mask of it, in the image's own coordinates, so you can inpaint the face in place without touching anything else. That's the entire job of 😺NKD Face Mask, and it's the same landmark-based mask machine as the other face nodes in this pack, served without the crop-and-stitch ceremony.
The pitch is simple: no segmentation model, no extra download. The mask is drawn from the facial landmarks the detector finds, filled in - the same landmarks 😺NKD Face Rig uses. "Fill the polygon from the landmarks" is a much cheaper operation than running a segmentation network, and it's instant.
What you set
image- the picture with the face in it. It finds the face wherever it is; a head that's a small part of a wide shot works the same as a headshot.mask_region- what the mask covers.faceis the whole head area;face without featuresleaves the eyes and mouth out of it;skinalso leaves the eyebrows;featuresis only the eyes, brows and mouth;nonereturns an empty mask. Thefeaturesoption is genuinely useful for expression-targeted work - you get a mask that covers exactly the parts an expression pass should touch.forehead- how far above the eyebrows the mask reaches. The landmarks stop at the brow, so this is an estimate: 1.0 lands near the hairline on most faces, higher takes in more scalp.refine_edges- lets the picture decide the last few pixels of the outline so it follows hair and jaw rather than cutting across them. Slower, and it can't see through anything held in front of the face.feather- softens the mask edge, in pixels. This is the one you'll tune most in practice: a hard landmark polygon edge shows in a composite, and 4–12 px of feather is the standard fix.expand- grows (or shrinks, when negative) the mask before feathering.
The two knobs I'd call beginner-relevant are mask_region and feather. The rest you set once and leave alone. padding and face_index exist but only affect finding the face - padding frames the search area, and face_index picks which face when there's more than one (0 = the surest).
Output is a single mask, ready to feed any inpaint, detailer, or compositing node.
Install and gotchas
Install via ComfyUI Manager (search ComfyUI-NKD-Basic-Tools) or:
cd ComfyUI/custom_nodes
git clone https://github.com/Nekodificador/ComfyUI-NKD-Basic-Tools
Restart after. Requires onnxruntime (a pack dependency); if it's missing, the face nodes are skipped at startup with a warning. The detector model (~232 KB YuNet, plus the ~10 MB landmark weights if you never use the rig) fetches itself on first use - that's the only download this node triggers, and it's tiny. Where people get caught: because the mask follows the landmark polygon rather than the hairline segmentation, refine_edges + a forehead bump is the way to stop the mask slicing through hair - leave both at defaults and you may find the mask cuts across a fringe it shouldn't.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| padding | FLOAT | 1.701–4 | How wide the face search frames the head while it looks. Only affects finding the face, not the mask. |
| face_index | INT | 00–64 | Which face to use when the picture has more than one, in order of how sure the detector is. 0 is the surest. |
| mask_region | COMBO | face | What the mask covers. 'face' is the whole head area, 'face without features' leaves the eyes and mouth out of it, 'skin' also leaves the eyebrows, 'features' is only the eyes, brows and mouth, and 'none' returns an empty mask. |
| forehead | FLOAT | 1.000–2 | How far above the eyebrows the mask reaches. The landmarks stop at the brow, so this is an estimate: 1.0 lands near the hairline on most faces, lower keeps the mask below it, higher takes in more scalp. |
| refine_edges | BOOLEAN | false | Let the picture decide the last few pixels of the outline instead of the polygon, so the edge follows hair and jaw rather than cutting across them. Slower, and it cannot see through anything held in front of the face. |
| feather | INT | 00–256 | Softens the mask edge, in pixels. |
| expand | INT | 0-256–256 | Grows (or shrinks, when negative) the mask before feathering, in pixels. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |