Nodes/ComfyUI/Draw Face Mask (MediaPipe)
ComfyUI Node Runs on cloud

Draw Face Mask (MediaPipe)

Face, lips, or eye masks from landmarks — the detail pass starts here

By Comfy-Org·Created 4 years ago·Updated 20 days ago· 121,575
Draw Face Mask (MediaPipe)
  • face_landmarks
  • MASK
regions

Once MediaPipe has dropped landmarks on a face, you can do a lot more with them than stare at a wireframe. This node turns those landmarks into actual MASK tensors - filled polygons you can feed straight into inpainting, a face detailer, or a regional-edit workflow. It's the bridge between "the model found the face" and "only the face gets regenerated," and it's the node that makes the classic detect-crop-refine detail loop fully native in ComfyUI.

The use case that pays for the whole setup: a face that occupies a tiny corner of a big image always comes out soft, because it gets a tiny fraction of the model's attention. The fix - the same one Impact Pack's FaceDetailer made famous - is to isolate the face, regenerate it at proper resolution, and paste it back. This node produces the mask that makes that isolation possible, and because MediaPipe is Apache 2.0, the whole pipeline stays commercially clean.

How it works

The landmark set includes a bunch of closed contours - the face oval, the lips (two loops: outer and inner), each eye, the irises. The node walks those connection loops from the landmark data, and for every face in the frame it fills each selected contour as a polygon on a mask canvas. Faces in the same frame union together into one mask per frame. What you get out is a clean binary mask at the image's full resolution.

The inputs and outputs that matter

  • face_landmarks - from MediaPipeFaceLandmarker. Required.
  • regions - the interesting one. all unions the face oval, lips, eyes and irises - which, as the tooltip cheerfully admits, collapses to the face oval anyway, since the oval encloses everything else. custom lets you toggle each region individually, and that's where this node earns its keep: a lips-only mask for a smile edit, lips+eyes for makeup retouching, left_eye only for a lazy-eye fix.

The MASK output is one mask per input frame, standard ComfyUI type - into Set Latent Noise Mask for inpainting, a crop node for detailing, or a mask-dilate node if you want the region padded before generation.

The catches

First, the mask hugs the landmarks - no feathering, no padding. A mask that exactly outlines the lips produces hard edges that inpainting will show as seams; run it through mask-blur or dilate (or pad the crop in your detailer) or you'll see the boundary. Second, region quality is inherited: if MediaPipeFaceLandmarker struggled with a profile view, the lip contour will be the weakest part of the mask. And one more conceptual note - for the "detail the whole face" case, remember the oval is the whole face; you don't need all for that, and custom-region mode is where the genuinely different results live.

If all you want is to see the landmarks rather than edit by them, use MediaPipeFaceMeshVisualize instead - this node's whole job is producing a mask someone else acts on.

Categoryimage/detection

Inputs (2)

NameTypeDefaultDescription
face_landmarksFACE_LANDMARKS
regionsCOMBO'all' = union of face_oval+lips+eyes+irises (which collapses to face_oval since it encloses the rest). 'custom' = toggle each region individually for combos like lips+eyes.

Outputs (1)

NameTypeDescription
MASKMASK