Overview

12 Generative Image Models

Generative image models translate natural language into images by learning a “visual grammar” from vast collections of image–caption pairs. Modern systems rely chiefly on diffusion, a counterintuitive process that starts from pure noise and iteratively removes what doesn’t belong until a coherent picture emerges. Trained at scale and often aided by language models, these generators connect words to pixels with remarkable fidelity, and fit within the broader landscape of generative learning alongside GANs, supervised, unsupervised, and reinforcement techniques.

Building such models begins with curating and cleaning diverse, well-captioned datasets while addressing licensing, privacy, and bias. Images are normalized to numeric tensors and paired with text embeddings; forward diffusion creates noisy training examples governed by a noise schedule (betas, alphas) and tracked by timesteps. A U-Net—an encoder–decoder CNN with skip connections—forms the denoising “brain,” fusing image features with timestep and text guidance (in large systems via cross‑attention). The training objective is simple but powerful: predict the exact noise added to an image (MSE loss) and update all weights via backprop. At inference, the process runs in reverse: starting from random noise, the model repeatedly predicts and subtracts noise using the same schedule until an image consistent with the prompt appears.

Quality and control arise from smart choices and add‑ons: dataset diversity and caption richness, timestep count and noise schedules, attention mechanisms, and disciplined training with validation loss or FID and checkpointing. Practical capabilities extend well beyond text‑to‑image: inpainting and outpainting edit or extend scenes; LoRA adapts styles efficiently; high‑resolution fixes and upscalers boost detail; ControlNets and IP‑Adapters enforce structure and style from references; and human‑feedback tuning refines aesthetics. The resulting tools power workflows from concept art, design, and advertising to personalized content and intelligent photo editing, all built on the same scalable diffusion-and-U‑Net foundation.

An analogy showing that Diffusion is about removing to create rather than adding
How Diffusion models fits into machine learning
An example of initial noise
An example of denoising
An example of denoising after more timesteps
An example of denoising after all timesteps
A workflow for training a diffusion model
Preparing image data in the diffusion model training workflow
Cleaning image data for training
Embedding in the diffusion model training lifecycle
Example basic image training data
How images are represented as normalized numbers
How RGB images are represented as matrices
Calculations for adding noise to an image
A progression of adding noise to an image over 1000 timesteps
A view of probability of selection in a normal distribution
Calculations for timestep embeddings
The embeddings for timestep 22
The embeddings for “a happy face”
A view of a feed-forward ANN processing the text embedding
A complete representation of one training data input
Designing the architecture in the Diffusion model training workflow
The difference between an ANN and a CNN
How a CNN filter scans an image
Calculations of a filter on an image for the first pixel
Feature maps produced by a convolutional layer
The U-Net architecture
The U-Net architecture for our example
Denoising in the Diffusion model training workflow
The first pixel of all feature maps produced by the first convolutional layer
Normalized values for the first pixel in all feature maps produced from the first convolutional layer
ReLU vs SiLU activation functions
Calculations for the SiLU activation function
The down-sampling convolutional layer in our U-Net
How filters scan an image with padding
Calculations for the down-sampling convolutional layer in our U-Net
Calculations for producing the final value for the first pixel in the feature map
The bridge convolutional layer in our U-Net
How the text embedding and timestep embedding are injected
Simplistic up-sampling with nearest neighbor interpolation
The up-sampling layer in our U-Net
How skip connection feature maps are combined with the up-sampled feature maps
The final convolutions to produce an noise prediction
Learning in the Diffusion model training lifecycle
Calculations for finding the loss
The ideal loss-over- time for a Diffusion model
Adjusting weights based on loss
The components whose weights are updated with backpropagation
Generating an image in the Diffusion model lifecycle
Starting with pure noise for making a prediction
How a denoised image is predicted
Calculations for finding timestep scale for timestep 1000
Generating a new image by removing noise
The denoised images from timestep 1000 to timestep 750
The denoised images from timestep 1000 to timestep 1
The denoised images when we generate with only 50 timesteps instead of 1000 timesteps
How cross-attention fits into the U-Net architecture

