Nodes/ComfyUI_MinimaxH3_AutoContext/Minimax_H3_Face_Blend
ComfyUI Node

Minimax_H3_Face_Blend

The paste-back pass that keeps a fixed face where it belongs

By supElement·Created 3 months ago·Updated 4 days ago· 36
Minimax_H3_Face_Blend
  • images
  • canvas
  • bbox
  • masks
  • images
◄feather_px16►
◄use_sec_maskfalse►
◄lowfreq_lockfalse►
◄motion_aligntrue►

Face_Blend is the third node in this pack's face-fix trio, and the only one that doesn't run a model at all. Face_Cut finds faces and crops them, Face_Resample repaints those crops with your H3 model, and Face_Blend puts the repainted pixels back into the original frames. It's the step everyone underestimates, because a sharpened face that jitters against the background looks worse than the soft face you started with.

If you've used image detailers, you know the loop: detect a region, crop and upscale it, diffuse the crop, composite it back (the detailing doc calls this the four-step core loop, and it's the same here). Face_Blend is step four - with two twists that matter for video. There is no VAE round-trip at all, and the node actively corrects for the resampled face drifting off its real position.

How the paste-back actually works

Two things are going on, and both are on by default except one.

Geometry, not guessing. Face_Cut's face_pack is a per-subtrack ledger - which crop row belongs to which frame, at which window offset, at which scale. Face_Blend walks that ledger and scales each refined canvas row back into its source window, pixel by pixel, fully in pixel space. No encode, no decode, so you don't pay a second generation of VAE mush on top of the repair.

Low-frequency lock (lowfreq_lock). Off by default. When on, the node takes the blurred original frame as the low-frequency signal and only borrows the high-frequency texture from the canvas - blur(original) + canvas − blur(canvas). Structure, colour and geometry stay the original's.

Motion align (motion_align). On by default, and this is the one you want. The canvas face is rarely in the exact same spot as the original face, especially at high sigma where the model freely recomposes. So the node does a per-frame, normalized-cross-correlation template match between the canvas face and the original frame's face, cancels the measured drift, and hands motion inheritance back to the source video. Estimates are peak-gated and temporally median-smoothed, unreliable frames get interpolated, corrections are clamped to a fraction of the window, and if the whole estimate fails it just does a plain paste. It's the difference between a face that tracks the head and a face that swims.

Inputs and outputs that matter

Required: images (the original frames - the same ones you fed Face_Cut), canvas (Face_Resample's images output), and bbox (Face_Resample's bbox, i.e. the updated face_pack).

Then four knobs. feather_px (default 16, 0–128) is your seam width - box mode feathers the rectangle edge, mask mode erodes and blurs around the SeC mask edge. use_sec_mask (default false) switches from pasting the whole feathered window to pasting only the face; the source priority is the masks port, then the pack's built-in masks, then the feathered box. motion_align you leave on. lowfreq_lock is the sharpening-at-low-sigma switch, and the author is explicit: keep it off when you're repairing a structurally broken face, because at high sigma the canvas has redrawn correct geometry and the lock would faithfully preserve the original's wrong geometry.

One optional input: masks, wired straight from Face_Cut, bypassing Face_Resample entirely. Rows line up 1:1 with the canvas rows.

One output: images. Wire it to your save/video node, or through Minimax_H3_Seam_Correction if you still have chunk seams to fix.

Install

Install the pack, not this node:

cd ComfyUI/custom_nodes
git clone https://github.com/supElement/ComfyUI_MinimaxH3_AutoContext.git
cd ComfyUI_MinimaxH3_AutoContext
pip install -r requirements.txt

Or search ComfyUI_MinimaxH3_AutoContext in ComfyUI Manager. Restart after either. Face_Blend itself has no extras - the pack's requirements are torch, numpy, scenedetect, opencv-python-headless, plus the accelerate/peft/timm/hydra-core/omegaconf/scikit-image/iopath/safetensors stack the bundled SeC-4B engine needs.

