小珠光 Face Align (人脸对齐)
Alignment without the arc of despair
- target_image
- reference_image
- aligned_reference_image
Face-swap and identity workflows have a dirty secret: the alignment step. You want a reference face composited onto a target's position and scale, and doing it by hand - or by an ArcFace embedding pipeline that drags in a model download and a license review - is a project. 小珠光 Face Align (人脸对齐) solves the boring version of the problem: it detects the face in your target image and the face in your reference image, then crops and scales the reference so the face lands at exactly the target's position and size. One node, no models to download.
Where this shines is compositing work that isn't a full identity swap: paste a consistent face onto a character across frames, align a source portrait to a different frame's head position before re-rendering, prep crops for a detail pass. If you need true identity preservation (matching who the face is, not just where it is), you still want a dedicated identity model - this node is about geometry, and it says so on the box.
How it works
It runs face detection on both images, then computes a canvas size from the target's face-relative size and scale, and extracts a window from the reference centered on the reference face so the two line up. Detection is MediaPipe (Apache-2.0) - the license-clean option the detailing docs call out as the swap for AGPL'd YOLO - with a fallback path if no face is found (it uses the whole image as a last resort rather than crashing). 检测分辨率 (detection resolution, default 640) controls the detection image size; 640 is a good balance, and you raise it if tiny faces aren't being found. padding_mode picks white or black for the area outside the extracted window.
The inputs that matter
target_image- the image whose face position you want to match.reference_image- the face you're aligning onto the target.target_frame_index- which frame of the target to use (target can be a batch).padding_mode- white or black for the surrounding canvas.检测分辨率- detector input resolution.
Output: aligned_reference_image - a single IMAGE, the reference cropped and scaled to the target's face geometry.
Install
From the ComfyUI-xiaozhuguang pack - Manager (search "ComfyUI-xiaozhuguang"), or:
cd ComfyUI/custom_nodes/
git clone https://github.com/xiaozhuguang/ComfyUI-xiaozhuguang.git
Restart. No model downloads. MediaPipe is a listed optional dependency - the pack falls back to whole-image detection if it's missing, but for real face alignment you'll want it: pip install mediapipe in your ComfyUI environment.
Gotchas
Two honest ones. First, MediaPipe's short-range detector is tuned for frontal faces - extreme angles can miss, and the fallback to whole-image detection will happily "align" a nothingburger. Keep faces roughly forward-facing for reliable results. Second, this aligns position and scale, not identity: the output is a crop of your reference, so any color or style mismatch between the two images still needs blending work downstream (the pack's ATR with blur_amount is the natural next hop).
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| target_image | IMAGE | — | |
| reference_image | IMAGE | — | |
| target_frame_index | INT | 00–999999 | — |
| padding_mode | COMBO | white | 2 options: white, black |
| 检测分辨率 | INT | 640160–2048 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| aligned_reference_image | IMAGE | — |