Diffusion Models: How AI Generates Images from Noise

Also known as: Denoising diffusion model · Diffusion probabilistic model · DDPM

Definition

A diffusion model is a generative model trained to reverse a gradual noising process, allowing it to create a sample by starting from noise and repeatedly estimating a cleaner state.

Contents

A diffusion model is a generative model that learns how to reverse a process that gradually corrupts data with noise. During training, clean examples are perturbed at different noise levels, and a neural network learns a denoising-related prediction. During generation, the system begins with random noise and applies a sequence of learned updates until a structured sample emerges. Images are the most familiar application, but diffusion and related score-based methods can model other continuous data.

Four-stage diffusion diagram transforms random noise into rough shapes, emerging details, and a final red sailboat through repeated denoising

Simple analogy

Imagine learning to restore drawings seen through increasing amounts of static. During practice, you receive many drawings with known levels of noise and learn what clean structure is likely to lie underneath. To create a new drawing, you start from a page of static and repeatedly apply the restoration skill. Early steps establish rough composition; later steps refine edges, color, and texture.

The analogy should not be taken literally. A generated image is not usually one hidden training picture uncovered from noise. Sampling follows patterns learned from many examples and randomness, producing a new point from the model's learned distribution. Memorization can still occur and must be evaluated, but denoising is a generative computation rather than a database lookup.

How it works

Define a forward noising process

The forward process gradually adds Gaussian noise to a clean sample across a sequence of time steps. With enough steps, the data becomes close to a simple noise distribution. This corruption process is specified mathematically, so the training pipeline can take a clean example and produce a noisy version at a randomly chosen time level without simulating every earlier step.

The forward direction is used to construct training examples. It is not the direction used to generate the final image. That distinction is central: training starts with data and adds noise, while sampling starts with noise and removes it.

Learn a reverse prediction

A neural network receives a noisy sample and its time level. Depending on the formulation, it may predict added noise, a clean sample, a velocity-like target, or a score related to the gradient of the perturbed data distribution. These parameterizations lead to related denoising updates. Optimization compares the prediction with a known training target and adjusts model weights.

The network architecture is separate from the diffusion process. Image diffusion systems have often used U-Net-like networks, while other designs use Transformers or hybrids. Calling a system a diffusion model describes its generative process and training formulation, not one mandatory neural architecture.

Sample by iterative denoising

At generation time, the sampler creates random noise with the desired shape. It evaluates the trained model at a sequence of noise levels, updates the sample toward a cleaner estimate, and repeats. A stochastic sampler can inject randomness during updates; deterministic or partially deterministic samplers can follow different numerical paths. The number and schedule of evaluations affect speed and quality.

Generation is therefore usually more sequential than a single feed-forward image prediction. Faster samplers, distillation, and alternative formulations reduce the number of model evaluations, but they can introduce tradeoffs in fidelity, diversity, or training complexity.

Add conditioning and guidance

A conditional diffusion model receives extra information such as a class label, text embedding, low-resolution image, mask, or depth map. Conditioning steers the denoising trajectory toward samples compatible with that input. In text-to-image systems, a text encoder represents the prompt, and the denoising network uses that representation while updating the image or latent.

Classifier-free guidance combines conditional and unconditional predictions from a jointly trained model. Increasing guidance can strengthen alignment with a condition but may reduce diversity or create visual artifacts when pushed too far. Guidance is a sampling control, not a proof that every requested detail will appear correctly.

Operate in pixel or latent space

Pixel-space diffusion updates full image arrays. Latent diffusion first uses an autoencoder to compress images into a smaller representation, performs diffusion in that latent space, and decodes the final latent back to pixels. The latent diffusion work demonstrated how this approach can reduce computational requirements while supporting high-resolution conditional synthesis.

Compression is not free. The autoencoder can discard fine details, and the decoder influences the final appearance. Latent diffusion is an important implementation family, not a synonym for every diffusion model.

Why it matters

Diffusion models provide a flexible framework for high-quality generative modeling. The same denoising principle can support unconditional creation, text or class conditioning, inpainting, super-resolution, colorization, and other inverse problems. Iterative sampling makes it possible to incorporate constraints at multiple noise levels rather than commit to a full output in one step.

The framework also has meaningful costs. Training uses large datasets and substantial computation, while inference can require many sequential network evaluations. Output quality depends on the data, conditioning pipeline, sampler, guidance, and evaluation criteria. Generated images may reproduce bias, mishandle text or spatial relations, or resemble training material.

A diffusion model does not understand a prompt in isolation. A text-to-image system combines a text encoder, denoising model, sampler, often an autoencoder, and product-level safety or editing components. Confusing the complete application with the core diffusion process hides where errors and capabilities originate.

Practical use cases

  • Text-to-image generation: Condition denoising on a text representation to produce images matching a description.
  • Image editing and inpainting: Preserve known pixels or latent regions while synthesizing selected missing areas.
  • Super-resolution: Condition on a low-resolution input and generate a higher-resolution version consistent with it.
  • Image-to-image transformation: Use an encoded input, noise level, and condition to vary style or content while retaining selected structure.
  • Scientific inverse problems: Combine score-based priors with measurements for tasks such as reconstruction, when the formulation is validated for the domain.
  • Audio, video, and 3D generation: Apply related iterative generative methods to other continuous representations, with modality-specific architectures and costs.

Users should evaluate generated results for the actual task. Visual appeal alone does not measure prompt adherence, factual correctness, diversity, safety, or faithfulness to an input image.

Common misconceptions

“The model finds a hidden picture inside random noise.” The noise is an initial sample. Learned updates transform it toward a point in the model's data distribution; no predetermined picture is waiting inside.

“Diffusion means the model only removes noise.” Training defines a noising process and learns a reverse-related prediction. Generation uses repeated updates, conditioning, and a sampler.

“Every diffusion model is a text-to-image product.” Diffusion is a general generative framework. Text conditioning is one application, and systems can be unconditional or conditioned on many other signals.

“More denoising steps always improve the result.” Step count interacts with the training formulation and sampler. Beyond an appropriate schedule, extra evaluations may add cost without proportional benefit.

Frequently asked questions

Why does diffusion generation start with random noise?

The model is trained around a process whose most corrupted state follows a simple noise distribution. Sampling from that distribution provides a tractable starting point for the learned reverse updates.

What is the difference between pixel and latent diffusion?

Pixel diffusion updates the image representation directly. Latent diffusion compresses the image through an autoencoder, denoises the smaller latent representation, and decodes it back to pixels.

Does the same prompt always create the same image?

Not normally. The starting noise and stochastic sampling can change the result. Reusing a seed and fixed settings can improve reproducibility, but implementations and hardware may still affect exact output.

What does guidance scale control?

In classifier-free guidance, it controls how strongly conditional and unconditional predictions are combined. Stronger guidance can emphasize the condition but may reduce diversity or introduce artifacts.

Related concepts

Sources and further reading

  1. [1]Denoising Diffusion Probabilistic Models
  2. [2]Score-Based Generative Modeling through Stochastic Differential Equations
  3. [3]High-Resolution Image Synthesis with Latent Diffusion Models
  4. [4]Classifier-Free Diffusion Guidance