Pular para o conteúdo principal
InicioTutoriaisInteligência Artificial (IA)

How to Run Stable Diffusion

Explore generative AI with our introductory tutorial on Stable Diffusion. Learn how to run the deep learning model online and locally to generate detailed images.
mai. de 2023  · 7 min leer

In collaboration with several academic researchers and non-profit organizations, a startup named Stability AI, founded in 2019, developed the Stable Diffusion model, which was later released in 2022.

It’s effectively an open-source deep learning model primarily tasked with generating high-quality, detailed images from text. However, you can also use text to modify images or fill in details for low-resolution images.

Stable Diffusion was initially trained on 2.3 billion images and is said to be capable of producing results comparable to that of DALL-E 2.

In this article, we will scratch the surface of how it works and then cover a few ways you can run it for yourself.

How Does Stable Diffusion Work?

The stable diffusion model falls under a class of deep learning models known as diffusion. More specifically, they are generative models; this means they are trained to generate new data similar to what it’s learned in the past.

As a side note, generative modeling is a type of unsupervised learning concerned with automatically discovering and learning patterns in input data such that the model may be used to output new examples that may have been drawn from the original data.

Stable diffusion earned the name ”diffusion” based on its striking similarities in mathematical formulation to that of diffusion in physics.

AI Upskilling for Beginners

Learn the fundamentals of AI and ChatGPT from scratch.
Learn AI for Free

How To Run Stable Diffusion Online

If you wish to get started with the Stable diffusion model right away, you can do so by running it online using the following tools.


Stability AI, the creators of Stable Diffusion, have made it extremely simple for curious parties to test their text-to-image model with their online tool. This platform grants users access to the latest version of stable diffusion models, which allows you to generate an image in up to 15 seconds.

Dream Studio

Note you would have to sign up to DreamsStudio to use the tool. New users are granted 25 credits (at the time of writing) upon creating an account, which gives you approximately 100+ images. If you need more, you can easily purchase extra credits from the account dashboard.

Credits dashboard

Hugging Face Stable Diffusion

Hugging Face is an AI community and platform that promotes open-source contributions. Though it’s highly recognized for its transformer models, hugging face also provides access to the latest Stable diffusion model; and like a true lover of open-source, it’s free. The tradeoff with hugging face is you’re unable to customize properties as you are in DreamsStudio, and it takes noticeably more time to generate an image.

Hugging Face Stable Diffusion

How to Run Stable Diffusion Locally

But what if you want to experiment with Stable Diffusion on your local computer?

We’ve got you covered.

Running Stable Diffusion locally enables you to experiment with various text inputs to generate images more tailored to your requirements. Also, you may fine-tune the model on your data to improve the results given the inputs you provide.

Disclaimer: You must have a GPU to run stable diffusion on your PC.

Step 1: Install Python & Git

You will require Python 3.10.6 to run Stable Diffusion from your local computer; this can be installed from the official Python Website. If you get stuck, check out our How to Install Python tutorial.

Check the installation worked correctly by opening the command prompt, typing python, and executing the command; this should print the version of Python you’re using.

Install git and Python

If you don’t see Python version 3.10.6, ensure you’ve removed all other versions of Python from your PC.

Disclaimer: Don’t proceed without Python 3.10.6.

Next, you must install the code repository management system, Git; the Git Install Tutorial is there to help you get stuck, and our Introduction to Git course is available if you wish to deepen your knowledge of git.

Step 2: Create a GitHub and Hugging Face account

GitHub is a hosting service for software development; it’s where developers host their code so they can track and collaborate with other developers on software projects. If you haven’t got a Github account, now is also a good time to create one – check out Github & Git Tutorial for Beginners for assistance.

Hugging Face, on the other hand, is an AI community that advocates for open-source contributions. It serves as the hub for several models from various domains, including Natural language processing, computer vision, and more. You’ll need an account to download the latest version of Stable Diffusion – we will get to this step later.

Step 3: Clone Stable Diffusion Web-UI to your PC

This step is important but can easily get tricky; all we want to do is download the basics of the stable diffusion installation on our local PC. It helps to create a folder (i.e., stable-diffusion-demo-project) to download the repository into, but it’s not a necessary requirement.

For this step, you’ll need Git bash. Navigate to the folder you would like to clone the stable diffusion web UI into using the following command:

cd path/to/folder 

Then run the following command:

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

If the command is executed successfully, you should now have a folder called stable-diffusion-webui.

Install stable diffusion

Step 4: Download the Latest Stable Diffusion model

Here’s where your Hugging Face account comes in handy; Login to Hugging Face, and download a Stable Diffusion model. Note this may take a few minutes because it’s quite a large file.

Once you’ve downloaded the model, navigate to the “models” folder inside the stable diffusion webui folder. In there, there should be a “stable-diffusion” folder that contains a text file called “Put Stable Diffusion Checkpoints here.”

Now, move the recently downloaded Stable Diffusion model to this folder.

Here’s the path for clarity:


Step 5: Setup the Web-UI

The next step is to install the tools required to run stable diffusion; this step can take approximately 10 minutes.

Open your command prompt and navigate to the stable-diffusion-webui folder using the following command:

cd path/to/stable-diffusion-webui

Once you’re there, run:


This will create a virtual environment and install all the dependencies required.

Step 6: Run Stable Diffusion

After the dependencies have been installed, a URL will appear in your command promt: “” Copy and paste this into your address bar to run the Stable Diffusion web-ui.

Stable diffusion dashboard

Learn more about generative AI

Generative AI refers to a mode of deep learning capable of generating high-quality text, images, etc., based on what the model was trained on. Tools like Stable Diffusion, ChatGPT, DALL-E, etc., are great examples of generative AI that have been making waves of late.

If you’re not up to speed with Generative AI, check out the resources listed below to get up to speed.

Photo of Kurtis Pykes
Kurtis Pykes


Stability AI Announces Stable Diffusion 3: All We Know So Far

Find out about the new updates to Stable Diffusion and discover the capabilities of the version 3 text-to-image model.
Richie Cotton's photo

Richie Cotton


How to Use the Stable Diffusion 3 API

Learn how to use the Stable Diffusion 3 API for image generation with practical steps and insights on new features and enhancements.
Kurtis Pykes 's photo

Kurtis Pykes

12 min


StableDiffusion Web UI: A Comprehensive User Guide for Beginners

Learn how to easily install and use Stable Diffusion Web UI for generating high-quality images on your laptop.
Abid Ali Awan's photo

Abid Ali Awan

13 min


Fine-tuning Stable Diffusion XL with DreamBooth and LoRA

Learn how to successfully fine-tune Stable Diffusion XL on personal photos using Hugging Face AutoTrain Advance, DreamBooth, and LoRA for customized, high-quality image generation.
Abid Ali Awan's photo

Abid Ali Awan

14 min

código junto

Generating Photorealistic Images using AI with Diffusers in Python

In this live training, you'll learn about state-of-the-art diffusion models and how to generate photorealistic images using Python.
Sayak Paul's photo

Sayak Paul

código junto

Building a Diffuser Model From Scratch with PyTorch

In this webinar, you'll learn how to build your own diffuser model from scratch!
Philip Bontrager's photo

Philip Bontrager

See MoreSee More