h4 - Face Forge
The all-in-one face swap with restore, upscale, and occlusion smarts
- input_image
- source_image
- face_model
- SWAPPED_IMAGE
- FACE_MODEL
- ORIGINAL_IMAGE
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_128is 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-UltraSharpis 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.
Inputs (20)
| Name | Type | Default | Description |
|---|---|---|---|
| input_image | IMAGE | The image you want to work on. Connect your Load Image node here. | |
| swap_enabled | BOOLEAN | true | Turn this ON to swap faces. Turn OFF if you just want to use Restore or Upscale. |
| swap_model | COMBO | The brain that performs the swap. 'inswapper_128' is the standard one. | |
| target_face_index | STRING | 0 | Which face to replace? 0 = 1st face, 1 = 2nd face. Use commas for multiple (e.g., '0,2'). |
| source_face_index | STRING | 0 | Which face from the source to use? Usually 0 (the main face). |
| face_selection_mode | COMBO | How we count faces. 'large-small' finds the biggest face first (Index 0). | |
| restore_enabled | BOOLEAN | true | Fixes blurry or pixelated faces. Great for low-res images. |
| restore_model | COMBO | Choose the repair tool. 'GFPGAN' is standard, 'CodeFormer' is strong but can change identity. | |
| restore_visibility | FLOAT | 1.000–1 | How strong is the repair? 1.0 = Full Model, 0.5 = 50% Mix with original. |
| codeformer_weight | FLOAT | 0.500–1 | (CodeFormer Only) Balance between Quality (0.0) and Identity (1.0). |
| boost_enabled | BOOLEAN | false | Experimental: Enhances the face *during* the swap. Slower, but can be sharper. |
| upscale_enabled | BOOLEAN | false | Make the image larger and crisper. |
| upscale_model | COMBO | The scaling engine. 'UltraSharp' is great for photos. | |
| upscale_face_only | BOOLEAN | false | ON = Only sharpen the face. OFF = Sharpen the whole image (Slower). |
| occlusion_enabled | BOOLEAN | false | Smart Masking. Prevents the face from covering hair/hands/objects. ⚠️ Uses lots of VRAM! |
| preserve_glasses | BOOLEAN | true | (With Occlusion) Try to keep the original glasses on the face. |
| preserve_hair | BOOLEAN | true | (With Occlusion) Try to keep hair strands from being covered by the new face. |
| source_imageopt | IMAGE | — | |
| face_modelopt | FACE_MODEL | — | |
| sam_modelopt | COMBO | 2 options: none, sam_vit_b_01ec64.pth |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| SWAPPED_IMAGE | IMAGE | — |
| FACE_MODEL | FACE_MODEL | — |
| ORIGINAL_IMAGE | IMAGE | — |