Summary of Generative Image Models

FAQ

What’s the core intuition behind diffusion-based image generation?Instead of “drawing” on a blank canvas, diffusion models start with pure noise and gradually remove what doesn’t fit the target concept. Trained on many image–caption pairs, the model learns to predict and subtract the right noise at each step so a coherent image emerges, much like a sculptor chiseling a figure out of marble.
What are the main stages of training a diffusion model?- Prepare and clean a large image–caption dataset - Encode images and text into numbers; construct a forward diffusion (noising) process - Choose an architecture (U-Net) suited for denoising - Train the model to predict the noise added at each timestep, conditioned on the caption - Compute loss (MSE) and backpropagate to update weights - After training, generate images by reversing the diffusion process from noise
How should I select and prepare training data, and why are captions so important?Use diverse, high-quality sources (web-crawled data, museum archives, scientific sets, stock photos, satellite images, synthetic 3D renders). Clean the data: standardize resolution/aspect ratio, remove watermarks/overlays, deduplicate and discard corrupted files, apply safety filtering, and improve captions (e.g., with a captioning model). Captions tie words to pixels; precise, descriptive captions are critical for following prompts accurately.
What legal, ethical, and safety concerns arise with image datasets?- Copyright: Most images are protected; training commercial models may require licenses. - Style mimicry: Reproducing recognizable living artists’ styles raises consent and compensation issues. - Representation and bias: Skewed datasets amplify stereotypes; strive for diversity and balance. - Misuse of likeness: Scraping faces without consent can violate privacy and enable abuse.
How are images and text converted into embeddings the model can use?Images are normalized numeric tensors (e.g., RGB channels scaled to small values centered around zero). Text prompts are processed by a pretrained text encoder into a dense embedding, then adapted via a small feed-forward network for the diffusion model. A timestep embedding (often sinusoidal) encodes the current noise level; it is also projected to match the model’s internal representation.
What is forward diffusion and what are β (beta), α (alpha), and ᾱ (alpha-bar)?Forward diffusion creates training examples by progressively adding Gaussian noise to clean images across timesteps. The schedule controls noise per step: - βt: noise rate at step t - αt = 1 − βt: signal retained at step t - ᾱt: cumulative product of α up to step t (how much original signal remains overall) During training, the model learns to predict the exact noise that was added.
Why do diffusion models use a U-Net, and how does it work?U-Nets are CNN-based, image-to-image architectures ideal for denoising. The encoder downsamples to capture global context; the decoder upsamples to reconstruct details. Skip connections pass high-resolution features from early layers directly to matching decoder layers, combining “what” (abstract meaning) with “where” (precise spatial detail). Embeddings for text and time are injected (at the bottleneck or via attention in larger models) to guide denoising.
How does image generation (inference) work, and why do timesteps matter?Inference reverses diffusion: start from pure noise and iterate backward through timesteps. At each step, the U-Net predicts the noise in the current image (conditioned on the prompt and timestep), and the algorithm subtracts a scaled amount using the same noise schedule used in training. More steps generally improve fidelity (finer, safer edits), while fewer steps are faster but can degrade quality.
How can I steer or adapt a diffusion model’s outputs?- Cross-attention: Aligns text tokens with image regions at multiple U-Net depths. - ControlNets: Inject structural guidance (e.g., edge maps, poses, depth) alongside the prompt. - IP-Adapters: Use a reference image to transfer style or character traits. - LoRA: Lightweight fine-tuning that adds small, learned matrices to a frozen base model for new styles/concepts. - High-Resolution Fix and upscalers: First get composition right at lower resolution, then refine or upscale for detail.
What are inpainting and outpainting, and how are they implemented?Inpainting edits within a masked region (remove/replace objects) while preserving the unmasked context. Outpainting expands the canvas beyond original borders and “fills in” plausible content guided by the prompt. Practically, at each denoising step, known pixels outside the mask are restored so only the masked area is regenerated, yielding seamless blends.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking AI Algorithms, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking AI Algorithms, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking AI Algorithms, Second Edition ebook for free