SCAIL-2 Align Reference Face To Crop
Align your face reference to the crop so SCAIL-2's detail pass actually matches
- face_crop_video
- reference_image
- aligned_reference_image
- debug_preview
- summary
The second-pass trick for fixing SCAIL-2's drifting faces works a lot better when the reference image you give it actually lines up with the crop it's trying to reproduce. That's the insight behind this node: SCAIL-2 Align Reference Face To Crop detects the face in your first crop frame, detects the face in your high-res reference image, and builds a new reference whose face position and face size match the crop - so the detail pass starts from a reference that already looks like the shot instead of a random headshot the model has to reconcile.
It was added to the pack specifically because a community member (the README credits Aiwu/爱屋) noticed the second-pass face-detail video is far more stable when the high-res reference is aligned to the crop first. You connect the crop video from SCAIL-2 Head Track Crop as face_crop_video, your high-res face image as reference_image, and it outputs aligned_reference_image, which you then wire into the second scheduler as reference_N. There's also a debug_preview and a summary string describing what it did.
The key design choice is that it does not shrink your reference to crop resolution. It crops the reference at its original pixel density, so you keep every detail your high-res image has. window_fit_mode controls the edge behavior: the default shift_inside_reference moves the computed crop window back inside the reference image whenever it fits, so a large-enough reference gets no artificial padding at all; padding is used only when the requested window is bigger than the reference, or if you pick strict_alignment to preserve exact relative face placement. The practical result: alignment without upscaling, which is exactly what you want for a face detail pass.
The detector is where the install requirements creep in. face_detector_backend defaults to auto, which tries InsightFace first and falls back to MediaPipe if InsightFace isn't installed or fails. For the strongest detection, install InsightFace:
python -m pip install insightface onnxruntime-gpu # CUDA; use onnxruntime for CPU
with insightface_model set to buffalo_l (default) or buffalo_s for the smaller model. The simplest path is MediaPipe, which uses its built-in face detection and needs no separate model file:
python -m pip install mediapipe
The MediaPipe-specific knobs (mediapipe_model_selection, mediapipe_min_detection_confidence) only matter on that backend, and provider (auto/cuda/cpu), det_size, and insightface_model only matter on InsightFace. If you don't have either library installed, auto falls back gracefully to MediaPipe - but you need at least one of them for this node to do anything.
The manual tuning controls are for small corrections only: face_scale (default 1.0; above 1.0 makes the reference face larger in the output window, below makes it smaller), x_offset_ratio and y_offset_ratio (fine position nudges, ±0.5), face_size_basis (bbox_width or bbox_height), and padding_mode (edge, reflect, black, white, mean) for the edges. target_face_select (center default) and reference_face_select (largest default) pick which face to use when a frame has more than one. target_frame_index selects which frame of the crop video is the alignment target - frame 0 by default, and usually that's the right one.
Install for the node itself is the pack standard (ComfyUI Manager search comfyui_scail2_multi_cond, or clone into custom_nodes and restart) - the extra step is the detector package above, which is the one place this pack has any real Python dependency.
Where people get burned: nothing about alignment fixes a bad reference, and nothing about it fixes SCAIL-2's underlying face drift. What it does is remove a controllable mismatch - wrong face size and position - so the detail pass isn't fighting geometry before it starts. For a single face used across the whole clip, point every segment at reference 1 and align once.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| face_crop_video | IMAGE | — | |
| reference_image | IMAGE | — | |
| target_frame_index | INT | 00–999999 | — |
| face_scale | FLOAT | 1.000.25–4 | — |
| x_offset_ratio | FLOAT | 0.000-0.5–0.5 | — |
| y_offset_ratio | FLOAT | 0.000-0.5–0.5 | — |
| face_size_basis | COMBO | bbox_width | 2 options: bbox_width, bbox_height |
| target_face_select | COMBO | center | 2 options: center, largest |
| reference_face_select | COMBO | largest | 2 options: largest, center |
| padding_mode | COMBO | edge | 5 options: edge, reflect, black, white, mean |
| insightface_model | COMBO | buffalo_l | 2 options: buffalo_l, buffalo_s |
| provider | COMBO | auto | 3 options: auto, cuda, cpu |
| det_size | INT | 640160–2048 | — |
| face_detector_backend | COMBO | auto | 3 options: auto, insightface, mediapipe |
| mediapipe_model_selection | COMBO | full_range | 2 options: full_range, short_range |
| mediapipe_min_detection_confidence | FLOAT | 0.500.01–0.99 | — |
| window_fit_mode | COMBO | shift_inside_reference | 2 options: shift_inside_reference, strict_alignment |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| aligned_reference_image | IMAGE | — |
| debug_preview | IMAGE | — |
| summary | STRING | — |