Nodes/h4_Live/h4 - Face Forge
ComfyUI Node

h4 - Face Forge

The all-in-one face swap with restore, upscale, and occlusion smarts

By m3rr·Created 9 months ago·Updated 10 days ago· 1
h4 - Face Forge
  • input_image
  • source_image
  • face_model
  • SWAPPED_IMAGE
  • FACE_MODEL
  • ORIGINAL_IMAGE
swap_enabledtrue
swap_model
target_face_index0
source_face_index0
face_selection_mode
restore_enabledtrue
restore_model
restore_visibility1.00
codeformer_weight0.50
boost_enabledfalse
upscale_enabledfalse
upscale_model
upscale_face_onlyfalse
occlusion_enabledfalse
preserve_glassestrue
preserve_hairtrue
sam_model

H4_FaceForge is the face swapper at the heart of h4_Live's FaceForge suite - the "put this face on that person" node. But unlike a bare swap tool, it's built as a pipeline: swap, then clean up, then (optionally) upscale. The author's own framing is that basic swappers look fake - plastic skin, a visible jawline seam - and FaceForge exists to fix that. It detects the face in your target image, grafts on the source face, runs a restore pass (GFPGAN or CodeFormer) to sharpen eyes and mouth, and can optionally push it through an upscaler or add occlusion-aware masking so the new face doesn't paint over hair, hands, or glasses.

Under the hood it's the same backbone nearly every no-training identity tool uses: InsightFace for detection and ArcFace embeddings, then an inswapper_128-style model for the actual swap. This is the post-process face-swap lineage (ReActor/Roop family), not the generative IP-Adapter/InstantID approach - it's pixel-level grafting after generation, which is why it lands on top of an already-generated image rather than conditioning the diffusion.

The settings that matter

  • input_image - the image you're working on. source_image (optional) - the reference face; if you've already built one, plug a face_model in instead.
  • swap_enabled and swap_model - on by default; inswapper_128 is the standard model. Turn swap off if you only want restore/upscale.
  • target_face_index / source_face_index - which face to replace and which source face to use ("0" is the first). Commas allow multiples like 0,2. face_selection_mode sets how faces are counted (largest-first, left-right, etc.).
  • restore_enabled / restore_model - the cleanup pass. GFPGAN is the safe pick; CodeFormer is stronger but "can change identity." restore_visibility blends how much repair (1.0 = full model). codeformer_weight balances quality vs identity for CodeFormer.
  • upscale_enabled / upscale_model - optional final scaling; 4x-UltraSharp is the author's recommendation for photos. upscale_face_only saves VRAM by only sharpening the face region.
  • occlusion_enabled - smart masking so the new face doesn't swallow hair/glasses. The tooltip warns it "Uses lots of VRAM!" and needs a sam_model (e.g. sam_vit_b_01ec64.pth) for the segmentation.
  • boost_enabled - experimental "enhance during swap," slower, occasionally sharper.

The outputs

  • SWAPPED_IMAGE - the result.
  • FACE_MODEL - the extracted identity, which you can feed to a save node or reuse in the other FaceForge nodes.
  • ORIGINAL_IMAGE - the untouched input, handy for comparison or further processing.

Installing and dependencies

ComfyUI Manager → search "h4_Live", or:

cd ComfyUI/custom_nodes
git clone https://github.com/m3rr/h4_Live

restart. This is where the pack's hidden dependencies live: the swap path needs insightface, onnxruntime, and opencv - there's no requirements.txt, and they're lazy-imported, so the pack installs fine and the node errors on first run if they're missing. Fix with:

pip install insightface onnxruntime opencv-python

Model files (swap, restore, upscale, SAM) auto-download into your models/ folders on first use. The restore and upscale model URLs point at the standard sources (ReActor's dataset on HuggingFace, Real-ESRGAN, UltraSharp), so they're the same weights the rest of the ecosystem uses.

Where people get burned

The big one is identity drift from restore: crank CodeFormer's weight toward 1.0 and your source face gets smoothed into someone else. Keep restore_visibility around 0.8 and check the swap before letting restore go wild. Occlusion mode is genuinely VRAM-hungry - don't enable it on a 6GB card and expect smooth sailing. And remember the licensing reality of the whole family: InsightFace's models are non-commercial while the library is MIT, so this stack is fine for personal work but not for selling a product.

Categoryh4_Live/FaceForge

Inputs (20)

NameTypeDefaultDescription
input_imageIMAGEThe image you want to work on. Connect your Load Image node here.
swap_enabledBOOLEANtrueTurn this ON to swap faces. Turn OFF if you just want to use Restore or Upscale.
swap_modelCOMBOThe brain that performs the swap. 'inswapper_128' is the standard one.
target_face_indexSTRING0Which face to replace? 0 = 1st face, 1 = 2nd face. Use commas for multiple (e.g., '0,2').
source_face_indexSTRING0Which face from the source to use? Usually 0 (the main face).
face_selection_modeCOMBOHow we count faces. 'large-small' finds the biggest face first (Index 0).
restore_enabledBOOLEANtrueFixes blurry or pixelated faces. Great for low-res images.
restore_modelCOMBOChoose the repair tool. 'GFPGAN' is standard, 'CodeFormer' is strong but can change identity.
restore_visibilityFLOAT1.000–1How strong is the repair? 1.0 = Full Model, 0.5 = 50% Mix with original.
codeformer_weightFLOAT0.500–1(CodeFormer Only) Balance between Quality (0.0) and Identity (1.0).
boost_enabledBOOLEANfalseExperimental: Enhances the face *during* the swap. Slower, but can be sharper.
upscale_enabledBOOLEANfalseMake the image larger and crisper.
upscale_modelCOMBOThe scaling engine. 'UltraSharp' is great for photos.
upscale_face_onlyBOOLEANfalseON = Only sharpen the face. OFF = Sharpen the whole image (Slower).
occlusion_enabledBOOLEANfalseSmart Masking. Prevents the face from covering hair/hands/objects. ⚠️ Uses lots of VRAM!
preserve_glassesBOOLEANtrue(With Occlusion) Try to keep the original glasses on the face.
preserve_hairBOOLEANtrue(With Occlusion) Try to keep hair strands from being covered by the new face.
source_imageoptIMAGE
face_modeloptFACE_MODEL
sam_modeloptCOMBO2 options: none, sam_vit_b_01ec64.pth

Outputs (3)

NameTypeDescription
SWAPPED_IMAGEIMAGE
FACE_MODELFACE_MODEL
ORIGINAL_IMAGEIMAGE