Nodes/Fat Mex Nodes/Fat Mex Inpaint Sampler
ComfyUI Node

Fat Mex Inpaint Sampler

Head swaps without the ten-node spaghetti

By FatMex·Created 7 months ago·Updated 7 months ago· 3
Fat Mex Inpaint Sampler
  • model
  • clip
  • vae
  • target_image
  • mask
  • image1
  • image2
  • images
  • latent
promptReplace the masked head area with the person of image 1. Match the head shape, rotation and lighting of the source image.
negative_promptugly, blurry, deformed, bad anatomy, plastic skin
seed0
grow_mask_by6
preset_hintauto
steps8
cfg0.0
sampler_nameauto
schedulerauto
denoise1.00

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 denoise 1.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). image2 is 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; match preset_hint to 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.
CategoryFat Mex

Inputs (17)

NameTypeDefaultDescription
modelMODELModel from Fat Mex Model Loader (Qwen Edit preset).
clipCLIPCLIP from Fat Mex Model Loader.
vaeVAEVAE from Fat Mex Model Loader.
target_imageIMAGEThe image to inpaint on (e.g. the body image).
maskMASKMask defining the area to regenerate (e.g. from FatMexHeadMask).
promptSTRINGReplace 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_promptSTRINGugly, blurry, deformed, bad anatomy, plastic skin
seedINT00–18446744073709550000
image1optIMAGEReference image 1 (e.g. the face to swap in).
image2optIMAGEReference image 2 (optional — e.g. the target body for context).
grow_mask_byoptINT60–64Expand mask edges for seamless inpainting (matches VAEEncodeForInpaint).
preset_hintoptCOMBOauto8 options: auto, Klein 9B, Klein 9B True, Qwen Image Edit 2509, Qwen Image Edit 2511, Qwen Image 2512, +2
stepsoptINT81–100Inpaint steps.
cfgoptFLOAT0.00–100
sampler_nameoptCOMBOauto45 options: auto, euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, +39
scheduleroptCOMBOauto10 options: auto, simple, sgm_uniform, karras, exponential, ddim_uniform, +4
denoiseoptFLOAT1.000–1Inpaint denoise strength. 1.0 fully regenerates masked area.

Outputs (2)

NameTypeDescription
imagesIMAGE
latentLATENT