This ComfyUI workflow performs high-quality face replacement by combining an InsightFace-based alignment and paste stage with FLUX.1 image-to-image generation guided by Kontext. It is designed for creators who want fast, reliable swaps with minimal masking and natural skin and hair blending. The pipeline loads a prepared Kontext UNet, applies the Put it here LoRA, and regenerates the local region for a seamless result.
The FLUX Kontext Face Swap workflow takes a base image and a face image, auto-detects and aligns the face, pastes it into the base, scales the composite for FLUX, then refines it with prompt-guided sampling. Results are previewed and saved, with optional knobs to tighten crops or make the swap subtler or stronger.
This graph has two main groups that run in sequence: Face transplant prepares a clean composite patch; Ksampler and Output regenerates and polishes it with FLUX.
This group loads your Base Image (LoadImage
(#108)) and Face Image (LoadImage
(#110)), then finds face regions with AutoCropFaces
(#119, #122). The crops and landmarks feed FaceAlign
(#121), which warps the source face to match the base pose and scale. Image Paste Face
(#125) merges the aligned face into the base while using crop metadata for a tight, realistic overlay. FluxKontextImageScale
(#134) then rescales the composite to the exact dimensions Kontext expects, so the downstream VAE encode is lossless and stable.
What to provide:
DualCLIPLoader
(#8) loads CLIP-L and T5-XXL encoders, and CLIPTextEncode
(#6) converts your prompt into conditioning. The prompt is written to focus on restoring the face area and controlling expression; you can edit it to nudge details like smile, hair, or makeup. ConditioningZeroOut
(#4) gates text influence so Kontext preserves context outside the swap region, and ReferenceLatent
(#3) anchors the generation to the encoded composite. FluxGuidance
(#5) balances how much the sampler should obey the reference versus your prompt. The model path runs UNETLoader
(#140) with Kontext followed by LoraLoaderModelOnly
(#141), which applies the Put it here LoRA. The composite is encoded by VAEEncode
(#10), sampled by KSampler
(#9), decoded by VAEDecode
(#7), previewed, and saved with SaveImage
(#19).
What to change:
CLIPTextEncode
to steer expression and local detail.AutoCropFaces
(#119 and #122)Detects faces and produces crop metadata for alignment and pasting. If the face is partially missed or includes hair you do not want, increase crop size slightly or lower detection confidence to pick up more context.
FaceAlign
(#121)Uses InsightFace landmarks to warp the source face onto the base face geometry before merging. Switch the analysis device in FaceAnalysisModels
(#120) to GPU
when available for faster alignment.
Image Paste Face
(#125)Blends the aligned face into the base image using the crop data. If edges look sharp or color is off, try a slightly larger crop box or reduce any post-prompt aggressiveness so FLUX does less overpainting around the border.
FluxKontextImageScale
(#134)Rescales the composite to the native shape expected by Kontext so the VAE can encode without distortion. Leave this in place to prevent stretching or drift in the refined output.
UNETLoader
(#140)Loads the Kontext-tuned FLUX UNet. Use this together with the LoRA for the intended behavior of FLUX Kontext Face Swap. Changing the checkpoint will noticeably alter skin texture and overall fidelity.
LoraLoaderModelOnly
(#141)Applies Put it here LoRA to localize reconstruction. If the swap drifts or edits spill outside the face, increase the LoRA influence slightly. If the look feels locked, reduce it for more creative freedom.
DualCLIPLoader
(#8) and CLIPTextEncode
(#6)Provide text conditioning. Keep prompts short and targeted to the face region and expression. Avoid global style cues if you want to preserve the base image background and clothing.
FluxGuidance
(#5)Balances how much the sampler trusts the reference composite. Raise it to preserve the base composition more tightly, lower it for stronger prompt-driven edits within the face area.
RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Playground, enabling artists to harness the latest AI tools to create incredible art.