[Beginner's Guide] How to remove undesirable objects with AI inpainting

[Beginner's Guide] How to remove undesirable objects with AI inpainting

AI  Learning Assistant No 1
AI Learning Assistant No 1
July 28th, 2023

There’s an old post in Reddit showcasing a daunting tasks of removing the ex wife from a family photo. I surely can’t pull it off with my amateur Photoshop skill. But that was before the time of Stable Diffusion…. Let’s find out what we can achieve with inpainting.

In this post, I am going to show you how use inpainting function of Stable Diffusion to remove object (a person in this case) and reconstruct the background.

Software for inpainting

We will use this Stable Diffusion GUI for this tutorial. See my quick start guide for setting up in Google’s cloud server.

What is inpainting?

Inpainting is a technique that Stable Diffusion only redraws part of an image. Specifically, you supply an image, draw a mask to tell which area of the image you would like it to redraw and supply prompt for the redraw. Then Stable Diffusion will redraw the masked area based on your prompt.

To access the inpainting function, go to img2img tab, and then select the inpaint tab. Make sure the Draw mask option is selected. Upload the image to the canvas.


Adjust image size based on your original image. Because my image is in landscape orientation, I used size 768×512 pixels.

Select the batch size of 8 so that you can cherry pick the best image.

Let’s remove the ex…

OK, let’s get started. Since I don’t have access to the original image, I took a screenshot of the video and use as the input image:

In the GUI, draw a mask covering the area you want to erase and redraw. I’m starting with the main subject. My mask looks like this:

Now supply the prompt of the background

photograph of a lake, tree, wooden deck, wooden fence Press Generate. The inpainted image then generated:

Not perfect but not too shabby! The deck floor and the legs are not quite right but we can fix them later. The deck fence is in a pretty good shape. Now let’s fix up the gentleman’s black pant and the floor. photograph, pant, wooden deck

Fix the pant and floor one more time…

black pant, wooden deck

Now remove the long white dress behind the in-laws (?):

wooden deck, leg

Remove the word REMOVE and the arrow in the sky…

tree, sky It’s missing a deck board between the deck and the fence, let’s fix it.

wooden deck, lake

Fix the gentleman’s arm…

lake, black jacket

Finally, the deck floor the bride originally stood on is a bit unnatural. Let’s fix it.

wooden deck

Now are done! Let’s look at the before and the after side-by-side.

I think it’s pretty good given we made less than 10 edits!


In this post, I showed you how easy it is to use inpainting to remove unwanted objects in a photo. What would have taken a professional Photoshop user hours can be done in fewer than 10 steps using inpainting with Stable Diffusion. I hope you too can use this powerful tool to accomplish what previously think only a professional can do!

To see more content about Stable Diffusion from zero click:https://www.hayo.com/article/64c21001ef669957a0d21e63

Reprinted from View Original
Collection Navigation
# 1 [Beginner's Guide] Stable Diffusion Absolute beginner’s guide (+online demo)
# 2 [Beginner's Guide] How to use img2img to turn an amateur drawing to professional with Stable Diffusion (Image-to-image)
# 3 [Stable Diffusion Repair] Beginner’s guide to inpainting (step-by-step examples)
# 4 [Beginner's Guide] How to remove undesirable objects with AI inpainting
# 5 [Beginner's Guide] Video to video with Stable Diffusion (step-by-step)
# 6 [Beginner's Guide] How do you use Stable Diffusion AI?
# 7 [Beginner's Guide] Top Free Stable Diffusion AI image generator sites
# 8 [Beginner's Guide] Stable Diffusion prompt: a definitive guide
# 9 [Beginner's Guide] Instruct Pix2Pix: Edit and stylize photos with text
# 10 【Beginner's Guide to Stable Diffusion】How to build a good prompt?
# 11 【Beginner's Guide to Stable Diffusion】Rules of thumb for building good prompts
# 12 【Beginner's Guide to Stable Diffusion】What is ChatGPT?
# 13 【Beginner's Guide to Stable Diffusion】Sorting out high-quality prompt words from ChatGPT
# 14 【Beginner's Guide to Stable Diffusion】How to use negative prompts?
# 15 【Beginner's Guide to Stable Diffusion】Negative prompt is important for v2 models
# 16 【Beginner's Guide to Stable Diffusion】Boilerplate negative prompts in v2 model
# 17 【Beginner's Guide to Stable Diffusion】What are those parameters, and should I change them?
# 18 【Beginner's Guide to Stable Diffusion】How many images should I generate?
# 19 【Beginner's Guide to Stable Diffusion】Common ways to fix defects in images
# 20 【Beginner's Guide to Stable Diffusion】Garbled faces and eyes problems
# 21 【Beginner's Guide to Stable Diffusion】How to use VAE to improve eyes and faces
# 22 [Beginner's Guide] How to install Stable Diffusion on Windows (AUTOMATIC1111)
# 23 【Beginner's Guide to Stable Diffusion】Beginner’s guide to inpainting (step-by-step examples)
# 24 【Beginner's Guide to Stable Diffusion】What are custom models?
# 25 【Beginner's Guide to Stable Diffusion】How to control image composition?
# 26 【Beginner's Guide to Stable Diffusion】Generating specific subjects
# 27 [Beginner's Guide] How to install and run Stable Diffusion on Apple Silicon M1/M2 Macs
# 28 [Beginner's Guide] Try the Stable Diffusion online demo
# 29 [Beginner's Guide] Beginner’s guide to Stable Diffusion models and the ones you should know
# 30 [Beginner's Guide] What Can Stable Diffusion Do?
# 31 [Beginner's Guide] Realistic human street portrait
# 32 [Beginner's Guide] How to generate animals in Stable Diffusion


no dataCoffee time! Feel free to comment