Carasibana/ComfyUI-H3-FaceRefine

Refine and improve the quality of small faces in MiniMax H3 video. Per-frame face tracking, crop, refine with H3, stitch back.

What it solves

This project addresses the poor rendering of small faces in MiniMax H3 videos. When a head occupies a small portion of the frame, the quality drops regardless of the output resolution. These nodes automate a process of detecting, cropping, refining, and compositing faces back into the original video to restore detail and quality.

How it works

The system uses a multi-step pipeline within ComfyUI:

  1. Tracking and Cropping: It detects faces in every frame, smooths the trajectory to prevent "boiling" (jitter), and crops the face to fill a canvas.
  2. Latent Injection: It encodes these crops into H3's joint audio-video latent stream, enabling a video-to-video (img2img) workflow that is not natively supported by stock H3 nodes.
  3. Dynamic Denoising: It adjusts the denoise strength per frame based on the face size; smaller faces receive stronger synthesis to add detail, while larger faces receive gentler passes to preserve existing detail.
  4. Refinement: The MiniMax H3 model regenerates the face crops.
  5. Stitching: The refined crops are warped back onto the original frames using sub-pixel precision, color-matched to avoid brightness shifts, and feathered into the original video.

Who it’s for

Users of ComfyUI and the MiniMax H3 video model who want to improve facial detail and consistency in shots where subjects are distant or small in the frame.

Highlights

  • Temporal Smoothing: Uses Gaussian or Savgol smoothing on crop centers and sizes to ensure the refined face doesn't shimmer or jitter.
  • Identity Tracking: Supports using a reference image to track a specific person through a crowd or during occlusions.
  • Per-Frame Denoise: Automatically scales denoise strength based on the actual pixel size of the face in the source video.
  • Flexible Masking: Offers both simple rectangular masks and high-precision SAM (Segment Anything Model) masks for blending.
  • Sub-pixel Stitching: Uses a batched grid_sample to ensure refined faces are placed back exactly where they originated.

Related

  • Project
  • Project
  • Project
  • Dispatch
  • Project