Nodes/h4_Live/h4 - Identity Engine
ComfyUI Node

h4 - Identity Engine

The all-in-one character generator that swaps a consistent face onto every scene

By m3rr·Created 9 months ago·Updated 10 days ago· 1
h4 - Identity Engine
  • face_image
  • model_opt
  • clip_opt
  • vae_opt
  • image_optional
  • character_image
  • model
  • clip
  • vae
presetNone
ckpt_name
vae_name
clip_name
seed0
steps20
cfg8.00
sampler_name
scheduler
denoise1.00
positive_dna
positive
negative
width512
height512
batch_size1
face_model
swap_enabledtrue
face_similarity0.50
restore_enabledtrue
restore_visibility1.00
restore_modelcodeformer-v0.1.0.pth
codeformer_weight0.50
swap_modelinswapper_128.onnx
boost_enabledfalse
occlusion_enabledtrue
sam_modelnone
preserve_glassestrue
upscale_enabledfalse
upscale_modelnone
upscale_face_onlyfalse
positive_text
negative_text

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 .safetensors face 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.

Categoryh4/IdentityEngine

Inputs (38)

NameTypeDefaultDescription
presetSTRINGNoneSelect a saved character preset.
ckpt_nameCOMBOThe primary Checkpoint. Determines the art style.
vae_nameCOMBOColor correction. 'Baked' means use what's inside the Checkpoint.
clip_nameCOMBOText Interpreter. 'Use Checkpoint' is usually best.
seedINT00–18446744073709550000The magic number definition. Same Seed + Same Settings = Same Image.
stepsINT201–10000How many times to polish the image. 20-30 is standard.
cfgFLOAT8.000–100Creativity Scale. Low (5-7) = Creative. High (8-12) = Strict.
sampler_nameCOMBOThe drawing method. 'euler' is fast, 'dpmpp_2m' is detailed.
schedulerCOMBOHow noise is removed. 'normal' or 'karras' work well.
denoiseFLOAT1.000–1Img2Img Only: How much to change the original? 1.0 = New Image, 0.4 = Minor Edits.
positive_dnaSTRINGDNA Prompt: Fixed character persistence (e.g. 'blonde, scars'). Concats with Positive.
positiveSTRINGScene Prompt: What they are doing (e.g. 'riding a moto').
negativeSTRINGWhat do you NOT want? (e.g. 'blurry, ugly, bad hands')
widthINT51216–4096Image Width.
heightINT51216–4096Image Height.
batch_sizeINT11–64How many images to create at once.
face_imageIMAGEDrag a photo here to clone this face onto the character.
face_modelCOMBOOr pick a pre-saved .safetensors face model. 'None' to disable.
swap_enabledBOOLEANtrueTurn ON to enable face swapping.
face_similarityFLOAT0.500–1How strictly to copy the face features. Higher = More likeness, but maybe weird.
restore_enabledBOOLEANtrueFix blurry faces automatically.
restore_visibilityFLOAT1.000–1Restore strength. 1.0 = Full Fix.
restore_modelCOMBOcodeformer-v0.1.0.pthThe repair tool to use.
codeformer_weightFLOAT0.500–1Fidelity vs. Quality. 0.0 = High Fidelity, 1.0 = Smooth Skin.
swap_modelCOMBOinswapper_128.onnxThe logic engine for the swap.
boost_enabledBOOLEANfalseHigh-Res swap? Slower but sharper.
occlusion_enabledBOOLEANtruePrevent face from overlapping hair/hands.
sam_modelCOMBOnoneSAM model for perfect occlusion masks.
preserve_glassesBOOLEANtrueAttempt to keep the target's eyewear.
upscale_enabledBOOLEANfalseUpscale the FINAL result.
upscale_modelCOMBOnoneThe upscaler engine.
upscale_face_onlyBOOLEANfalseOnly upscale the face region? (Saves VRAM)
model_optoptMODEL
clip_optoptCLIP
vae_optoptVAE
image_optionaloptIMAGE
positive_textoptSTRING[Override] Connect external Scene Prompt here (e.g. from a Primitive).
negative_textoptSTRING[Override] Connect external Negative Prompt here.

Outputs (4)

NameTypeDescription
character_imageIMAGE
modelMODEL
clipCLIP
vaeVAE