Face Align Single @ CHAOS
Graft a face onto a target without mangling the geometry
- target
- source
- mask
- image
- mask
- raw_mask
Face Align Single is the "surgical" node in the CHAOS pack. Where Face AutoFit composes a whole character onto a fresh canvas, this one takes a face you like, detects its landmarks, and pastes it onto a specific target image so the two faces line up - same eye line, same head tilt, same scale, as close to the target's geometry as the source allows. Think of it as a geometry-aware paste rather than a face swap: it moves pixels, it doesn't generate identity. You'd reach for it when you've got a character you want to place onto an existing head, pose, or background and you don't want to leave the placement to chance.
How it works
The node extracts facial landmarks from both the source face and the target - it tries the face-alignment library if you've installed it (pip install face-alignment), and falls back to MediaPipe or dlib's 68-point predictor, whose model (shape_predictor_68_face_landmarks.dat) ships inside the pack. From the landmark correspondence it computes the transform that maps the source face onto the target's position, applies it, and composites with the mask you provide. The feather control (0–100) softens the paste edges, which is what separates a decent graft from a visible hard circle.
Inputs and outputs that matter
The three required inputs are:
target(IMAGE) - the base image the face gets pasted onto.source(IMAGE) - the face you're moving.mask(MASK) - the source face's alpha, so only the face region is pasted.
The optional tweaks are small and self-explanatory: feather (0–100, edge softening), size (0.5–2×, scale the pasted face), and move_x/move_y (−20..20, nudge it into place). Outputs are image (the composite), mask (the feathered mask you can feed an inpaint step), and raw_mask (the unfeathered version, handy when you want the hard silhouette).
The workflow pattern that makes this shine: paste the aligned face, then send the composite plus mask into a masked inpaint at low denoise so the generator redraws the boundary and makes the graft look real. On its own it's a paste; with an inpaint step it's a believable face replacement.
Installing it
Same single-repo install as the rest of the pack. ComfyUI Manager → search ComfyUI_FaceAlignPaste, or:
cd ComfyUI/custom_nodes
git clone https://github.com/CHAOSEA/ComfyUI_FaceAlignPaste
Restart, and expect the usual dependency haul: insightface, dlib, mediapipe, opencv-python. The dlib landmark model is bundled, so no manual model download. The one extra this node quietly wants is the optional face-alignment library - without it the code falls back to MediaPipe/dlib landmarks, which still work but are a step down in landmark precision. Install it the same way:
pip install face-alignment
And yes, dlib builds from source - CMake plus MSVC build tools on Windows, and a long compile. InsightFace's weights are non-commercial, which is fine for hobby use.
Gotchas
- It's a pixel paste, not an identity swap. Don't expect inswapper-level likeness transfer. This node preserves geometry; the identity comes from whatever source face you fed it.
- Garbage in, garbage out on the mask. A loose mask drags background pixels along with the face. Get the mask clean before you paste.
- Watch the seam. If you skip feathering or inpaint after, you'll see the cut line. The
raw_maskoutput exists precisely because people kept wanting the hard-edged version to build their own blending. - If landmarks fail, check the bundled
.datis present in the pack'smodels/folder - the code warns you to downloadshape_predictor_68_face_landmarks.datfrom dlib.net if it's missing.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| target | IMAGE | — | |
| source | IMAGE | — | |
| mask | MASK | — | |
| featheropt | INT | 00–100 | — |
| sizeopt | FLOAT | 1.000.5–2 | — |
| move_xopt | INT | 0-20–20 | — |
| move_yopt | INT | 0-20–20 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| raw_mask | MASK | — |