Mask from FaceModel
Turn a Reactor face model into a mask of the lower face
- image
- faceanalysis
- face_model
- mask
- genders
If you're running a Reactor-based face-swap pipeline, you already have a detected face model floating around your graph - Reactor needs one to know where and what to swap. MaskFromFaceModel takes that same detection and turns it into an actual mask: the lower-face region, below the eyes, excluding the forehead. Instead of running a second, separate face-detection pass just to get a mask, you reuse the detection you already paid for.
What it's for
The obvious pairing is inpaint or attention masking around a face-swap result - mask exactly the region Reactor touched so a follow-up pass (a detail fix, a blend correction, a targeted re-generation) only affects that area and leaves hair, forehead, and background alone. Because it works directly off the face model rather than re-running its own detection, it stays consistent with whatever Reactor already decided the face region is, instead of potentially disagreeing with it.
How it works
It reads the geometry out of a FACE_MODEL (or FACEANALYSIS) object - the same face-embedding/landmark data Reactor's own face-swap node produces and consumes - and rasterizes it into a mask covering the lower face: below the eyes, forehead deliberately excluded. The README is upfront that this is a functional trade-off, not a bug: enabling add_bbox_upper_points extends the mask upward using a rough bounding-box approximation, but it's explicitly described as imprecise. If your use case genuinely needs the forehead included with any accuracy, this node says plainly you're better off with a different mask source.
The inputs and outputs that matter
image(IMAGE) - the image to generate the mask against.max_face_number(default -1, meaning no limit, up to 99) - caps how many detected faces get masked, if the image has more than one.add_bbox_upper_points(default false) - the forehead-extension approximation described above. Off by default for a reason; the README calls out its imprecision itself.faceanalysis/face_model(optional) - feed in whichever face-detection object your Reactor pipeline is already producing.cant_detect_mask_mode(black/white/none, defaultblack) - what happens when no face is found: return an empty (black) mask, a fully-covering (white) mask, or skip cleanly.face_confidence(default 0.75, 0–1) - the minimum detection confidence before a face counts.
Outputs: mask (MASK) and genders (STRING) - a detected-gender readout per face, which ties into this same pack's other gender-conditional nodes (ModifyTextGender, GenderControlOutput) if you're chaining prompt adjustments based on who's actually in frame.
How to install it
Via ComfyUI Manager: search "ComfyUI-utils-nodes," install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/zhangp365/ComfyUI-utils-nodes
Restart ComfyUI. This specific node has no extra install steps of its own - but it's only useful alongside a Reactor-style face-swap node pack, which you'll need installed separately to actually produce the FACE_MODEL input. (Don't confuse this with the pack's other face-related node, the DeepFace attribute analyzer - that one needs TensorFlow installed manually per the README's own warning. This node doesn't touch TensorFlow at all.)
Common issues & troubleshooting
The dependency chain worth knowing about: Reactor-style face swapping runs on InsightFace under the hood for detection and embeddings, and InsightFace's code is MIT but its pretrained face models ship under non-commercial research terms - a licensing detail that trips up a lot of people building anything they intend to sell, since it's easy to read "MIT" and stop there. Worth knowing before you build a commercial pipeline around this mask, since the mask itself is only as available as the face model feeding it.
On the mask quality side: face_confidence set too low will happily mask a false-positive "face," and set too high will drop legitimate detections in poor lighting or profile shots - if faces are dropping out unexpectedly, that's the first knob to check before assuming Reactor's detection itself is broken. And remember the excluded forehead is deliberate, not a limitation to work around within this node - if you need full-face coverage, generate that mask elsewhere and treat this one as specifically the below-the-eyes region it's designed to be.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| max_face_number | INT | -1-1–99 | — |
| add_bbox_upper_points | BOOLEAN | false | — |
| faceanalysisopt | FACEANALYSIS | — | |
| face_modelopt | FACE_MODEL | — | |
| cant_detect_mask_modeopt | COMBO | black | 3 options: black, white, none |
| enabledopt | BOOLEAN | true | — |
| face_confidenceopt | FLOAT | 0.750–1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| genders | STRING | — |