Skip to content

How-ToGPU

How to Inpaint in ComfyUI: Fix Part of an AI Image Without Starting Again

Inpainting repaints only the masked part of an image. In ComfyUI, load the official inpainting workflow, use an inpainting checkpoint such as 512-inpainting-ema, draw a mask in the Mask Editor, describe the change and queue it. Raise grow_mask_by in VAE Encode (for Inpainting) if you can see seams, and try a few seeds.

By , Editorial team

3 min read

How to Inpaint in ComfyUI: Fix Part of an AI Image Without Starting Again

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

  1. Right-click the Load Image node and choose Open in MaskEditor.

  2. Paint over the area you want changed. Use the panel on the right to adjust the brush, and the eraser to fix mistakes.

  3. 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.

The bottom line

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.

Sources

  1. 01ComfyUI documentation, ComfyUI Inpainting Workflow
  2. 02ComfyUI Examples, Inpaint Examples

About the author

Forge PC Staff

Editorial team

The shared byline for articles researched, written and edited by the Forge PC editorial team. How we source, check and correct our work is set out in our editorial policy.

More from Forge PC Staff

Read next

HDR10 vs HDR10+ vs Dolby Vision on PC: What Your Monitor's HDR Badge Means

Versus

HDR10 vs HDR10+ vs Dolby Vision on PC: What Your Monitor's HDR Badge Means

HDR10 uses static metadata and is the format Windows HDR is built around. HDR10+ adds royalty-free dynamic metadata, and HDR10+ Gaming certifies both monitor and GPU. Windows picks Dolby Vision automatically on certified monitors, but Microsoft warns some cap brightness in that mode. Panel brightness and contrast matter more than the badge.

Forge PC Staff3 min

How to Fix Games Crashing on PC: A Step-by-Step Checklist for Windows 11

How-To

How to Fix Games Crashing on PC: A Step-by-Step Checklist for Windows 11

Most PC game crashes come from drivers, corrupted files or unstable overclocks. Update, roll back or clean-install the graphics driver, verify the game's files, run DISM and SFC, and reset GPU and memory tuning to stock. If crashes continue, check temperatures, test RAM with MemTest86 and look at the power supply.

Forge PC Staff3 min

KoboldCpp vs LM Studio: Which Local AI App Should You Use?

Versus

KoboldCpp vs LM Studio: Which Local AI App Should You Use?

KoboldCpp is a single, install-free executable built on llama.cpp, with CUDA and Vulkan builds plus image, speech and agent features and a story-writing UI. LM Studio is a polished app that finds and downloads models for you and serves them over an OpenAI-like API. LM Studio suits most people; KoboldCpp suits tinkerers and writers.

Forge PC Staff3 min

How to Use Radeon Chill: Cut Power, Heat and Fan Noise on AMD Graphics Cards

How-To

How to Use Radeon Chill: Cut Power, Heat and Fan Noise on AMD Graphics Cards

Radeon Chill lowers your frame rate when there's little movement in a game and ramps it up when the action starts, saving power and heat. Turn it on in AMD Software's Global Graphics, set Min and Max FPS, override per game and toggle it with Alt+F11. It disables Anti-Lag and Boost and doesn't work with UWP games.

Forge PC Staff3 min