Fat Mex Inpaint Sampler
Head swaps without the ten-node spaghetti
- model
- clip
- vae
- target_image
- mask
- image1
- image2
- images
- latent
Put a face into a photo and make it look like it belongs there. That's the job this node was built for - head swaps, face edits, replacing an object in a scene. In a raw graph it takes VAEEncode + SetLatentNoiseMask + TextEncodeQwenImageEditPlus + KSampler + VAEDecode, which is six nodes of careful wiring before you've even started failing. Here it's one box: target image, mask, reference face, prompt.
How it works - and the honest caveat
Read the source before you assume this is classic mask-locked inpainting, because it isn't. The implementation does full-canvas Qwen Edit regeneration:
- Your target image becomes Picture 1, fed to the vision encoder for pose/scene context only (no reference latent attached - that would fight the face).
- Your reference face becomes Picture 2, and this one gets the strong ~1MP reference latent, so identity comes through loud and clear while the body's context doesn't dilute it.
- The negative conditioning is zeroed out rather than text-encoded - a community-known trick that dramatically improves Qwen 2509 quality by forcing the model to use the reference latent instead of its own low-quality internal image copies.
- It generates from an empty latent at your target's dimensions at
denoise1.0.
The mask input is accepted, but in the current build it isn't consumed during sampling - the author's own comments say the mask is reserved for post-compositing, and that compositing step isn't in this version. So don't expect the unmasked regions to be locked in place. As the KB's inpainting doc puts it, edit models take the whole image into context and emit a whole new image, and the drift compounds if you chain edits.
That doesn't make it useless - it makes it predictable. For head swaps specifically, letting the model re-render the whole frame is often exactly what you want, because seams disappear. Just know what you're getting.
The inputs that matter
target_image- the photo to edit.image1- the face to swap in (referenced as "image 1" in the prompt).image2is optional context.prompt- a sensible default ships ("Replace the masked head area with the person of image 1. Match the head shape, rotation and lighting…"). Edit it to taste.mask- feed one (Fat Mex Head Mask makes them), it's required by the schema, and one day it'll composite; today it's largely vestigial.steps(default 8),denoise(1.0),preset_hint- sampling controls; matchpreset_hintto the Qwen Edit preset you loaded.model,clip,vae- from the Model Loader, and load a Qwen Image Edit preset, same as the Image Edit Sampler.
Outputs: images and latent.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/FatMex/ComfyUI-FatMex-Nodes.git FatMex-Nodes
pip install -r FatMex-Nodes/requirements.txt
Or ComfyUI Manager → search "Fat Mex Nodes" → Install → restart.
Where people get burned
- Expecting masked inpainting. If you wire a tight mask expecting everything outside it to stay pixel-identical, you'll be confused. This regenerates the canvas; the mask is there for future compositing. Plan around full-frame edits.
- Reference quality. A clean, well-lit, front-facing face reference is most of the result. A dark, angled selfie gives you a dark, angled result - the same law as every identity tool.
- Background drift on chains. Since the whole frame re-renders, run your edit, then upscale/final-pass, and don't re-inpaint repeatedly or the background will wander.
- Wrong preset loaded in the loader - Klein or Z-Image instead of a Qwen Edit family. You'll get an error or nonsense, and the error points at the loader, not here.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | Model from Fat Mex Model Loader (Qwen Edit preset). | |
| clip | CLIP | CLIP from Fat Mex Model Loader. | |
| vae | VAE | VAE from Fat Mex Model Loader. | |
| target_image | IMAGE | The image to inpaint on (e.g. the body image). | |
| mask | MASK | Mask defining the area to regenerate (e.g. from FatMexHeadMask). | |
| prompt | STRING | Replace the masked head area with the person of image 1. Match the head shape, rotation and lighting of the source image. | Describe the inpaint. Use 'image 1' to reference the face. |
| negative_prompt | STRING | ugly, blurry, deformed, bad anatomy, plastic skin | — |
| seed | INT | 00–18446744073709550000 | — |
| image1opt | IMAGE | Reference image 1 (e.g. the face to swap in). | |
| image2opt | IMAGE | Reference image 2 (optional — e.g. the target body for context). | |
| grow_mask_byopt | INT | 60–64 | Expand mask edges for seamless inpainting (matches VAEEncodeForInpaint). |
| preset_hintopt | COMBO | auto | 8 options: auto, Klein 9B, Klein 9B True, Qwen Image Edit 2509, Qwen Image Edit 2511, Qwen Image 2512, +2 |
| stepsopt | INT | 81–100 | Inpaint steps. |
| cfgopt | FLOAT | 0.00–100 | — |
| sampler_nameopt | COMBO | auto | 45 options: auto, euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, +39 |
| scheduleropt | COMBO | auto | 10 options: auto, simple, sgm_uniform, karras, exponential, ddim_uniform, +4 |
| denoiseopt | FLOAT | 1.000–1 | Inpaint denoise strength. 1.0 fully regenerates masked area. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| latent | LATENT | — |