How to Customize Stable Diffusion 2.1

How to Customize Stable Diffusion and deploy to Salad :

Stable Diffusion:
This guide will provide you with step-by-step instructions on how to customize Stable Diffusion's Docker image.

If anything is unclear, please open an issue.

  • To clone the repository, open your terminal or command prompt.
  • Run the following command:
git clone

Execute the command and wait for the repository to be cloned to your local machine

  • Configuring the Dockerfile :
    Now, configure it to include your desired model.
    This can be done either through a link in the MODEL_ID section, similar to the example, or by linking to a .CPKT file instead. You should also configure the Dockerfile to include your NGROK AUTH token and NGROK EDGE token in the sections specified at the end of the Dockerfile.

  • Changing the Working Directory
    CD into your working directory.

  • Building the Docker Image
    Run the following command to build your Docker image:

docker build -t dockerName .
  • Running the Docker Image
    After building the Docker image, run it using the following command:
docker run --gpus=all -p 50150:50150 dockerName
  • Testing the Docker Image
    Send a POST request to http://localhost:50150 to test the Docker image. You can use the following example POST request:
  "modelInputs": {
    "prompt": "YOUR PROMPT GOES HERE!",
    "num_inference_steps": 50,
    "guidance_scale": 7.5,
    "width": 512,
    "height": 512,
    "seed": 3239022079,
    "num_images_per_prompt": 4
  "callInputs": {
    "PIPELINE": "StableDiffusionPipeline",
    "SCHEDULER": "LMSDiscreteScheduler",
    "safety_checker": "true"
  • Sending Identical POST Request
    Send an identical POST request to your designated URL endpoint.

You can customize the modelInputs and callInputs fields as per your requirements. Note that the modelInputs field is passed directly to the selected diffusers pipeline unchanged, and the callInputs field affects which model, pipeline, scheduler, and other lower-level options are used to construct the final pipeline.

  • Test your customizations:
    You can use the script to test your customizations. The script contains very basic examples of how to use Stable Diffusion. To run the script against a running instance of Stable Diffusion, use the command python

  • Releasing the Docker Image
    Once you have a working test Docker image, you can either push it directly to your Docker repository or rebuild it with the desired tagging and name before pushing it to your Docker container.

  • Creating the Salad Portal Container Group
    [Create a Salad Portal container group] ( that is linked to your new Docker Container Tag.

Your image URL tag should be in this format when creating a container group :
This is a reference to a Docker Container image. Image source strings are expanded when possible.
Check out a guide here on how to create a Salad Container Group

  • Changes Made to the Project
    There have been some changes to the project, such as adding a GET request response, including by default, and adding configuration for network forwarding with NGROK.
    Kindly note this was created for, and everything is open source, but there may be certain request/response assumptions.


By following this guide, you should now have a customized Stable Diffusion Docker image with your desired model and configuration. You can use this image to develop your diffusers with a REST API, supporting various models, pipelines, and schedulers.