Nodes/comfyui_face_parsing/MaskInsertWithBBox(FaceParsing)
ComfyUI Node

MaskInsertWithBBox(FaceParsing)

Paste a cropped mask back at full scale

By Ryuukeisyou·Created 3 years ago·Updated about a year ago· 193
MaskInsertWithBBox(FaceParsing)
  • bbox
  • image_src
  • mask
  • MASK

This is the "put it back" node. If MaskCropWithBBox is how you zoom into a face, MaskInsertWithBBox is how you zoom back out - it takes a small mask (sized to a face crop) and pastes it into a full-size canvas at the exact position the bbox says it belongs, everywhere else filled in as empty. Without this step, every mask this pack produces stays trapped in crop coordinates and can't be composited against your original image at all.

Why you need this step

Face parsing, by design, works small. The README is explicit that running the segmentation model on a tight face crop - not the whole frame - is what makes the output accurate, which is why the pack runs a YOLOv8 face detector first to find and isolate the face before parsing it. Great for accuracy, but it means every mask that comes out of the parsing model is sized to that crop: a few hundred pixels, positioned nowhere in particular relative to your actual canvas.

That's fine right up until you want to use the result - composite a "skin" mask back onto the full portrait for a targeted color correction, feed a full-image mask into inpainting, or hand a finished mask to something downstream that expects it to line up with the original picture pixel-for-pixel. MaskInsertWithBBox is the node that closes that loop: give it the bbox that located the face, the source image (purely to know the target canvas dimensions), and your small cropped mask, and it hands back a mask the same size as your original image, with the cropped mask dropped in at the right spot and zeros everywhere else.

The three inputs and the one output

  • bbox - where the crop came from. This has to be the same bbox used to produce the crop the mask was generated against, or the insert lands in the wrong place.
  • image_src - the source image. It isn't blended into the output; it's there purely so the node knows what canvas size to build. Wire in the original full-resolution image, not the crop.
  • mask - the small, crop-sized mask you're inserting. Usually this has already been through a few operations in this pack - parsed, composited, feathered - before it gets here.

Output is a single MASK, full canvas size. From here it typically goes to MaskComposite (to merge with something else at full scale), straight into a sampler's masked-conditioning input, or to an ImageCompositeMasked-style node to paste generated content back onto the original.

Installing it

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

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

Restart ComfyUI. First run downloads the face-parsing weights to models/face_parsing/ and the YOLOv8 face model to models/ultralytics/bbox - both sourced from HuggingFace (jonathandinu/face-parsing and Bingsu/adetailer respectively), with manual-download instructions in the README if that connection is unreliable for you.

Common trip-ups

Same family of bug as its sibling MaskCropWithBBox: this node is only correct if bbox, image_src, and mask all agree with each other. Feed it a bbox from a different detection pass than the one that produced your crop, or an image_src that isn't actually your original full-resolution image, and you'll get a mask that's the right size but positioned wrong - the face-shaped blob shows up in the wrong part of the frame, or gets clipped at the canvas edge. In a graph with several crop/parse/insert cycles this is easy to get backwards, since bboxes and masks don't carry a visible label telling you which stage they came from. If your final composite looks offset, work backwards from this node first - check that the bbox and image_src you're feeding it actually match the crop the mask was built from - before assuming the parsing model itself did something wrong.

Categoryface_parsing

Inputs (3)

NameTypeDefaultDescription
bboxBBOX
image_srcIMAGE
maskMASK

Outputs (1)

NameTypeDescription
MASKMASK