Nodes/lf-nodes/Inpaint
ComfyUI Node

Inpaint

Inpaint without a separate KSampler

By lucafoscili·Created 2 years ago·Updated 7 days ago· 35
Inpaint
  • image
  • mask
  • model
  • clip
  • vae
  • positive_conditioning
  • negative_conditioning
  • ui_widget
  • image
  • image_list
steps16
denoise_percentage40
cfg7.0
positive_prompt
negative_prompt
upsample_target1024
samplerdpmpp_2m
schedulerkarras

Inpainting in stock ComfyUI is a small chore: you wire a VAE encode, a patch, a sampler, a decode, and a composite, and you hope the pieces line up. LF_Inpaint collapses that whole chain into one node. You hand it an image, a mask, a model, a CLIP and a VAE - it runs the diffusion pass and returns the inpainted image. If you've ever stared at a "paint out that power line / fix that face / remove that watermark" workflow and wished it were a single box, this is that box.

It sits squarely in the "mask-based inpainting" camp, and the knowledge base has a clear-headed take on why that still matters in the era of instruction-edit models: an edit model regenerates everything and drifts, while a mask inpainter leaves the unmasked pixels bit-identical. If you need exactly-one-region changed and nothing else moved, this is the tool.

How it works

The node runs the diffusion itself - model, clip, vae go straight in, no separate KSampler, no latent encode/decode nodes. Required basics: mask (1 = inpaint, per-image masks/batches supported), steps (default 16), cfg (default 7), and the critical one, denoise_percentage. It's 0–100 rather than the 0–1 denoise you usually see: 40% (the default) means a moderate rewrite of the masked area, ~10–25% for subtle fixes, 80%+ for full regeneration inside the mask.

Two ways to drive the generation: either positive_prompt / negative_prompt strings (simplest), or pre-built positive_conditioning / negative_conditioning from a CLIP Text Encode node if you want conditioning the rest of your graph already built. You can also swap sampler (44 options, default dpmpp_2m) and scheduler (default karras).

The gotcha worth knowing

upsample_target defaults to 1024. If your input is smaller, the image and mask get upscaled to ~1024 on the long side before inpainting and pasted back down afterward. That's actually the intended detail-boosting behavior - small crops get a bigger generation budget - but it's easy to mistake for the node resizing your image. Set it to 0 if you want no upsampling at all.

Outputs

image / image_list - the inpainted result. Compare widget shows before/after. That's the entire interface.

Installing it

lf-nodes installs as one pack:

cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/lf-nodes

then restart ComfyUI (or ComfyUI Manager → "LF Nodes"). No extra model - it runs whatever checkpoint your graph already loads.

Troubleshooting

  • Too much change - the 40% default is a rewrite. For a stray speck or a small flaw, drop denoise_percentage to 10–20 first.
  • Seams at the mask edge - feather the mask before it reaches this node (or use the advanced variant, which feathers internally).
  • Squashed output - almost certainly upsample_target doing its job on a small input. Set it to 0 and try again.
Category✨ LF Nodes/Filters

Inputs (16)

NameTypeDefaultDescription
imageIMAGEBase image.
maskMASKRegions to inpaint (1=inpaint). Supports a single mask or a per-image mask list/batch.
modelMODELDiffusion model.
clipCLIPCLIP text encoder.
vaeVAEVAE for encode/decode.
stepsINT161–10000Number of diffusion steps to use.
denoise_percentageFLOAT400–100Percentage of denoising to apply.
cfgFLOAT7.00–100Classifier-free guidance scale.
positive_promptoptSTRINGThe prompt to guide the inpainting process.
negative_promptoptSTRINGThe prompt to discourage certain elements in the inpainting process.
positive_conditioningoptCONDITIONINGConditioning inputs to guide the inpainting process.
negative_conditioningoptCONDITIONINGConditioning inputs to discourage certain elements in the inpainting process.
upsample_targetoptINT10240–16384If greater than 0, the image and mask will be upsampled to this size before inpainting.
sampleroptCOMBOdpmpp_2mThe sampler to use for the diffusion process.
scheduleroptCOMBOkarrasThe scheduler to use for the diffusion process.
ui_widgetoptLF_COMPARE[object Object]

Outputs (2)

NameTypeDescription
imageIMAGEImage tensor with inpainting effect applied.
image_listIMAGEList of image tensors with inpainting effect applied.