How to Setup Stable Diffusion Infinity for Infinite Outpainting

How to Setup Stable Diffusion Infinity for Infinite Outpainting

In this tutorial we’ll cover how to set up the Stable Diffusion Infinity notebook.

Stable Diffusion Infinity is an implementation of Stable Diffusion focused on outpainting on an infinite canvas.

Outpainting is a technique that allows you to extend the border of an image and generate new regions based on the known ones. This can be really helpful for designers who want to create images of any size.

Quick Video Demo

Here’s how it will look like when we’ll use outpainting with Stable Diffusion:

Google Colab Notebook Setup

If you want to use Stable Diffusion, you’ll need to find the corresponding Google Colab Notebook.

Google Colab is a virtual coding environment that uses the Python programming language in notebook format.

In other words, Google provides you with a free computer for programming or data processing. You don’t have to worry if you don’t know how to code because everything you need is already there.

Just click this link and it will take you to the notebook :

After that make sure you copy it into your own Google Drive.

Screenshot of clicking the button to Copy Colab Notebook to Google Drive
Copy Colab Notebook to Google Drive

After you’ve copied the Google Colab notebook into your own Google Drive, click on the Runtime tab and select change Runtime Type. Make sure you choose GPU.

Now we’re ready to start using the Stable Diffusion Infinity.

Running the Google Colab Cells Step-by-Step

To run a cell click on the play button next to it.

Running the first cell in Google Colab
Running the first cell in Google Colab

After you run the first cell, you may encounter a warning that says you have to restart the runtime. However, you actually don’t need to restart it. Just move on to the second cell.

word image 12676 7

Get a HuggingFace Token

If you want to use the fourth cell in this notebook, you’ll need to input a Hugging Face token.

Hugging Face is an open-source provider of machine learning technologies. Their platform offers a variety of tools that allow developers to build and train AI models.

The data is trained, processed and stored at Hugging Face database, and Stable Diffusion needs that data to be used into its algorithm.

To integrate Stable Diffusion with HuggingFace database, you have to sign up and getting access via access token.

word image 12676 8

If you don’t have a Hugging Face account, you can sign up for one at their website at The sign up process is typical and straightforward.

Next go to Access Tokens in your account (or visit this link and there you’ll easily be able to create a token.

Make sure token permission is set to WRITE, then copy your access token by clicking the white square symbol. With this token, you’ll have the ability to make changes and access sensitive information. So be sure to keep it safe.

word image 12676 9

Go back to the Stable Diffusion notebook, paste your access token into the Token field, and click Login. Once you’re logged in, you can move on to the next cell.

word image 12676 10

Stable Diffusion Infinity Settings

One last step before using Stable Diffusion Infinity for outpainting. We need to configure a few settings:

Configure Infinite Canvas Settings
Configure Canvas Settings
  1. canvas_width is the width of the canvas. The minimum is 800. If you set it to anything less than 800 it will throw an error.
  2. canvas_height is the hieght of the canvas. The minimum is 600. If you set it to anything less than 800 it will throw an error.
  3. selection_box_size is the selection box size. The selection box is a box where Stable Diffusion draws a picture based on your text prompt and you can move it by dragging it around. You can set the selection box size to more than the default number. There are strict numbers that you are allowed to input in the selection_box_size. You cannot input random numbers except 256, 512 and 768. Make sure that the number you input never exceeds the numbers in canvas_width and canvas_height.
  4. image_refresh_delay is a field for setting how long the process takes to refresh your resulting image.
Canvas Settings
Canvas Settings

Upload an Image (Optional)

The next cell is Upload an Image This cell gives you the option to upload an image to use as a reference for your art.

If you choose to do so, the image will automatically be resized to fit the canvas. Checking the box is optional, but if you don’t need an initial image, just leave it unchecked and run the cell.

Start Using Stable Diffusion Outpainting

Now we can generate our images.

Under Init Mode: you’ll see some tabs you can select at the top of the canvas.

I recommend you choose edge_pad mode. It seems to have the best results in my opinion.

word image 12676 12

There’s a field below called Steps. It indicates how many drawing processes are required.

For 50 steps, that means it’ll take 50 iterations, and each iteration will take ~1-4 seconds, depending on the GPU we’ve been allocated by Google. If you need speed, I recommend you upgrade to Google Colab Pro. The more steps there are, the longer the process will be. A higher number of steps will result in more detailed images, but that doesn’t mean the results will be proportional. Sometimes you just need to be accurate with your text prompts.

Then input a text prompt in Prompt field to start generating our image. If you don’t know what to start with, you can check to find inspiration.

In my case I’ll use the following:

linear park and esplanade along passing river, view of the river and metro manila skyline, concept art, artstation

I selected edge_pad and when you’re ready click on the blue Outpaint button.

Initial Prompt
Initial Prompt

You can grab the selection box and move it around, change the prompt, depending on what you want to generate, and click Outpaint.

For example I moved it around and now I set the prompt to a whale.

a whale
Generating a whale

If you feel enough, you can save it by clicking ‘Export’ button and image result will appear at the bottom of it. Right click and save it to your computer. But, if you want to expand it, you can drag the box around existing image, click the patchmatch and re-run the process by clicking Outpaint button.


In this article we covered how to set up the Stable Diffusion Infinity Google Colab to use outpainting on a potentially infinite canvas. If you encountered any issues or have any questions feel free to leave a comment and we’ll get back to you as soon as possible.

Notify of
Receive notifications when your comment receives a reply. (Optional)
Your username will link to your website. (Optional)

Inline Feedbacks
View all comments
You May Also Like