Inpainting
The overall image looks great, but one corner is off — an extra finger, an unwanted bystander, a pattern that went sideways. Re-generating the whole image risks changing everything else; inpainting is the answer: you draw a boundary around “only this region can change,” and everything outside stays put.
The approach here follows the official tutorial — for a step-by-step version with screenshots, see ComfyUI Inpainting Workflow.
Three Things to Get Right
Section titled “Three Things to Get Right”- Mask: tells the model “which area to repaint.” Usually white marks what to change, black marks what to preserve (verify with your specific workflow).
- Use an inpaint-oriented model: a checkpoint specifically trained for “hole-filling” blends edges much more naturally. Using a regular text-to-image model often produces hard seams or jarring style shifts.
- Different encoding: a normal workflow encodes an empty latent or the full image; inpainting typically uses a node like
VAE Encoder (for Inpainting)to encode original image + mask together into latent space, so the sampler knows “what to preserve, what to regenerate.”
The official docs table worth remembering: pixels is the source image, mask defines the region, grow_mask_by expands the mask outward by a few pixels to create a transition zone at the seam — avoids a hard cut.
Typical Use Cases
Section titled “Typical Use Cases”- Fix flaws: remove unwanted objects, fix hands, fix faces.
- Isolate details: change only the clothing texture, change only the expression — leave everything else untouched.
Where Does the Mask Come From?
Section titled “Where Does the Mask Come From?”- Some assets include an alpha channel — import it and you effectively have a built-in transparent region as your mask.
- More often you’ll draw it yourself: right-click on Load Image, open Mask Editor, paint with a brush or erase, then save. The painted region feeds into the downstream encoding node. The Copy(Clipspace) / Paste(Clipspace) workflow shown in the official tutorial is for copying the previous output back in to continue editing — very handy.
What to Check When It’s Running
Section titled “What to Check When It’s Running”- Load Checkpoint: is it an inpaint model (or one you’ve confirmed fits your workflow)?
- Load Image: is the image correct? Is the mask correct?
- Positive / negative prompts: be specific about “what you want this region to become.” Don’t expect the model to guess.
- KSampler: try multiple seeds — inpainting usually requires a few tries before it looks right.
How This Fits the Full Pipeline
Section titled “How This Fits the Full Pipeline”The “painter revising a draft” logic from Introduction hasn’t changed — it’s still conditioning + sampling. The difference is: the starting point isn’t pure noise on a blank canvas — it’s “repainting with constraints applied to the original image.” Keep that in mind and you won’t get lost when switching nodes or workflows.
Further Reading
Section titled “Further Reading”- Comfy official: Inpainting workflow
- Built-in node reference: VAEEncodeForInpaint