Outpainting

Outpainting refers to the task of extending parts of an image some amount of pixels. For example, using the reference photo from the inpainting tutorial, we can use Auto 1111 SDK's outpainting feature to extend it 128 pixels in the left. The photo's original dimensions were 768x1024, and now they are 896x1024:


Just like Inpainting, Outpainting with Auto 1111 SDK doesn't require a different pipeline object. You can use the same pipeline object that you used to generate the image to outpaint the image, though it is recommended that you use a dedicated inpainting model, which you can find on Civit AI: https://civitai.com/. In this example, I will be using the dreamshaper v8 inpainting pipeline: https://civitai.com/models/4384?modelVersionId=131004. Here's how you can outpaint with Auto 1111 SDK:

  1. Initialize your pipeline. This process is the same for inpainting. To download the model, you can use Auto 1111 SDK's Civit AI model downloader.

    from auto1111sdk import StableDiffusionPipeline
    inpainting_pipe = StableDiffusionPipeline("dreamshaper_v8Inpainting.safetensors")
  2. Open the image

from PIL import Image
image = Image.open("photo.png")
  1. Outpaint

output = pipe.poor_mans_outpainting_img2img(steps=10, prompt = prompt, direction=["left"], negative_prompt=negative_prompt, init_images = image)

You can leave the prompt and negative prompt as the same as the original photo. Currently, Auto 1111 SDK only supports poor mans outpainting.


Parameters

Currently, Auto 1111 SDK supports the following parameters (and the corresponding default values):

init_image: a PIL Image object
prompt: str
negative_prompt: str = ''
seed: int = -1
steps: int = 20
cfg_scale: float = 7.5
sampler_name: str = "Euler"
denoising_strength: float = 0.75
pixels: int = 128 # the number of pixels you want to outpaint in each specified direction
mask_blur: int = 4
directions: list = ["left"] # the directions you want to outpaint in. Can include multiple directions, including ["left", "right", "up", "down"]

Last updated