You've generated an image you almost like, but one hand has six fingers or there's an object you don't want in the background. Regenerating will probably give you a completely different picture. Inpainting solves this: you mask the area you want changed and let the model repaint only that part.
This guide follows ComfyUI's official inpainting tutorial and examples. Forge PC hasn't run timed tests for this guide, and results depend on your model, prompt and seed.
What you need
ComfyUI installed and working. If it isn't yet, follow our guide to installing ComfyUI on Windows.
An inpainting model (recommended). ComfyUI's tutorial uses 512-inpainting-ema.safetensors, a dedicated inpainting checkpoint (the ComfyUI examples page calls it the v2 inpainting model). It goes in ComfyUI/models/checkpoints. The ComfyUI examples page says inpainting also works with ordinary models, but the official docs found the dedicated inpainting model gave more natural transitions than the standard SD 1.5 checkpoint.
An image to edit. You can use one of your own generations or a photo.
If your graphics card is short on memory, see how to run ComfyUI on low VRAM first.
Step 1: Load the inpainting workflow
Images that contain ComfyUI workflow data in their metadata can be dragged straight into ComfyUI, so the quickest start is to download the example workflow image from ComfyUI's inpainting tutorial and drag it into the ComfyUI window. You can also open it from the Workflows > Open menu (Ctrl+O).
Make sure the Load Checkpoint node is set to your inpainting model.
Step 2: Load your image
Upload your picture to the Load Image node. If the image already has a transparent (alpha) area, ComfyUI uses that as the mask, which is how the tutorial's example image works. Otherwise, you'll draw a mask in the next step.
Step 3: Draw the mask in the Mask Editor
Right-click the Load Image node and choose Open in MaskEditor.
Paint over the area you want changed. Use the panel on the right to adjust the brush, and the eraser to fix mistakes.
Click Save.
To refine a result you've already generated, right-click the Save Image node and choose Copy (Clipspace), then right-click Load Image and choose Paste (Clipspace). You can then mask and inpaint it again.
Step 4: Describe what should be there
Edit the positive prompt to describe what you want in the masked area, such as "an empty park bench", and use the negative prompt for anything you don't want. ComfyUI's docs suggest more specific prompts when results aren't right.
Step 5: Generate
Click Queue or press Ctrl+Enter. If you don't like the result, change the seed in the KSampler node and try again. The docs recommend trying several seeds.
Getting cleaner blends: grow_mask_by
The inpainting workflow uses a VAE Encode (for Inpainting) node, which takes your image, the VAE and the mask. Its grow_mask_by setting expands the mask outwards by a set number of pixels. That creates a transition zone so the repainted area doesn't end in a hard edge. If you can see a seam, try increasing it.
Outpainting uses the same idea
The ComfyUI examples page explains that outpainting, or extending an image beyond its borders, is the same process. A Pad Image for Outpainting node adds space around the image and creates the mask for you.
Where to go next
Our verdict
Inpainting is the quickest way to fix the one thing wrong with an otherwise good AI image. In ComfyUI, load the official inpainting workflow, use a dedicated inpainting checkpoint if you can, draw your mask in the Mask Editor, and raise grow_mask_by if the edges show. Then try a few seeds until it blends in.