WATCH FULL VIDEO BELOW
Tech

How to Outpaint With Stable Diffusion

Stable Diffusion is one of the top AI text-to-image generating tools available online. Developed by Stability.ai, the software is a revolutionary image translator. It uses a latent diffusion model to render some of the fastest pictures based on text prompts.

Among its many features, outpainting is one of the most exciting ones to use. It helps expand an existing image in one or more directions based on text descriptions, sampling methods, and resolution settings. And unlike purely AI-generated images, the outpainting feature gives artists and casual Stable Diffusion users more control over the final product.

Creating Your Image Using Prompts

Before you tackle outpainting in Stable Diffusion, you must generate a picture. Here’s how you use the Automatic1111 GUI interface to create a new image.

  1. Go to the txt2img tab.
    How to Outpaint With Stable Diffusion 1 3
  2. Type the words that describe your image in the prompt text box.
    How to Outpaint With Stable Diffusion 2 1
  3. Type words describing graphic elements you don’t want to see in the negative prompt text box.
    How to Outpaint With Stable Diffusion 3
  4. Set the sampling steps at around 50-55, depending on your graphic card’s capabilities.
    How to Outpaint With Stable Diffusion 4
  5. Use whatever sampling method you want and set the width and height of the image.
    How to Outpaint With Stable Diffusion 5
  6. Check the “Restore Faces” option if you’re generating people in the image.
    How to Outpaint With Stable Diffusion 6
  7. Adjust the “Batch Count” slider if you want to render more than one image.
    How to Outpaint With Stable Diffusion 7
  8. Set the seed to “-1” unless you have a specific image seed in mind that you want to recreate.
    How to Outpaint With Stable Diffusion 8
  9. Click the “Generate” button.
    How to Outpaint With Stable Diffusion 9

Note that the words you type in the prompt text box are highly important. If you want specific strokes, styles, colors, and other effects, you must mention them in that section.

The default Stable Diffusion image generator will render something with a photographic feel unless instructed otherwise.

Using the Outpaint Feature in Stable Diffusion

Once you render an image, you can start expanding on it or outpainting it. Select the image you like the most from your batch and click the “Send to img2img” button.

Follow the next steps to configure Stable Diffusion for outpainting.

  1. Go to the img2img tab in the Automatic1111 GUI interface.
    How to Outpaint With Stable Diffusion 1 4
  2. Scroll down until you see the “Script” dropdown menu and select “Outpainting mk2.”
    How to Outpaint With Stable Diffusion 10 1
  3. Choose the outpainting direction by checking the “Left,” “Right,” “Up,” or “Down” boxes.
    How to Outpaint With Stable Diffusion 11
  4. Describe the visual elements of the outpainting in the prompt text box at the top of the UI.
    How to Outpaint With Stable Diffusion 12
  5. Check the “Just Resize” option.
    How to Outpaint With Stable Diffusion 13
  6. Set the sampling steps between 80 and 100 using the slider.
    How to Outpaint With Stable Diffusion 14
  7. Adjust the number of pixels, which you can often max out for the highest image quality.
    How to Outpaint With Stable Diffusion 15
  8. Click the “Generate” button.
    How to Outpaint With Stable Diffusion 16

The Best Way to Configure the Outpaint Process

One of the biggest problems with outpainting in Stable Diffusion and other AI-enabled text-to-image software is overloading the AI. For example, expanding a picture in more than one direction can yield mixed results.

In addition, if only one side turns out good, you won’t be able to keep it and redo the outpainting in the other directions. Instead, you must start from scratch. That means you may not be able to recreate that one side that looked perfect.

Here’s what you want to do to get the best outpainting results in Stable Diffusion.

Expand to the Left

  1. Load your picture in the img2img tab.
    How to Outpaint With Stable Diffusion 17
  2. Describe the visual elements you want in the outpainting.
    How to Outpaint With Stable Diffusion 18
  3. Add negative prompts if needed.
    How to Outpaint With Stable Diffusion 19
  4. Choose the “Left” outpainting direction and uncheck the other three options.
    How to Outpaint With Stable Diffusion 20
  5. Click “Generate” until you’re happy with the result.
    How to Outpaint With Stable Diffusion 21
  6. Drag the image from the right UI pane to the img2img tab.

Expand to the Right

  1. Describe the visual elements you want and don’t want in the prompt fields.
    How to Outpaint With Stable Diffusion 23
  2. Add negative prompts if you want the AI to omit specifics.
    How to Outpaint With Stable Diffusion 24
  3. Choose the “Right” outpainting direction and uncheck the previous one.
    How to Outpaint With Stable Diffusion 25
  4. Hit “Generate” until you get something great.
    How to Outpaint With Stable Diffusion 26
  5. Drag the image to the img2img tab or hit the “Send to img2img” button.
    How to Outpaint With Stable Diffusion 27

Expand Upward

  1. Add new visual elements for the image.
    How to Outpaint With Stable Diffusion 23
  2. Add negative prompts if needed.
    How to Outpaint With Stable Diffusion 24
  3. Select the “Up” outpainting direction and uncheck the last one.
    How to Outpaint With Stable Diffusion 28
  4. Hit “Generate” until you like the result.
    How to Outpaint With Stable Diffusion 30
  5. Drag and drop the final image back into the img2img tab.