Where people get burned

"Blend reports a bbox port error." You wired shot_info into bbox. A shot map is not a geometry pack. Face_Resample's bbox output goes there; Face_Cut's face_pack also works as a fallback (with a warning), and shot_info belongs on the parameter node.

The background changed and you didn't want it to. That's the default. The feathered box replaces the entire window's content, not just the face. Set use_sec_mask to true and wire Face_Cut's masks across - and note the masks are only populated in multi-identity mode (sec_model set), so in single-face mode they're all zero and the box fallback is simply what you get. Not a bug.

A visible rectangle or a soft halo. Raise feather_px. If the fix is great but the edges pop, that's usually it.

Everything looks soft after a low-sigma detail pass. Turning lowfreq_lock on is exactly the case it was built for: at low sigma the canvas mostly adds texture, and locking the low frequencies stops that texture from wobbling frame to frame.

Your changes do nothing. Cache, almost always - clear_cache on the node that cached, or delete ComfyUI/output/cache/node_<node id>/ wholesale. The pack caps that cache directory at 32 GB by default and evicts oldest-first; H3_CACHE_MAX_GB=0 disables the cap.

CategoryMinimaxH3_AutoContext/FaceFix

Inputs (8)

NameTypeDefaultDescription
imagesIMAGEOriginal video frames 原视频画面
canvasIMAGECanvas from Minimax_H3_Face_Resample 来自 Face_Resample 的画布
bboxDICTface_pack from Minimax_H3_Face_Resample 来自 Face_Resample 的 face_pack
feather_pxINT160–128Blend-back edge feather (pixels); box mode: rectangle edge, mask mode: erode+blur around SeC mask edge (scaled per-frame in v14) 贴回边缘羽化 (像素); 框模式羽化矩形边, mask 模式羽化 SeC mask 边 (v14 起随逐帧窗口等比缩放)
use_sec_maskBOOLEANfalseBlend back with feathered SeC mask (face only, background untouched). Source priority: masks port > face_pack > feathered box 用羽化的 SeC mask 贴回 (只贴人脸)。来源优先级: masks端口 > face_pack > 羽化框回退
lowfreq_lockBOOLEANfalsePyramid low-freq lock: keep structure/color/geometry from the ORIGINAL frames, take only texture detail from the canvas. For DETAIL-sharpening workflows at LOW sigma (suppresses jitter). Keep OFF for structural repair of corrupted faces — at high sigma the canvas redraws correct geometry and this lock would keep the broken original geometry 金字塔低频锁定: 结构/色彩/几何取原帧, 仅纹理细节取画布。适用于低 σ 细节锐化 (抑制抖动)。修'崩坏脸'请保持关闭 — 高 σ 下画布重绘了正确的五官几何, 锁定反而会保住原帧的错误几何
motion_alignBOOLEANtrueLocal position correction at paste-back: per-frame NCC estimates how far the resampled canvas face drifted from the ORIGINAL frame's face and cancels it — the pasted face is glued to the original face position, its motion fully inherited from the source video. Kills paste-back jitter (esp. block boundaries at high sigma). Peak-gated + temporally median-smoothed; frames where the estimate is unreliable are interpolated. Soft-fails to plain paste 贴回局部位置修正: 逐帧 NCC 估计重采样画布脸相对原帧脸的位置漂移并抵消 — 贴回的脸被粘到原帧面部的真实位置, 运动完全继承原视频。消除贴回后抖动 (尤其高 σ 块边界)。峰值门控 + 时间中值平滑, 不可靠帧由邻帧插值, 失败自动回退普通贴回
masksoptMASKSeC masks from Minimax_H3_Face_Cut (rows 1:1 with crop_images/canvas rows, 1=face). Connect directly from Cut, bypassing Resample 来自 Face_Cut 的 SeC mask (行与裁剪/画布 1:1 对齐, 1=人脸)。从 Cut 直连, 不经过 Resample

Outputs (1)

NameTypeDescription
imagesIMAGE—