Hot starts, batch inference, and what's next for Runpod Serverless. Webinar June 25.

Using Stable Diffusion Scripts and Extensions

Learn how to expand your Stable Diffusion workflow on Runpod with custom scripts and extensions. This guide walks through installing a pixel art script.

Using Stable Diffusion Scripts and Extensions

Looking to "extend" the functionality of your Stable Diffusion instance? Look no further! This guide will show you how to install and use custom scripts and extensions with our Stable Diffusion endpoint.

I'll assume you already have a Pod instance with the Stable Diffusion template; if you don't and need a guide, the first step in this article will show you how to get one spinning.

Installing Custom Scripts

For this tutorial, I'm going to reference the pixel_art script from these repos; this is a script that gives you some options for downscaling and reducing the color palette of generated images to create some neat pixel art. However, if you're savvy enough, you can edit an existing script for additional functionality or write one yourself!

1. Save a copy of the script of your choice (in my case, the pixel_art script).

Some scripts might have extra steps or a slightly different installation process; be sure to check out your script's README!
Some scripts might have extra steps or a slightly different installation process; be sure to check out your script's README!
Screenshot from Stable Diffusion scripts and extensions tutorial

2. Connect to your Pod with Jupyter Lab and navigate to workspace/stable-diffusion-webui/scripts. This is where we'll drop the .py file we saved.

Runpod pod connection options with HTTP port 3000, Jupyter Lab port 8888, and a basic SSH command
Jupyter file browser listing the default scripts in the stable-diffusion-webui/scripts folder

3. Copy the .py file of your script to the scripts directory in Jupyter Lab.

pixel_art.py uploaded into the stable-diffusion-webui/scripts folder via the Jupyter file browser

4. Connect to your Pod via HTTP to access the webUI.

Runpod pod connection options dialog with Connect via HTTP on port 3000 highlighted

If you were already connected via HTTP, hop over to the Settings tab at the top and select Reload UI to refresh your available scripts.

5. Select your script from the Script dropdown, configure the settings specific to your script, and generate some images!

Stable Diffusion web UI Script dropdown listing Pixel Art, Prompt matrix, Prompts from file, and X/Y/Z plot options
Pixel Art script settings with downscale multiplier, color palette size, and palette extraction method options
Stable Diffusion web UI generating a batch of beach scenes with the Pixel Art script enabled
Pixelated AI-generated beach scene with ocean waves and a palm tree silhouette at sunset

Installing Extensions

Before we start! Each Pod instance has a requirements.txt file which lists dependencies needed for things to work properly:

JupyterLab file browser in the stable-diffusion-webui folder with requirements.txt open listing dependencies

Your extension will install its own dependencies. If these conflict with any of the existing ones, bad things™ can happen, so double-check before you install!

For this tutorial, I'll be showing off the Randomize extension; this one

1. In the Stable Diffusion webUI, navigate to the Extensions tab at the top. If you have a specific extension in mind, you can select the Install from URL tab and provide a URL for the extension's git repo.

Stable Diffusion web UI Extensions tab with the Install from URL form for an extension git repository

If you don't have a specific one in mind, select the Available tab and click the orange Load from: button (a URL to a JSON file with a bunch of extension repos should auto-populate the text box). Then, you can scroll down and select an interesting extension; I'm going to follow this path for the tutorial with the Randomize extension.

Available extensions list in the Stable Diffusion web UI Extensions tab with Install buttons

2. Select the Install button on the right for the extension of your choice, and under the Installed tab, click the orange Apply and restart UI button.

Installed extensions list in Stable Diffusion web UI showing the randomize extension and Apply and restart UI button

3. Once your UI has restarted, you should see the additional options your extension provides in the appropriate tab (in my case, the txt2img tab).

Stable Diffusion txt2img settings with the Randomize extension panel for sampler, CFG scale, steps, width, and height

Now, you can use these new options to customize your experience with Stable Diffusion!

Stable Diffusion web UI showing a batch of snowy mountain images generated with the Randomize extension enabled
AI-generated snowy landscape with pine trees and a mountain under a purple cloudy sky
AI-generated winter scene of snow-covered pine trees in front of misty mountains

Author profile: Brandon Ikeler

Related articles

View All
Deploy When Available is now GA

Deploy When Available is now GA

Queue for any GPU spec, even one that's fully rented out, and we'll deploy it the moment capacity opens up. No more refreshing the console or running a sniping tool.

All
The Chips Got Faster. The Stack Didn't.

The Chips Got Faster. The Stack Didn't.

Explore why faster chips have shifted the bottleneck to AI infrastructure, and what that means for teams running production workloads.

All

Build what’s next.

Build, train, and scale AI workloads on Runpod with cloud GPUs, Serverless, and Clusters.