h4 - Identity Engine
The all-in-one character generator that swaps a consistent face onto every scene
- face_image
- model_opt
- clip_opt
- vae_opt
- image_optional
- character_image
- model
- clip
- vae
H4_IdentityEngine is h4_Live's "make the same character every time" node - a full text-to-image generator wrapped around a face-swap, so you get both a fresh scene and a consistent face. It's the character-consistency answer for people who don't want to train a LoRA: you keep a "DNA" prompt (fixed character traits like "blonde, scars") and a scene prompt (what they're doing), and the node generates the scene, then optionally swaps a reference face onto the result using the FaceForge machinery.
The clever design bit is the DNA prompt concept. Instead of repeating a character description in every positive prompt and hoping the model stays consistent, you put the immutable traits in positive_dna, which gets concatenated with the per-scene positive. That separation is genuinely the right mental model for consistent characters: DNA is the person, positive is the moment. The face-swap layer then enforces identity at the pixel level on top of whatever the model guessed - a hybrid that mirrors what the community does by hand ("IP-Adapter gets you 80% there, face swap gets the rest").
The settings that matter
- positive_dna - the character's fixed identity text. positive - the scene. negative - what to avoid. These three are the heart of the node.
- preset - a saved character preset selector (the engine can save/load character configs, so your DNA doesn't get re-typed every session).
- ckpt_name, vae_name, clip_name, seed, steps, cfg, sampler_name, scheduler, denoise, width, height, batch_size - the generation recipe, mostly standard sampler fare. VAE/CLIP default to "Baked"/"Use Checkpoint," which is right for most people.
- The swap block: face_image (drag a photo in to clone that face) or face_model (a saved
.safetensorsface identity - pair it with H4_BuildFaceModel), swap_enabled, face_similarity (how strictly to copy facial features; higher = more likeness but "maybe weird"), swap_model (inswapper_128). - The polish block: restore_enabled / restore_model (CodeFormer by default), codeformer_weight, occlusion_enabled (needs a sam_model), preserve_glasses, and upscale_enabled / upscale_model.
- Overrides: model_opt/clip_opt/vae_opt to inject your own models, plus positive_text/negative_text inputs to drive the prompts externally.
The outputs
- character_image - the finished generation with the face applied.
- model, clip, vae - the loaded stack passed through, so the engine can feed a downstream node without reloading.
Installing and dependencies
ComfyUI Manager → search "h4_Live", or:
cd ComfyUI/custom_nodes
git clone https://github.com/m3rr/h4_Live
restart. The swap path needs insightface, onnxruntime, and opencv (no requirements.txt in the pack, lazy-imported, so first run may hit a ModuleNotFoundError):
pip install insightface onnxruntime opencv-python
Restore/swap/SAM model weights auto-download on first use.
Where people get burned
Tune face_similarity down from 1.0 - max likeness produces uncanny results, and the tooltip's "maybe weird" is understating it. Keep positive_dna short and stable across scenes; that's what makes the character read as the same person. And the licensing reminder applies to the whole identity family: InsightFace's weights are non-commercial, so this is personal-work territory, not a commercial pipeline. It's the most ambitious node in the pack - and as with everything in h4_Live, it's a work in progress, so expect the occasional rough edge and keep the "?" help drawer handy.
Inputs (38)
| Name | Type | Default | Description |
|---|---|---|---|
| preset | STRING | None | Select a saved character preset. |
| ckpt_name | COMBO | The primary Checkpoint. Determines the art style. | |
| vae_name | COMBO | Color correction. 'Baked' means use what's inside the Checkpoint. | |
| clip_name | COMBO | Text Interpreter. 'Use Checkpoint' is usually best. | |
| seed | INT | 00–18446744073709550000 | The magic number definition. Same Seed + Same Settings = Same Image. |
| steps | INT | 201–10000 | How many times to polish the image. 20-30 is standard. |
| cfg | FLOAT | 8.000–100 | Creativity Scale. Low (5-7) = Creative. High (8-12) = Strict. |
| sampler_name | COMBO | The drawing method. 'euler' is fast, 'dpmpp_2m' is detailed. | |
| scheduler | COMBO | How noise is removed. 'normal' or 'karras' work well. | |
| denoise | FLOAT | 1.000–1 | Img2Img Only: How much to change the original? 1.0 = New Image, 0.4 = Minor Edits. |
| positive_dna | STRING | DNA Prompt: Fixed character persistence (e.g. 'blonde, scars'). Concats with Positive. | |
| positive | STRING | Scene Prompt: What they are doing (e.g. 'riding a moto'). | |
| negative | STRING | What do you NOT want? (e.g. 'blurry, ugly, bad hands') | |
| width | INT | 51216–4096 | Image Width. |
| height | INT | 51216–4096 | Image Height. |
| batch_size | INT | 11–64 | How many images to create at once. |
| face_image | IMAGE | Drag a photo here to clone this face onto the character. | |
| face_model | COMBO | Or pick a pre-saved .safetensors face model. 'None' to disable. | |
| swap_enabled | BOOLEAN | true | Turn ON to enable face swapping. |
| face_similarity | FLOAT | 0.500–1 | How strictly to copy the face features. Higher = More likeness, but maybe weird. |
| restore_enabled | BOOLEAN | true | Fix blurry faces automatically. |
| restore_visibility | FLOAT | 1.000–1 | Restore strength. 1.0 = Full Fix. |
| restore_model | COMBO | codeformer-v0.1.0.pth | The repair tool to use. |
| codeformer_weight | FLOAT | 0.500–1 | Fidelity vs. Quality. 0.0 = High Fidelity, 1.0 = Smooth Skin. |
| swap_model | COMBO | inswapper_128.onnx | The logic engine for the swap. |
| boost_enabled | BOOLEAN | false | High-Res swap? Slower but sharper. |
| occlusion_enabled | BOOLEAN | true | Prevent face from overlapping hair/hands. |
| sam_model | COMBO | none | SAM model for perfect occlusion masks. |
| preserve_glasses | BOOLEAN | true | Attempt to keep the target's eyewear. |
| upscale_enabled | BOOLEAN | false | Upscale the FINAL result. |
| upscale_model | COMBO | none | The upscaler engine. |
| upscale_face_only | BOOLEAN | false | Only upscale the face region? (Saves VRAM) |
| model_optopt | MODEL | — | |
| clip_optopt | CLIP | — | |
| vae_optopt | VAE | — | |
| image_optionalopt | IMAGE | — | |
| positive_textopt | STRING | [Override] Connect external Scene Prompt here (e.g. from a Primitive). | |
| negative_textopt | STRING | [Override] Connect external Negative Prompt here. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| character_image | IMAGE | — |
| model | MODEL | — |
| clip | CLIP | — |
| vae | VAE | — |