Expand Down

  1. Type your final description before generating a downward expansion.
    How to Outpaint With Stable Diffusion 23
  2. Use some negative prompts, preferably to prevent overlapping with the original image.
    How to Outpaint With Stable Diffusion 24
  3. Select “Down” as the outpainting direction and uncheck everything else.
    How to Outpaint With Stable Diffusion 29
  4. Click the “Generate” button until satisfied with the results.
    How to Outpaint With Stable Diffusion 30 1

Another great benefit of expanding your image in one direction at a time is that you can better describe the imagery.

For example, say your starting image had the following prompt: “kids playing in the yard.” You could add “dog playing in the yard” on one side and “cat playing in the yard” on the other side. The AI will have a much higher chance of getting things right and rendering realistic animals in the final image.

In the same example, you can type “blue sky and birds” in the prompt and have the AI fill outwards above the original image instead of getting chunks of the sky in all directions.

What You Need to Master When Outpainting in Stable Diffusion

Stable Diffusion doesn’t come cheap. But since it’s Open AI software, you can run it on your own machine to avoid paying a fee per generation. Note that you’ll probably need a decent graphics card with around 8 GB of VRAM and a good CPU to avoid super slow rendering times.

Now it’s a matter of installing the Automatic1111 GUI web UI.

How to Install Stable Diffusion Automatic1111 Web UI on Windows

  1. First, install Python 3.11.1, as Stable Diffusion relies heavily on Python coding.
    How to Install Stable Diffusion Automatic1111 Web UI on Windows 1
  2. Download and install the appropriate 32-bit or 64-bit Git standalone installer depending on your CPU.
    How to Install Stable Diffusion Automatic1111 Web UI on Windows 2
  3. Run “git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git” to get the correct repository.
    How to Install Stable Diffusion Automatic1111 Web UI on Windows 3
  4. Download the Stable Diffusion model checkpoint labeled “model.ckpt” from here.
    How to Install Stable Diffusion Automatic1111 Web UI on Windows 4
  5. Add “model.ckpt” in the “models” directory.
    How to Install Stable Diffusion Automatic1111 Web UI on Windows 5
  6. Double-click the “webui-user.bat” executable file.
    How to Install Stable Diffusion Automatic1111 Web UI on Windows 6
  7. Generate a picture and experiment with the outpainting, inpainting, and other features.

How to Install Stable Diffusion Automatic1111 Web UI on Linux

Installing the Automatic1111 Web UI on a Linux machine is slightly different but pretty straightforward. Here are the steps you must follow.

Red Hat Linux

  1. Type “sudo dnf install wget git python3” in the terminal.
    terminal linux red hat
  2. Install the UI by running “bash <(wget –q0-https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh).”
    redhat terminal

Debian Linux

  1. Type “sudo apt install wget git python3 python3-venv” and run it in the terminal.
    terminal debian
  2. Install the UI with the following command “bash <(wget –q0-https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh).”
    terminal debian

Arch Linux

  1. Type “sudo P –S wget git python3” in the terminal.
    terminal arch
  2. Run “bash <(wget –q0- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh)” in the terminal.
    terminal arch linux 2

How to Install Stable Diffusion Automatic1111 Web UI on Apple Silicon

The commands for installing Automatic1111 Web UI on an Apple Silicon machine are different than other operating systems.

  1. Start the Terminal app.
    mac
  2. Execute “$ cd ~/Documents/
    mac1
  3. Run “$ curl https://raw.githubusercontent.com/dylancl/stable-diffusion-webui-mps/master/setup_mac.sh -0 setup_mac.sh
    mac2
  4. Execute “$ chmod +x setup_mac.sh
    mac3
  5. Run “./setup_mac.sh
    mac4
  6. Follow the next instructions presented in the terminal interface.

You can run the Automatic1111 UI by running “./run webui_mac.sh” in the terminal. Whenever you run it, it will start with the latest updates made to the repository.

What to Do After Outpainting an Image

As great as the Stable Diffusion AI is, it’s far from perfect. Overloading it with information and lengthy descriptions can render some less-than-exciting pictures. Likewise, vague descriptions can expand the image without adding enough relevant visual elements.

Once you’re done outpainting, you have two options. You can save the image and edit it further in your favorite image editor. But another way to get more use out of Stable Diffusion is to switch to inpainting.

Select your image in the right pane and click the “Send to Inpaint” button. The UI will switch to a new type of editing feature. It’s a great method for filling in the blanks in certain parts of the image.

  1. Select a brush size and mask a part of the image where you want to add something.
    How to Outpaint With Stable Diffusion 31
  2. Describe the inpainting elements.
    How to Outpaint With Stable Diffusion 32
  3. Deselect the “Outpainting mk2” script.
    How to Outpaint With Stable Diffusion 33
  4. Click “Generate” until satisfied with the result.
    How to Outpaint With Stable Diffusion 34

A Much-Needed Feature Is Finally Here

Although Stable Diffusion launched in August 2022, the outpainting feature didn’t really exist at first. At least its earliest iteration wasn’t spectacular. But in a short amount of time, Stable Diffusion’s outpainting has surpassed the capabilities of its inpainting feature.

The software can generate stunning images. And with 75-word descriptive texts and a separate field for negative prompts, the AI’s accuracy is astounding.

Now we want to hear from you. What is your experience with Stable Diffusion or similar software so far? Can you usually render satisfying images, or does it take too much time? Tell us about your Stable Diffusion experiences and outpainting tips in the comments section below.

Muhabarishaji

🧪 |Medical Laboratory Scientist 🥇 | Mindset over Everything. 
 🤝 | Let's Grow Together.

Related Articles

Back to top button