Home > Apps

How does Stable Diffusion work?

The nitty-gritty details about Stable Diffusion
Last Updated on August 14, 2023
Stable diffusion functioning.
PC Guide is reader-supported. When you buy through links on our site, we may earn an affiliate commission. Read More
You can trust PC Guide: Our team of experts use a combination of independent consumer research, in-depth testing where appropriate - which will be flagged as such, and market analysis when recommending products, software and services. Find out how we test here.

Stable Diffusion is a deep learning model that can generate high-quality images from natural language descriptions known as text prompts. But, how does Stable Diffusion work? Generative AI can be an overwhelming topic to take on, but we hope to keep things simple for you here. Understanding how the tool works can in turn help you become a better artist through using the mechanics with more prescision. This post will guide you through the underlying technology behind Stable Diffusion and how it can create realistic images from text descriptions.

How does Stable Diffusion create images?

Stable Diffusion is a generative model that uses deep learning to create images from text. The model is based on a neural network architecture that can learn to map text descriptions to image features. This means it can create an image matching the input text description.

The Stable Diffusion model uses “diffusion” to generate high-quality images from text. The diffusion process involves iteratively updating a set of image pixels based on a diffusion equation. This helps to smooth out the image and create a more realistic texture.

Obviously, there are a lot of complex processes occurring when Stable Diffusion is generating images. To simplify it to its most basic form, the text prompt you provide the model is converted into numbers that relate to the individual words, called tokens. Each token is then converted to a 768-value vector known as embedding. These embeddings are then processed by the text transformer and are ready to be consumed by the noise predictor.

Stable Diffusion is a latent diffusion model, and this is part of the reason it can generate high-resolution images at such a fast speed. The model compresses the image into latent space rather than operating in the high-dimensional image space. In the context of AI, latent space refers to a mathematical space that maps what a neural network has learned from training images. As the latent space is a lot smaller, the images are generated faster.

This compression (and later decompression/painting) is actually done through an autoencoder. The autoencoder compresses the information into the latent space using its encoder, then reconstructs it again as an image using only the compressed information using the decoder.

Essential AI Tools

Editor’s pick
Only $0.00019 per word!

Content Guardian – AI Content Checker – One-click, Eight Checks

8 Market leading AI Content Checkers in ONE click. The only 8-in-1 AI content detector platform in the world. We integrate with leading AI content detectors to give unparalleled confidence that your content appear to be written by a human.
EXCLUSIVE DEAL 10,000 free bonus credits

Jasper AI

On-brand AI content wherever you create. 100,000+ customers creating real content with Jasper. One AI tool, all the best models.
TRY FOR FREE

WordAI

10x Your Content Output With AI. Key features – No duplicate content, full control, in built AI content checker. Free trial available.
TRY FOR FREE

Copy.ai

Experience the full power of an AI content generator that delivers premium results in seconds. 8 million users enjoy writing blogs 10x faster, effortlessly creating higher converting social media posts or writing more engaging emails. Sign up for a free trial.
TRY FOR FREE

Writesonic

Create SEO-optimized and plagiarism-free content for your blogs, ads, emails, and website 10X faster. Start for free. No credit card required.

Energy-based model

Stable Diffusion is an energy-based model that learns to generate images by minimizing an energy function. The energy function measures how well the developed image matches the input text description. Stable Diffusion can create images that closely match the input text by minimizing the energy function.

Does Stable Diffusion use images?

In short, yes. Stable Diffusion does use images. In fact, you need a large dataset of input images and text descriptions to train Stable Diffusion. The model learns to create images by comparing its output to the ground truth images in the dataset. This helps the model learn how to create realistic images from text descriptions.

Once Stable Diffusion has been trained, you can generate images from text descriptions. To do this, you input a text description into the model, and it creates an image that matches the description. The generated image can be further refined by adjusting various parameters, such as the temperature and threshold values.

Advantages of Stable Diffusion

Stable Diffusion has several advantages over other text-to-image models. One of the main advantages is its ability to generate high-quality images with fine details and textures that match the input text. This is due to the diffusion process that allows the model to create stable and consistent images.

One of the reasons for the popularity of stable diffusion comes from its open-sourced nature, its ease of use, and its ability to run on a consumer-level GPU. This is in a way democratizing image generation and generative AI, allowing anyone interested to try it out. If you’re interested in using this AI model for yourself, you can read on about how to run Stable Diffusion locally, and how to use Stable Diffusion to get you started.

Kevin is the Editor of PC Guide. He has a broad interest and enthusiasm for consumer electronics, PCs and all things consumer tech - and more than 15 years experience in tech journalism.