Nodes/comfyui_face_parsing/MaskComposite(FaceParsing)
ComfyUI Node

MaskComposite(FaceParsing)

Combine two masks with a boolean or arithmetic op

By Ryuukeisyou·Created 3 years ago·Updated about a year ago· 193
MaskComposite(FaceParsing)
  • destination
  • source
  • MASK
operation

Two masks in, one mask out, combined with whichever operation you pick from a dropdown. If you've used stock ComfyUI's built-in MaskComposite node before, this one will feel familiar - same idea, scoped to this pack's category - with one difference worth knowing up front: there's no x/y offset here. The stock node lets you paste a smaller mask onto a larger one at a chosen position; this one just combines two masks that are already the same size, aligned pixel-for-pixel. If you need to place one mask inside another at a specific coordinate, that's what MaskInsertWithBBox elsewhere in this pack is for - MaskComposite is purely about combining, not positioning.

Why you'd need this in a face-parsing workflow

The face-parsing model this pack is built around segments a face into classes - skin, eyes, nose, mouth, ears, hair, whatever you asked for - and depending on how you've set it up, you can end up with those as separate masks. Real work usually wants combinations of them, not one class in isolation. Want a mask for "the whole face minus the eyes," so you can relight or recolor skin without touching the eyeballs? Subtract the eye mask from the skin mask. Want "everything that isn't background"? Union (or/add) every foreground class together. Want the overlap between a hand-painted mask and a parsed region, to make sure you're only touching skin the user actually selected? Intersect (and). That's what this node is for - the boolean algebra layer sitting between "the model gave me six separate masks" and "I have the one mask my compositing step actually needs."

The inputs that matter

  • destination - the base mask.
  • source - the mask being combined into it.
  • operation - a dropdown with six choices: multiply, add, subtract, and, or, xor. add/or unions two regions together; multiply/and gives you the overlap; subtract removes the source region from the destination; xor keeps only the parts that are in one mask but not both. For combining semantic face regions, add (union) and subtract (exclude) cover the large majority of real cases - reach for and/multiply when you specifically need an intersection, and xor is the one you'll use least often.

Output is a single MASK, same dimensions as your inputs. From here it commonly feeds MaskBorderDissolve for edge feathering before a composite, or goes straight into MaskInsertWithBBox if you're working in crop coordinates and need to get back to full-image scale.

Installing the pack

ComfyUI Manager: search comfyui_face_parsing, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/Ryuukeisyou/comfyui_face_parsing.git

Restart. Model downloads (the segmentation model to models/face_parsing/, the YOLOv8 face detector to models/ultralytics/bbox) happen automatically on first use, sourced from jonathandinu/face-parsing and Bingsu/adetailer on HuggingFace - grab them by hand from the README's links if that connection is unreliable.

What actually goes wrong here

The two masks not being the same size is the classic failure - mix a mask that's still in face-crop coordinates with one that's already full-image size (say, you forgot a MaskInsertWithBBox step somewhere) and the composite either errors out or silently produces something spatially meaningless. Beyond that, the operation choice is the other place people get bitten: picking subtract when they meant xor, or and when they meant or, produces a mask that's technically valid - just empty, or the wrong shape - with nothing in the graph telling you which case you're in. When a composite comes out blank or way smaller than expected, preview both inputs separately before touching the operation dropdown; nine times out of ten one of the two masks isn't what you thought it was.

Categoryface_parsing

Inputs (3)

NameTypeDefaultDescription
destinationMASK
sourceMASK
operationCOMBO6 options: multiply, add, subtract, and, or, xor

Outputs (1)

NameTypeDescription
MASKMASK