Nodes/ComfyUI_FaceAlignPaste/Face AutoFit Double @ CHAOS
ComfyUI Node

Face AutoFit Double @ CHAOS

The node that frames dialogue scenes

By CHAOSEA·Created about a year ago·Updated about a year ago· 24
Face AutoFit Double @ CHAOS
  • image_L
  • mask_L
  • image_R
  • mask_R
  • image
  • mask_L
  • mask_R
  • mask_combined
  • gender_L
  • gender_R
  • mode_code
modeportrait
backgroundwhite
move_L_x0
move_L_y0
move_R_x0
move_R_y0
face_size_L1.00
face_size_R1.00
angle_L0.0
angle_R0.0
detection_methodinsightface
custom_width1024
custom_height1024

Face AutoFit Double is the same composition trick as its single variant, but for two people - and that changes the job in a way that's worth understanding before you wire it up. Instead of just placing one person on a properly-framed canvas, it has to place two people at sensible relative sizes and positions so the result reads as a conversation or a shared scene rather than two headshots glued together. It's the node you reach for when you want a "two characters talking" or "couple portrait" image with the faces you already generated, laid out on a canvas that doesn't look accidental.

What it's for

In the pack's intended pipeline it sits right before generation: you bring in two face images with their masks (usually from two separate generated images, cut out with a background-removal or segmentation node), AutoFit Double lays them on one canvas with left/right placement, and then you sample around the composition. It also decides the whole prompt story for you: it detects the gender of each face internally and exports a mode_code that tells a Prompt Selector Double exactly which of its 16 template slots to draw from - two women, mixed couple, two men, times portrait/half-body/full-body/custom. That's the genuinely clever part of this pack: the geometry node and the text node share one numeric language.

How it works

Each side goes through the same pipeline as the single node: face detection (insightface default, with opencv, mediapipe, dlib, auto, none as alternatives), head-ratio and eye-line calculation, then a resize and paste onto the shared canvas. mode sets the canvas and framing - the built-in sizes are portrait 1024×720, half_body 1024×1536, full_body 1280×1600, custom via custom_width/custom_height. The per-side controls (move_L_x/move_L_y, face_size_L, angle_L, and the _R twins) let you nudge each person independently - which you will, because side-by-side faces usually need a nudge to actually look like they're sharing a frame. background picks white or gray for the canvas.

Inputs and outputs that matter

The four required image/mask inputs are image_L/mask_L and image_R/mask_R - left and right subjects. Then mode (portrait/half_body/full_body/custom) and detection_method. The three controls most beginners actually touch are move_L_x/move_R_x (get the spacing right), face_size_L/face_size_R (make sure the two heads are proportionate), and angle_L/angle_R (fix a tilted subject).

The outputs are where the value hides:

  • image - the composed two-person canvas, ready for the sampler.
  • mask_L, mask_R, mask_combined - the per-person alphas and the combined one, all usable for masked inpainting.
  • gender_L, gender_R (INT) and mode_code (INT) - the metadata that drives the prompt selector.

Wire mode_code into a Prompt Selector Double's mode_code input and the workflow picks the right template with zero input from you.

Installing it

Same as every node in this pack - one repo, one install. ComfyUI Manager → search ComfyUI_FaceAlignPaste, or:

cd ComfyUI/custom_nodes
git clone https://github.com/CHAOSEA/ComfyUI_FaceAlignPaste

Then restart. Dependencies are insightface, dlib, mediapipe, and opencv-python; insightface's buffalo_l model auto-downloads to ComfyUI/models/insightface/models on first use (shared with IP-Adapter plus if you already run that), and the dlib landmark model is bundled in the repo. Two install notes: dlib builds from source so Windows users need CMake and MSVC build tools, and insightface's weights carry a non-commercial license - fine for personal art, a problem if you're shipping a product.

Gotchas

  • Left/right is fixed by input order. image_L always lands on the left side of the canvas. Swap the inputs to swap the people, and remember the gender codes follow the same order - mode_code assumes L then R, and getting it backwards gives the Prompt Selector the wrong couple template.
  • Same canvas-size caveats as the single node. First run downloads models, none detection leans entirely on your masks, and the output is a composed flat canvas you still need to generate on top of.
  • Expect to nudge. Auto placement is decent, not miraculous - the per-side move controls exist because two faces almost never need zero adjustment.
Categoryimage/face

Inputs (17)

NameTypeDefaultDescription
image_LIMAGE
mask_LMASK
image_RIMAGE
mask_RMASK
modeCOMBOportrait4 options: portrait, half_body, full_body, custom
backgroundCOMBOwhite2 options: white, gray
move_L_xFLOAT0-100–100
move_L_yFLOAT0-100–100
move_R_xFLOAT0-100–100
move_R_yFLOAT0-100–100
face_size_LFLOAT1.000.5–2
face_size_RFLOAT1.000.5–2
angle_LFLOAT0.0-180–180
angle_RFLOAT0.0-180–180
detection_methodCOMBOinsightface6 options: insightface, auto, opencv, mediapipe, dlib, none
custom_widthoptINT1024256–4096
custom_heightoptINT1024256–4096

Outputs (7)

NameTypeDescription
imageIMAGE
mask_LMASK
mask_RMASK
mask_combinedMASK
gender_LINT
gender_RINT
mode_codeINT