Home » today » Technology » Powerful Inpainting and Outpainting with Stable Diffusion + ControlNet Model

Powerful Inpainting and Outpainting with Stable Diffusion + ControlNet Model

When retouching pictures, have you ever encountered “It would be better if it was a little more to the left!” “It would be better if it was a wider angle!” Before, I could only find a way to manually P out, but rely on the new Inpaint model launched by Stable Diffusion + ControlNet , in addition to inpainting the picture, it can also be extended to complete the picture (outpaintng)! It’s too strong! Come and see how it works!

Table of contents

preparation material

Download ControlNet Inpaint Model

ControlNet Inpaint Model Go to HuggingFace After downloading control_v11p_sd15_inpaint.pth and control_v11p_sd15_inpaint.yaml, put them into the stable-diffusion-webuiextensionssd-webui-controlnet folder.

Go back to StableDiffusion WebUI, restart it, if you see the ControlNet v1.1 block and Inpaint Model, it means the installation is complete!

Note: If ControlNet has been installed before, it must be updated to ControlNet v1.1 or above to have the inpaint function!

Prepare experiment pictures

In order to “contrast” the ability of Stable Diffusion to expand outward, I deliberately used the complete picture as a crop to remove the two sides, leaving the central part for AI to complete, and finally compared with the original picture

Cut out the test pattern on both sides

Inferring prompt words using Interrogate

In order to make the picture more perfect, you can use the built-in Interrogate CLIP or Interrogate DeepBooru in the Stable Diffusion img2img tab to deduce the prompt from the picture, and then manually modify it according to the situation, which is faster. The detailed steps are as follows:

Drag the image into the source block of the img2img tab and click the orange Interrogate CLIP button on the upper right (DeepBooru is also available, it will be generated as a keyword) Wait for a short calculation time, and the inferred prompt words will appear in the Positive Prompt input box backup

Outpainting with ControlNet Inpaint

Basic txt2img settings

Everything is ready, go back to the Stable Diffusion txt2img tab page and start the implementation:

Paste the Prompt just now, and increase the Negative Prompt Sampling Method appropriately: Choose Euler a, because the calculation speed is relatively fast, and it is used for preliminary composition Sampling Steps: First use the preset 20 Width / Hight: set to 784, 512 respectively, and the values ​​can be adjusted Free choice, but in order for him to be able to do outpainting, the proportion must be different from the original picture! For example, the original image is a vertical format. To make it outpainted into a banner, the width must be set to be larger than the height.Others keep the default

ControlNet settings

Next, the focus is on the settings of ControlNet:

Check enable and drag the picture to the source area Preprocessor: Select inpaint_only Model: Select control_v11p_sd15_inpaint Resize Mode: Select Resize and Fill, very important! Because it is necessary for him to fill the blank part, if he chooses wrong, there will be no outpainting!

further reading

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.