Inpaint (adv.)
The inpainter that crops first, so small fixes get full-res detail
- image
- mask
- model
- clip
- vae
- positive_conditioning
- negative_conditioning
- ui_widget
- image
- image_list
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(defaulttrue) - 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(default0) - 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_paddingso 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_autopick the alignment, or upscale the ROI to a cleaner target. - Nothing changed -
denoisetoo low (under ~0.3 on a fresh region barely does anything) or the mask isn't actually covering the thing you want replaced.
Inputs (24)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Base image. | |
| mask | MASK | Regions to inpaint (1=inpaint). Supports a single mask or a per-image mask list/batch. | |
| model | MODEL | Diffusion model. | |
| clip | CLIP | CLIP text encoder. | |
| vae | VAE | VAE for encode/decode. | |
| steps | INT | 201–10000 | Number of diffusion steps to use. |
| denoise | FLOAT | 0.450–1 | Denoising strength. Higher values produce more changes. |
| cfg | FLOAT | 7.000–100 | Classifier-Free Guidance scale. Higher values increase adherence to the prompt. |
| sampler | COMBO | dpmpp_2m | The sampler to use for the diffusion process. |
| scheduler | COMBO | karras | The scheduler to use for the diffusion process. |
| seed | INT | -1-1–18446744073709550000 | Seed for the random number generator. Use -1 for a random seed. |
| positive_promptopt | STRING | Prompt to guide the inpainting process. | |
| negative_promptopt | STRING | Prompt to discourage certain elements in the inpainting process. | |
| positive_conditioningopt | CONDITIONING | Conditioning inputs to guide the inpainting process. | |
| negative_conditioningopt | CONDITIONING | Conditioning inputs to discourage certain elements in the inpainting process. | |
| roi_autoopt | BOOLEAN | true | Whether to automatically determine the ROI. |
| roi_paddingopt | INT | 320–2048 | Padding to apply to the ROI. |
| roi_alignopt | INT | 81–128 | Alignment for the ROI. |
| roi_align_autoopt | BOOLEAN | false | Whether to automatically determine the ROI alignment. |
| roi_min_sizeopt | INT | 641–4096 | Minimum size for the ROI. |
| dilateopt | INT | 00–256 | Amount to dilate the ROI. |
| featheropt | INT | 00–256 | Amount to feather the ROI. |
| upsample_targetopt | INT | 00–16384 | Target size for upsampling. |
| ui_widgetopt | LF_COMPARE | [object Object] | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | Image tensor with inpainting effect applied. |
| image_list | IMAGE | List of image tensors with inpainting effect applied. |