Build a website with Next.jsBuild a Discord bot with PythonBuild an app with SwiftUIPush your own modelPush a Diffusers modelPush a Transformers modelPush a model using GitHub ActionsDeploy a custom modelFine-tune a language modelGet a GPU machine
Home / Guides / Stable diffusion

Inpainting with Stable Diffusion


Inpainting is like an AI-powered erasing and painting tool.

It can be used to:

  • remove unwanted objects from an image
  • replace or change existing objects in an image
  • fix ugly or broken parts of a previously generated image
  • expand the canvas of an image (outpainting)

It is similar to image-to-image.

Input
prompt
An orange cat sitting on a bench
prompt_strength
0.8
image
mask
seed
47363
Output

Prompt strength and inpainting

You can use the 'prompt strength' parameter to change how much the starting image guides the area being inpainted.

A value of 0.65 will keep the same colors and some of the structure that was there before, but will also generate new content based on the prompt.

Setting prompt strength to 1 will completely ignore the original image and only generate new content.

In the example below, you can see the difference – the cat is no longer dependent on the white-ish color of the dog – it is now much more orange as specified in the prompt.

Input
prompt
An orange cat sitting on a bench
prompt_strength
1
image
mask
seed
47363
Output

In this guide, we've covered how to use inpainting to remove unwanted objects from an image, replace or change existing objects in an image, and fix ugly or broken parts of a previously generated image. But you can also use it to expand the canvas of an image. Check out the outpainting guide to learn more about that process.

Inpainting vs outpainting

Outpainting expands the canvas of an image. Consider a portrait photo where the top of the head is cropped out. Outpainting can be used to generate the missing part of the head.

It’s very similar to inpainting. But instead of generating a region within an existing image, the model generates a region outside of it. Learn more about outpainting.