ow-to-use-outpainting

Are you familiar with Stable Diffusion and its ability to expand images in all directions? This technique, known as outpainting, allows for creating a cohesive background outside the image frame. This article will provide a step-by-step guide on achieving this using the AUTOMATIC1111 GUI. Additionally, we will introduce other painting models that can serve as alternative options.

Step-By-Step Guide

To prepare your image, start by centering it and adjusting its size to landscape orientation using a technique called “outpainting.” This is the first step in the process.

Upload Image to AUTOMATIC1111

If the image was created using the AUTOMATIC1111 GUI, the prompts and other parameters used for its generation can be found in the metadata of the PNG file.

To access this information in the AUTOMATIC1111 GUI, go to the PNG Info tab and drag the image from your local storage to the canvas area. The generation parameters should appear on the right-hand side of the screen.

To send the image and parameters for outpainting, click the “Send to img2img” button. The appearance and prompt will then appear in the img2img sub-tab of the img2img tab.

If your starting image was not created using the AUTOMATIC1111 GUI, simply proceed to the img2img tab and upload the image to the canvas area. You must write a prompt that accurately describes the image and style.

Alternatively, you can use the “Interrogate CLIP” feature to generate a prompt automatically, but the quality of the prompt may not be optimal in some cases.

The image was created using the AUTOMATIC1111 GUI

Adjust Parameters for Outpainting

To get started with outpainting, it’s essential to choose an appropriate model. For consistency in style, it’s best to use the same model to generate the original image. For instance, if you used the F222 model to generate your image, you should use the same model for outpainting.

If you used the v1.4 or v1.5 base models, or you’re working with a photograph, you could also use the v1 inpainting model. This is supposed to give better results, although I’ve succeeded without using it.

If you used PNG Info, the image size should have been automatically set correctly. However, for custom images, it’s essential to set the shorter side to the native resolution of the model (e.g., 512 px for v1 models), and adjust the longer side accordingly to maintain the aspect ratio.

Set the resize mode to crop and resize to ensure the aspect ratio doesn’t change.

To get different results each time, set the seed to -1.

The denoising strength can be adjusted to achieve different effects, and you may have fun playing around with this parameter. For now, let’s set it to 0.6.

You can use your standard text-to-image settings for the rest of the settings. For completeness, here’s what I use:

  • Sampling method: DPM++ 2M Karras
  • Sampling steps: 30
  • Batch size: 4

Enable Outpainting Script

To access the outpainting options, locate the Script drop-down menu. Two options are available: (1) outpainting mk2 and (2) poor man’s outpainting. The first option, outpainting mk2, is not very effective, so choosing the second option, poor man’s outpainting, is recommended.

When using poor man’s outpainting, it’s suggested to expand the pixels to 128 and select “fill” for masked content. This will use the image’s average color to fill in the expanded area before outpainting.

For optimal results, it’s best to outpaint one direction at a time. For example, you can choose the right outpaint direction for a particular image.

Once you’ve selected it, click “Generate” to create your new image. You can regenerate as many times as necessary until you find an image you like.

To adjust the amount of change in the image, you can increase or decrease the denoising strength. Increasing the strength will result in more changes, while reducing it will result in fewer changes. It’s as simple as that!

Center an Image

To center your character in the image, you can first center the image itself. This will ensure that the enlarged pixels appear visually consistent with the rest of the image. Once you have centered the image, you can send it to img2img for further processing by hitting the “Send” button under the resulting canvas. This will allow you to iterate the process and make any necessary adjustments.

Convert to Landscape Size

To transform a portrait-sized image into a landscape orientation, we can repeatedly extend its left and right sides. This alteration can significantly alter the viewer’s perception of the image. By doing so, the image no longer depicts a close-up of the subject but instead showcases a larger background. This change in composition creates a striking contrast and can significantly impact the image’s overall appearance.

Fix Details With Inpainting

It is not necessary to worry too much about the details of the extended part of the image because you can always use the “inpainting” technique to regenerate any areas later. In the following steps, I will explain how to regenerate the entire right-hand side of the image.

To start, click on “Send to Inpainting” to transfer the newly generated image to the inpainting tab. Then, select the “Inpaint” tab and use the paintbrush tool to create a mask on the area you want to regenerate.

You can use the inpainting technique to regenerate any areas

Here are some settings that you can use for the inpainting process:

  • Mask mode: “Inpaint masked”
  • Inpaint area: “Only masked”
  • Only masked padding, pixels: 36-72 (you can adjust this as needed)
  • Script: None (remember to turn off the outpainting script!)
  • Denoising strength: 0.6-0.9 (you may need to adjust this based on the result)
  • Batch size: 2-4 (you can generate multiple images at a time for comparison)
  • Seed: -1 (random)
  • Masked content: original or fill (fill will use the average color under the mask as the initial value)

Outpainting Complex Scenes

The Stable Diffusion method is effective for simple backgrounds but may encounter difficulties with more complex scenes. This is because the method only considers a small area of the image next to the outpainted area, which is insufficient for extending a complex scene that requires long-range information to be considered.

While the Stable Diffusion method is unsuitable for this task, the MAT (Mask-Aware Transformer) is an excellent inpainting/outpainting method that is available. It is a GAN (Generative Adversarial Network) model that is specifically designed to account for long-range information when creating missing parts of an image.

MAT Outpainting

MAT outpainting is an efficient method that produces superior results compared to other approaches. To use MAT outpainting, visit the Stable Diffusion Mat Outpainting website. The user interface only supports generating square images, which can be cropped to landscape size for a larger image.

Scale is a parameter that adjusts the size of the uploaded image before the outpainting process.

Example: The scale was set to 1 and the output size to 768, resulting in the outpainting of a 512×768 image to a final size of 768×768 by extending the left and right sides.

Conclusion

Outpainting is a powerful technique for extending images and creating seamless image backgrounds. Understanding the basic principles of outpainting, selecting the appropriate algorithm, and optimizing parameters such as scale and output size makes it possible to produce high-quality, outpainted images quickly and easily.

Whether you are a professional photographer, graphic designer, or hobbyist, outpainting can help you achieve your creative goals and take your image editing skills to the next level. So why not try it and see the stunning results for yourself?

Narry
http://blog.opendream.ai

Narry is a female author based in Singapore, specializing in providing valuable insights about AI. With a knack for writing captivating articles, she has made a profound impact on her readers. Her expertise lies in unraveling the complexities of artificial intelligence and translating them into accessible knowledge for a wide audience. Narry's work delves into the latest advancements, ethical considerations, and practical applications of AI, shedding light on its transformative potential across various industries. Her articles are not only informative but also thought-provoking, encouraging readers to contemplate the implications and future implications of AI technology.

Leave a Reply