Nodes/lf-nodes/Inpaint (adv.)
ComfyUI Node

Inpaint (adv.)

The inpainter that crops first, so small fixes get full-res detail

By lucafoscili·Created 2 years ago·Updated 6 days ago· 35
Inpaint (adv.)
  • image
  • mask
  • model
  • clip
  • vae
  • positive_conditioning
  • negative_conditioning
  • ui_widget
  • image
  • image_list
steps20
denoise0.45
cfg7.00
samplerdpmpp_2m
schedulerkarras
seed-1
positive_prompt
negative_prompt
roi_autotrue
roi_padding32
roi_align8
roi_align_autofalse
roi_min_size64
dilate0
feather0
upsample_target0

Fix a tiny flaw - a face, a hand, a text artifact - and the naive approach wastes your generation budget: the model renders the whole image and only the masked sliver matters. LF_InpaintAdvanced is LF's answer: it crops to the region of interest (ROI) around your mask, runs the diffusion pass at full detail on just that crop, and pastes it back. This is the "only masked" inpainting mode that the inpainting playbook credits with the best results for small detail fixes, because a 64px eye gets 1024px of generation budget.

It's the more capable sibling of LF_Inpaint. Same core idea - one node that runs the whole diffusion chain from model/clip/vae - but with ROI control, denoise as a proper 0–1 dial, a seed, and internal dilate/feather.

How it works

Same required pipeline: image, mask (1 = inpaint), model, clip, vae, plus steps (default 20), denoise (default 0.45), cfg (default 7), sampler (default dpmpp_2m), scheduler (default karras), and seed (-1 = random). Prompting is the same either-strings-or-conditioning choice as the plain node.

The ROI controls are what make it "advanced":

  • roi_auto (default true) - auto-detect the crop from the mask's bounding box. Keep it on.
  • roi_padding (default 32px) - breathing room around the mask so the model has context to blend against. The KB's rule of thumb is 32–64px of padding.
  • roi_align (8) / roi_align_auto - round the crop to a multiple the model and VAE are happy with.
  • roi_min_size (64) - floor on crop size so a tiny mask doesn't produce a uselessly small render.
  • dilate / feather - grow the mask and soften its edge before diffusion. Feather is your anti-seam knob; dilate widens the actual painted area.
  • upsample_target (default 0) - unlike the plain node, off by default. Set it if you want the crop itself upscaled before generation.

Outputs

image / image_list - the composited result with the inpainted crop pasted back. Compare widget previews original vs. result.

Installing it

One pack:

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

restart ComfyUI or install "LF Nodes" from ComfyUI Manager. Runs whatever checkpoint your graph loads; no extra downloads.

Where people get burned

  • Fixing a face and it looks pasted - raise roi_padding so the model sees more context, and feather a little. The crop has to blend, not just fill.
  • Scale mismatch after paste-back - if the model's native resolution is far from your crop size, let roi_align_auto pick the alignment, or upscale the ROI to a cleaner target.
  • Nothing changed - denoise too low (under ~0.3 on a fresh region barely does anything) or the mask isn't actually covering the thing you want replaced.
Category✨ LF Nodes/Filters

Inputs (24)

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.
stepsINT201–10000Number of diffusion steps to use.
denoiseFLOAT0.450–1Denoising strength. Higher values produce more changes.
cfgFLOAT7.000–100Classifier-Free Guidance scale. Higher values increase adherence to the prompt.
samplerCOMBOdpmpp_2mThe sampler to use for the diffusion process.
schedulerCOMBOkarrasThe scheduler to use for the diffusion process.
seedINT-1-1–18446744073709550000Seed for the random number generator. Use -1 for a random seed.
positive_promptoptSTRINGPrompt to guide the inpainting process.
negative_promptoptSTRINGPrompt 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.
roi_autooptBOOLEANtrueWhether to automatically determine the ROI.
roi_paddingoptINT320–2048Padding to apply to the ROI.
roi_alignoptINT81–128Alignment for the ROI.
roi_align_autooptBOOLEANfalseWhether to automatically determine the ROI alignment.
roi_min_sizeoptINT641–4096Minimum size for the ROI.
dilateoptINT00–256Amount to dilate the ROI.
featheroptINT00–256Amount to feather the ROI.
upsample_targetoptINT00–16384Target size for upsampling.
ui_widgetoptLF_COMPARE[object Object]

Outputs (2)

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