Portrait Segment (NH)
A checklist of face parts instead of one blunt mask
- image
- mask
- cutout_rgba
- mask_image
Most face-segmentation nodes give you one mask: "here's the person." Portrait Segment (NH) gives you a checklist instead - face, neck, hair, eyes, lips, nose, eyebrows, ears, and even mouth interior, each a toggle, combined into one mask. It's the node you reach for when you want to change the hair without touching the skin, or repaint the lips without smearing the face, or mask "head and hair" and nothing else.
You feed it an image, tick the regions you want (all on by default except mouth_interior), and it runs a SegFormer model trained for face parsing, then unions the selected labels into a single mask. The outputs are mask (the MASK tensor for inpainting or conditioning), cutout_rgba (your input image with the mask as alpha - RGB outside the mask left intact), and mask_image (the mask rendered as an RGB preview you can look at). Three outputs, three different jobs, all from one run.
The controls that matter
The face toggle deserves a note: it's the solid face region including the features, so "face" on its own is the whole oval, eyes and lips included. Turn off face and leave lips on if you want strictly the mouth area. The shared refinement trio from the pack does the rest:
mask_expand- grow (+) or shrink (−) the mask by N pixels. Great for catching flyaway hair or tightening a sloppy edge.mask_blur- feather the mask edge by N pixels, which softens hard boundaries for natural inpaints.fill_holes- fills enclosed holes in the mask. On by default here (fine for a face); the garment node turns it off by default because an arm across a torso would get filled in.
There's also device (cuda/cpu) so you can push the inference to CPU on low-VRAM rigs - slower, but it works.
The model, and what it costs
Under the hood it's the jonathandinu/face-parsing SegFormer checkpoint, auto-downloaded to models/NH-Nodes/face_parsing on first use - roughly 340 MB. The download happens on the first run, not at install, so your first queue won't be instant. Nice detail from the source: the loader first probes folders other packs may already have filled (face_parsing, RMBG/segformer_face), so if you already own these weights, no re-download. The model runs at your input resolution and offloads from VRAM between runs, so it won't pin memory.
Install
It's in NH-Nodes:
- ComfyUI Manager → search NH-Nodes → install → restart ComfyUI. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Then restart ComfyUI.
Beyond the pack's requirements (transformers, onnxruntime, opencv-python, etc.), just the auto-downloaded model on first use.
Common issues
The first-run download is the usual surprise - wait for the console to show the model fetching, and it only happens once. If the mask looks coarse on tiny inputs, remember it's a SegFormer label map upscaled to your size; bigger source images give cleaner edges, and mask_expand/mask_blur cover the rest. And if cutout_rgba looks "wrong," check what you're viewing it with - the alpha is in the channel, not visible as a checkerboard in every preview. Pair the mask output with an inpaint or a mask-aware resize and you've got the heart of a hair-recolor or relight workflow.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| face | BOOLEAN | true | — |
| neck | BOOLEAN | true | — |
| hair | BOOLEAN | true | — |
| eyes | BOOLEAN | true | — |
| lips | BOOLEAN | true | — |
| nose | BOOLEAN | true | — |
| eyebrows | BOOLEAN | true | — |
| ears | BOOLEAN | true | — |
| mouth_interior | BOOLEAN | false | — |
| mask_expand | INT | 0-64–64 | Grow (+) or shrink (-) the mask by N pixels. |
| mask_blur | INT | 00–64 | Feather the mask edge by N pixels. |
| fill_holes | BOOLEAN | true | Fill enclosed holes. Off for garments by default: an arm across the torso would be filled in. |
| device | COMBO | cuda | 2 options: cuda, cpu |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| cutout_rgba | IMAGE | — |
| mask_image | IMAGE | — |