Nodes/Node_Fun_ComfyUI/No Fun Flux Kontext Inpaint Conditioning
ComfyUI Node

No Fun Flux Kontext Inpaint Conditioning

Masked inpainting that keeps the reference — Kontext conditioning without the drift

By nofunstudio·Created 2 years ago·Updated about a month ago· 9
No Fun Flux Kontext Inpaint Conditioning
  • conditioning
  • vae
  • pixels
  • mask
  • reference_latents
  • conditioning
  • latent
noise_masktrue

This node exists for one very specific workflow: inpainting with FLUX.1 Kontext that respects both a mask and a reference image. Standard inpainting regenerates a masked region and hopes the rest stays put. Kontext's whole thing is reference-based editing - feed it an image of a face, and it keeps that identity through the generation. This conditioning node bolts those two ideas together: mask the region, hand over reference latents (say, a face you want preserved), and Kontext fills the masked area while staying consistent with the reference.

Under the hood it does the plumbing that makes Kontext's inpainting format work. The code (adapted from ZenAI's, with a padding fix) does four things:

  1. Upsamples your mask to full image size with nearest-neighbor so it stays sharp instead of blurring.
  2. Pads both pixels and mask to multiples of 8 with reflect/replicate padding - this is the "padding fix" in the author's comment: no cropping, so nothing shifts between encode and decode.
  3. Wipes the masked pixels before VAE-encoding, so the model only "sees" the region you want regenerated as empty space.
  4. Packs all of it into the conditioning keys Kontext expects - concat_latent_image and concat_mask - and appends your reference_latents so the reference is only applied inside the mask area.

The inputs, from the schema:

  • conditioning - the text conditioning for the Kontext model.
  • vae - the Flux VAE, used to encode the pixels and mask.
  • pixels - your input image.
  • mask - where to inpaint. This is the entire point of the node.
  • reference_latents - a LATENT holding the reference (e.g. face latents from a face-latent port). This is what keeps identity consistent; leave it disconnected and the reference part of the mechanism does nothing.
  • noise_mask (default true) - restrict noise to the masked region only. Keep it on unless you have a reason not to.

Outputs: conditioning goes to the KSampler's positive input, and latent goes to the sampler's latent_image input. That's the pairing the Kontext inpainting graph needs - one node replaces the usual mess of separate conditioning and mask-encoding nodes.

Now the honest part. Kontext is a 12B instruction editor, and by mid-2026 the KB's verdict is blunt: as an editor, Klein 9B and Qwen-Image-Edit beat it, and its own users call it a "tech demo" with heavy censorship. But it holds one real advantage: a LoRA library that was never retrained for the newer models, plus the ability to be prompted into genuinely new compositions. And the niche this node targets - masked inpainting with reference preservation, bit-identical unmasked pixels - is exactly the thing the pure instruction models can't do without drift. The KB frames it well: Qwen and Kontext "tend to shift other details not asked for," so putting a mask back on is the standing fix.

Installation is the pack standard: ComfyUI Manager search "Node Fun", or clone https://github.com/nofunstudio/Node_Fun_ComfyUI into custom_nodes, pip install -r requirements.txt, restart. The real setup cost is the model itself: you need the FLUX.1 Kontext dev checkpoint, which is gated on HuggingFace and runs heavy - plan for serious VRAM. And if you're here, the KB's advice applies: for the "change one object, leave everything else untouched" job, Kontext with a mask is still the tool that keeps the rest of the frame exact. Just don't expect it to be the fastest thing on your disk - the community clocked Kontext at roughly 3× slower than its successors.

Categoryconditioning/inpaint

Inputs (6)

NameTypeDefaultDescription
conditioningCONDITIONING
vaeVAE
pixelsIMAGE
maskMASK
reference_latentsLATENT
noise_maskBOOLEANtrueRestrict noise to the mask region.

Outputs (2)

NameTypeDescription
conditioningCONDITIONING
latentLATENT