Skip to content

Diffusion Models

Briefly

Diffusion models are neural networks that learn to create images by gradually removing noise from a random set of pixels.

Simple Analogy

Imagine taking a clear photograph and gradually adding noise to it until only 'snow' remains.

A diffusion model learns to do the opposite: start with 'snow' and gradually turn it into a meaningful image.

How It Works

Training

  1. Take a real image.
  2. Add noise to it.
  3. Ask the model to predict the noise that was added.
  4. Compare with the correct answer and update the weights.

This way, the model learns to 'fix' noisy images.

Generation

  1. Create random noise.
  2. The model removes a little noise.
  3. Repeat many steps.
  4. At the end, an image is produced.
flowchart LR
    A[Random noise] --> B[Step 1]
    B --> C[Step 2]
    C --> D[Step N]
    D --> E[Image]

Role of Text Prompt

Modern diffusion models are controlled by text. A prompt:

"A space cat on Mars, digital painting"

guides the noise removal process to produce the desired image.

For this, the text is converted into embeddings and fed into the model along with the image.

  • Stable Diffusion — an open model, can be run locally;
  • DALL-E — a model from OpenAI;
  • Midjourney — a popular generation service;
  • Flux — modern open models.

What Sets It Apart from GAN

Previously, images were often generated by GAN — two networks competed against each other. Diffusion models are usually more stable and produce more diverse results.

See Also