Nodes/ComfyUI-AIB/Auto Double Eyelid Mask
ComfyUI Node

Auto Double Eyelid Mask

Stop fighting the prompt for a double eyelid — this node draws the mask for you

By maweiqiang1978·Created 5 months ago·Updated 5 months ago· 0
Auto Double Eyelid Mask
  • image
  • left_eyelid_mask
  • right_eyelid_mask

Eyelid type is one of those details the prompt just won't hand you reliably. People have been fighting it for years - the classic r/StableDiffusion threads "How do get single eyelid" and "How to get 'Single Eyelid'?" are exactly this pain, with the accepted answer being "inpaint it." Adding or sharpening a double eyelid crease on an Asian face is the same fight in reverse, and inpainting needs a mask. Painting that crease by hand every time is fiddly. AutoDoubleEyelidMask is the first node from the small ComfyUI-AIB pack, and it exists to automate exactly that mask.

Feed it a face image and it returns two masks, one per eye, tracing the line where a double eyelid fold would sit. You wire those into an inpainting pass and the model does the rest. It's a niche beauty-retouch tool, so a warning up front: it's young (the pack's README calls it "not perfect yet, welcome corrections"), it's aimed squarely at portraits, and it will not rescue a side profile.

How it works

Under the hood it runs Google's MediaPipe Face Mesh - the same Apache-2.0 landmarking library that LivePortrait swapped in to escape InsightFace's licensing - with refine_landmarks=True, so it gets the fine eyelid iris landmarks rather than just the coarse face outline. Then it does the interesting part: instead of a learned model, it uses a hand-coded list of landmark indices, midpoints, and one-third-ratio points between specific landmarks to trace a polygon along where the crease should sit, and fills it white with cv2.fillPoly.

That means the mask is a solid, hard-edged filled shape, not a soft gradient. You'll want to feather it before it reaches a sampler or you'll get a visible seam - which is exactly the classic mask-blur mistake the inpainting docs hammer on.

Inputs and outputs

The whole interface is one input, two outputs:

  • image (IMAGE) - feed it a decoded face image (Load Image is fine; batch > 1 just uses the first frame).
  • left_eyelid_mask (MASK) - the crease region on the subject's left eye (their left, your right).
  • right_eyelid_mask (MASK) - the other eye.

Wire a mask into an inpainting setup - Set Latent Noise Mask, or an InpaintModelConditioning flow - and denoise low (0.3–0.5 range) so it just adds the crease rather than rebuilding the eye. Remember to composite the result back over the original so the rest of the face stays bit-identical.

Installing it

ComfyUI Manager is the easy path: search for ComfyUI-AIB and install. Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/maweiqiang1978/ComfyUI-AIB

then restart ComfyUI. Here's the gotcha: the repo ships no requirements.txt. It needs numpy, opencv-python, mediapipe, and torch - the README says it's tested on numpy 1.26.4, opencv 4.11.0.86, mediapipe 0.10.21, torch 2.10.0. Torch and numpy come with ComfyUI; mediapipe usually doesn't, and since there's no requirements file the Manager may not install it for you. If the node won't load with a ModuleNotFoundError: mediapipe, fix it directly:

pip install mediapipe

MediaPipe is version-sensitive about your Python build, so if that install balks, that's a Python-version mismatch, not a broken node.

Troubleshooting

  • Both masks come out black. No face was detected - the node runs max_num_faces=1 at 0.5 detection confidence and silently returns empty masks rather than erroring. Check your image actually has a detectable front-facing face.
  • Only one eye gets a good mask. It handles a single face; anyone else in frame is ignored, and extreme angles are MediaPipe's known weak spot.
  • The crease renders as a harsh line. Feather the mask (a few px of blur) before inpainting; the polygon edges are crisp by design.

For a first release it does one thing cleanly, and it's the right thing. If you're doing face beauty passes in ComfyUI, this is the fastest route from "prompt won't do it" to a usable inpaint mask.

CategoryAIB/Mask

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (2)

NameTypeDescription
left_eyelid_maskMASK
right_eyelid_maskMASK