🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
Search courses…
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Diffusion Models — State-of-the-Art Generative AI

Expert TopicsGenerative AI🟢 Free Lesson

Advertisement

Advanced Topics

Diffusion Models — How DALL-E and Stable Diffusion Create Images

Understand the revolutionary diffusion models behind modern image generation. Learn how these models gradually denoise random noise into coherent images.

  • Forward Diffusion — The process of adding noise to data
  • Reverse Diffusion — Learning to denoise and generate new samples
  • Conditional Generation — Guiding generation with text or other inputs

"Creation is just destruction in reverse."

Diffusion Models — Complete Guide

Diffusion models are the state-of-the-art for image generation (DALL-E, Stable Diffusion, Midjourney).


How Diffusion Works

Forward Process (fixed): Image -> Add noise -> Add noise -> ... -> Pure noise

Reverse Process (learned): Pure noise -> Remove noise -> ... -> Image

The model LEARNS to reverse the noise!

Forward and Reverse Diffusion Process

Diffusion Model: Forward and Reverse ProcessForward Process (fixed): q(x_t | x_{t-1}) — Gradually add Gaussian noisexâ‚€CleanImagex₁Slightnoisex₂Morenoisex₃Evenmore···x_TPureNoiseReverse Process (learned): p_θ(x_{t-1} | x_t) — Gradually remove noisex_TPureNoisex_{T-1}Denoisestepx_{T-2}Denoisestep···x₁Denoisestepxâ‚€GeneratedImage!

How diffusion models generate images: This diagram shows the two core processes of diffusion models. The forward process (top, flowing right) gradually adds Gaussian noise to a clean image x₀ over T timesteps, progressively destroying information until it becomes pure noise x_T ~ N(0,I). This process is fixed and non-learned — the noise schedule β_t controls how quickly noise is added. The reverse process (bottom, flowing left) is learned by a neural network: starting from random noise x_T, it iteratively denoises one step at a time, progressively recovering the clean image. At each step, the model predicts the noise ε_θ(x_t, t) that was added, and subtracts it to get a slightly cleaner version. After T denoising steps, the result is a generated image x₀. The key insight: by learning to reverse a simple, known corruption process, we get a powerful generative model that can create realistic images from pure noise.


DDPM (Denoising Diffusion Probabilistic Models)

Training:

  1. Take clean image
  2. Sample random timestep
  3. Add noise:
  4. Model predicts noise:
  5. Loss:

Generation:

  1. Start with random noise
  2. For :
  3. Return

DDPM Noise Schedule

DDPM Noise Schedule and Training ObjectiveForward Processq(x_t | x_0) = N(x_t; √ε_t·x_0, (1-ε_t)I)ε_t = ∏_{s=1}^{t} (1 - β_s)β_t: noise schedule (linear, cosine, etc.)T = 1000 timesteps typicallyReverse Processp_θ(x_{t-1} | x_t) = N(x_{t-1}; Μ_θ(x_t,t), σ_t²I)Μ_θ = 1/√α_t (x_t - β_t/√(1-ε_t)·ε_θ)ε_θ: U-Net predicts noise at each steptimestep embedding guides the networkTraining Loss (Simplified)L_simple = E_{t,x_0,ε} [ ||ε - ε_θ(x_t, t)||² ]Predict the noise that was added, not the denoised image directly

Classifier-Free Guidance

Where = guidance scale:

  • : No guidance (standard)
  • : Good balance
  • : Very high quality, low diversity

Classifier-Free Guidance Visualization

Classifier-Free Guidance: Quality vs Diversity Trade-offw = 1.0Standard samplingHigh diversityLower qualityw = 7.5BalancedGood qualityGood diversityw = 15+High guidanceVery high qualityLow diversityGuideScaleLowHighHigher w pushes generations toward the conditioning signal (text prompt)

Latent Diffusion (Stable Diffusion)

Latent Diffusion Architecture

Latent Diffusion Model (Stable Diffusion)Image512×512×3EncoderVAE EncLatent z64×64×448× smaller!U-Net DiffusionDenoise in latent spaceCross-attention with textDenoised latent zâ‚€DecoderVAE DecOutput512×512×3Text Encoder (CLIP)"a photo of a cat"

Key Takeaways


What to Learn Next

-> GANs — Generative Adversarial Networks Complete Guide Learn about gans — generative adversarial networks complete guide.

-> Autoencoders — Encoding, Decoding and Representation Learning Learn about autoencoders — encoding, decoding and representation learning.

-> 19-variational-autoencoders Learn about 19-variational-autoencoders.

-> Neural Networks Fundamentals — Perceptrons to Deep Learning Learn about neural networks fundamentals — perceptrons to deep learning.

-> Transformers — Attention Is All You Need Complete Guide Learn about transformers — attention is all you need complete guide.

-> Self-Supervised Learning — Pre-training Revolution Learn about self-supervised learning — pre-training revolution.

Need Expert Machine Learning Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement