[Stable Diffusion] Explain how to use the Inpainting function in img2img!

  • How can I use the Inpainting function of img2img?
  • I heard it's very convenient...
  • I want to know how to fix illustrations with pinpoint!

We will answer these questions for you.

[Stable Diffusion] Explain how to use the Inpainting function in img2img!
[Stable Diffusion] Explain how to use the Inpainting function in img2img!

[Stable Diffusion] Explain how to use the Inpainting function in img2img!

Stable Diffusion img2img allows you to modify the illustration with the Inpainting function. If you don't know this feature, you'll have to redo the gacha just because you don't like a part of your finger. It becomes difficult to get the illustration you want.

In this article, I will explain about :

  • [Stable Diffusion] Basic knowledge of the Inpainting function that can be used with img2img
  • [Practice! ] How to use the Inpainting function
  • If you want to generate illustrations more smoothly...
  • How to easily manage a large number of generated illustrations

so if you read to the end, you will understand how to use the Inpainting function to correct the illustration.

If you want to know how to use img2img in general, please read the following articles as well. It is explained with an illustration that was actually generated.

>> [Stable Diffusion] Explain how to use img2img to generate images from images!

[Stable Diffusion] Basic knowledge of the Inpainting function that can be used with img2img :

Inpainting is a function that partially corrects an image. The advantage is that you can pinpoint the range you want Stable Diffusion to redraw.

It will be useful for correcting part of the illustration and improving the completeness as a whole, such as when "The composition is good, but the fingers are...".

Inpainting operation screen :


Inpainting is a function within img2img mode. Make partial corrections to the original image while making full use of prompts and various settings.

Throw in an image and you'll see three icons on the right :
  • Upper left arrow icon: Return to the previous state.
  • X icon on the top right: Delete the image.
  • Lower right brush icon: change the size of the brush.
Each of them has the following roles. It's a little small, so it's hard to see, but you'll need to press it often, so remember it.

At the bottom of the screen are the following setting items:
  • Mask blur
  • Mask mode
  • Masked content
  • Inpaint area
  • Only masked padding, pixels
Other items (Sampling method, Sampling steps, etc.) are the same as txt2img, so if you want to know more, please read the article below.

Mask blur

A value that determines how much to blur the borders of the masked range.

When Mask blur is increased to "10", the border becomes blurred, making it difficult to see where the mask range is.

If you want it to blend in with the surroundings, you should increase the number a little.

Mask mode

  • Inpainting masked
  • Inpainting not masked
Mask mode can be selected from these two types.

Inpainting masked will redraw the area within the masked area.

Areas other than the mask are redrawn. This is a good choice if there are only a few parts that you do not want to modify.

If you need to fix most of it, I think it's better to start with a different image from the beginning...

Masked content

This is the type of method for how to redraw the masked area :
  • fill
  • original
  • latent noise
  • latent nothing
Let's look at them in order. Note that Denoising strength is set to 0 in the verification environment.

It is convenient because Stable Diffusion draws with a good feeling when the number is increased.

fill

It is a method to fill the masked range based on the "surrounding color".

Filling the mask range with the surrounding colors = Elements in the mask are easy to erase, so it is suitable for erasing unnecessary parts.

original

It is a method of filling the masked range based on the "original image".
Currently, the denoising strength is 0, so the illustration is exactly the same as the original image.

Unlike "fill", it respects the original image, so select it when you want to arrange or modify the mask range. I usually use "original".

latent noise

It is a method to fill the masked range based on "noise".

It returns to noise once and redraws from there.

Unlike "original", the original image is not taken into account at all, so the result may be unexpected (denoising strength: 0.7).

latent nothing

This is a method to fill in the masked range based on the "color of the masked range".
The hair color has an effect, making it more brownish than when it was "fill".

Inpainting area

  • whole picture.
  • Only masked.
If you select Only Masked, only the masked area will be resized and redrawn and then pasted to the original image. When generating a high-quality illustration, you may notice that the resolution is low only for the redrawn parts! It's a function that prevents this from happening.

If you want the masked part to be fully drawn, you should select Only Masked.

Only masked padding, pixels

This is a numerical value for how much margin to set when Only masked is selected. Rather than making fine adjustments here, I think it is more efficient to specify the mask range accurately in the first place (author's personal opinion).

[Practice! ] Simple usage of Inpainting function :

Simple usage of Inpainting function
Simple usage of Inpainting function

Now that you understand the meaning of each item, let's actually use Inpainting to correct the illustration. There is no end to Inpainting , so I will only tell you a simple practical method.

AI illustrations
AI illustrations

In this illustration, there are only four fingers on the right hand. There are AI illustrations.

Let's correct it so that it has five fingers :


Throw it in Inpainting and mask it so that it covers the entire right hand.
  • Prompt: open hands.
  • Negative prompt: missing finger.
  • Mask blur: 4.
  • Inpaint masked.
  • original.
  • Denoising strength: 0.5.
If you draw about 10 pictures with settings like this :


At least a few illustrations with five fingers should be generated.

At this time, the value of Denoising strength is important. If it's too small, you'll still have 4 fingers in order to respect the original illustration. Try it while adjusting the numbers.

To keep the story simple this time, I didn't put any extra prompts, but quality-up prompts and LoRA are also effective. Add as appropriate.

It is also possible to re-throw in Inpainting the illustration after correcting it with Inpainting, so please continue to make corrections until you are satisfied and improve the quality of your favorite illustration.
Next Post Previous Post
No Comment
Add Comment
comment url