Loop Strip — Center Character
The face-aware centering for character sheets
- image
- mask
- head_mask
- centered
If Center Subject is the video-cleanup node, this one is for character sheets: turnarounds, 8-angle references, the "same person, many views" images people actually use this pack to build. You feed it a cut-out character - usually with a mask from BiRefNet or RMBG - and it cuts, scales, and pastes each view onto a uniform canvas, anchored so the face sits at a consistent height. That consistency is what makes a turnaround read as one character instead of eight unrelated doodles.
How it works
The pipeline is two passes. First it figures out, per image, where the character and the face are:
- If you pass a mask, that's the character. If not, it auto-detects: estimate the background from the frame edges and Otsu-threshold the difference. RGBA images with real alpha get their alpha used as the mask automatically.
- The interesting part is locating the head. It runs OpenCV's
lbpcascade_animefacecascade (an anime-style face detector, bundled with the pack - no download) on the crop, then discards detections in the bottom half of the character as armor/body false positives. That filter is a nice touch; anime chest armor loves to read as a face. - No face found? Fallback: the largest blob in the top 40% of the mask gives the head's X position, and Y is pinned at 43% of character height - a fixed assumption that keeps back and side views consistent with detected front views.
Then pass two scales each character to fit fill_percent of the canvas and pastes it so the face lands on the canvas center, clamped inside the fill box. Symmetric front views land dead-center; asymmetric side poses drift until the body hits the box edge. Output: centered, a batch of uniform canvases.
There's a sharper mode hiding in the optional inputs: head_mask. Give it a SAM2 mask of the head on one reference frame (usually the front view), and it measures the head-above-feet distance once, then applies that fixed offset to every view - so back views, where no face exists, still center correctly because it never looks for a face, just feet and a known height. This is the trick for full turnarounds.
Inputs that matter
- output_size - square canvas, default 512. fill_percent (default 0.55) - how much of it the character occupies.
- mask (optional) - from BiRefNet/RMBG. Sharper edges than auto-detection. Worth supplying on anything with hair.
- head_mask + reference_index (optional) - the head-anchor trick above.
Install
Manager → search "Loop Strip" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/serhiiyashyn-sf/comfyui-loopstrip
cd comfyui-loopstrip
pip install -r requirements.txt
Restart after. Requirements are opencv-python, numpy, torch, scipy, requests - all typically already installed. The anime face cascade ships in the repo, so there's nothing to fetch.
Watch out
The face cascade is tuned for anime faces. Real-photo faces will mostly fall through to the fallback method, which still works - the fixed 43% head position - but you lose the per-view face anchoring. And if you skip the mask on a busy background, auto-detection will grab the wrong stuff; that's what the threshold input (default 0.12) is there for. One thing to love: it prints which method it used per frame (anime_cascade, head_anchor, or fallback) to the console, so you always know what actually happened.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| output_size | INT | 51264–4096 | Output square size |
| fill_percent | FLOAT | 0.550.3–0.95 | How much of the canvas the character fills |
| maskopt | MASK | Character mask from BiRefNet/RMBG. If not provided, auto-detects from background. | |
| head_maskopt | MASK | SAM2 mask of the head on ONE reference frame (usually the front view). When provided, centering anchors to feet + fixed head-above-feet offset — works reliably on back/side views where no face is visible. | |
| reference_indexopt | INT | 00–4096 | Which frame the head_mask corresponds to (usually the front-facing angle). |
| thresholdopt | FLOAT | 0.120.01–0.5 | Auto-detection threshold (only used when no mask provided) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| centered | IMAGE | — |