Diffusion-based models, exemplified by Mid-journey, DALL-E, and Stable Diffusion, offer a unique approach to data generation by applying random noise and evolving it over time. While each model has its unique features, they all showcase the potential of diffusion-based techniques in creating high-quality, natural-looking outputs in machine learning
Background
In recent years, diffusion-based models have become a hot topic in the world of ML, offering a unique approach to generating high-quality data like images or text. Unlike traditional machine learning models, which typically operate through straightforward mapping functions, diffusion models work by applying random noise to data and evolving it over time. This results in a more organic, less predictable pattern that can generate more natural-looking images or produce more nuanced textual outputs.
Models like Mid-journey, DALL-E, and Stable Diffusion represent the cutting edge in this space. Mid-journey and Stable Diffusion are particularly focused on image generation and take advantage of an offline, open-source framework to ensure quality and accessibility. DALL-E, on the other hand, is widely celebrated for its capability to generate highly creative images based on textual prompts. While each has its own unique features and benefits, they all exemplify the power and potential of diffusion-based techniques in machine learning.
Basic Frameworks
The best-in-class image generation models typically contain the following three main components (Those three components are usually trained separately and assembled together).
Some Examples
Stable Diffusion: [ Src: High-Resolution Image Synthesis with Latent Diffusion Models]

DALL-E Series: [Src1: Zero-Shot Text-to-Image Generation], [Src2: Zero-Shot Text-to-Image Generations]

Imagen: [Src: Photorealistic Text-to-Image Diffusion Models with Deep Language Understanding]

Additional Info
Some common terms found in papers.
More about Text Encoder
FID (Fréchet inception distance) is a metric used to assess the quality of images created by a generative model. It uses a pre-trained CNN (image classification) model. You will throw images (machine-generated and real) into the CNN model to obtain their latent representations. Then you can calculate the Fréchet distance based on the assumption that both distribution are gaussian (Smaller distance means better, a lot of samples are needed).
CLIP (Contrastive Language-Image Pre-Training) utilizes 400 million image-text pairs ([link]). CLIP has an image encoder and a text encoder; they both take inputs and generate vectors (distances between vector is used to see if the image-text pair a good match).
More about Decoder
Decoder can be trained without labelled data (remember, it takes some intermediate representations, B).
Bis a smaller image: decoder makes a bigger image.Bis alatent Representation: train aauto-encoder. (train an encoder-decoder pair, take the decoder)
More about Generation Model
Reminder: the Generation Model takes a vector representation of the text, and generate an (somewhat compressed) intermediate representation (or just the latent representation).
Noise is added to the latent representation during diffusion process (this is something quite unique).
- Start with an
encoderand generate someintermediate representation. - Add step-wise
noise. - Train a
Noise Predictor
Some Mathematics Behind
Basic Concepts
Intuitively, there are —
- Forward Process: sequentially adding noise to image till not able to see the original image.
- Reverse Process: sequentially denoising till recovering the image.
VAE vs. Diffusion Model has great resemblance. VAE uses an encoder to convert image to latent space, and use a decoder to recover image from its latent representation. The noise adding (N times) processes in the Diffusion Model can be treated as an encoder (in this case, not a NN that can be learned, it is predefined by human), and the denoising (N times) processes is like a decoder.
Denoising Diffusion Probabilistic Models
Training
- repeat
- sample the clean image
- sample a whole number
- sample noise (or
taget noise) - Take gradient descent step on this is rather complicated.
- is just a
noisy image, it is the weighted sum of and , where is a set of predefined weights that gradually goes smaller. - in is a
noise predictor. It takes anoisy imageand a number - The target (or ground truth) of the
noise predictoris thetarget noise
- is just a
- until converged.
Inference
Inference is the image generation process.
Overview:
- sample an all-noise image
- for do start of the reverse process, total times
- if , else sample another noise,
- is the
denoisedresult.- is the image generated from the previous step. The image is pure noise when
- Inside , is the noise output from the
noise predictor. - Adds one more niose times a constant,
- end for
- return
Process:
- Prepare following two series of predefined numerical values:
- The
noise predictortakes an image and , yielding- times , which is used to subtract from
- is step-dependent
- multiply by a fraction
- times , which is used to subtract from
- Add noise to get
So, things are getting super trippy now, we need to step back for a little bit.
Shared Goals For Generative Models
It simply looks like this:
- Sample a vector from a known distribution
- Put into a network plus some condition (for txt-img models)
Maximum Likelihood Estimation
- Sample images from , is the world of possible images (the entire process is sampling training data)
- Assume we can somehow calculate , is the probability of generating any image from . (this is a difficult process, is not necessarily a gaussian distribution)
- can be defined as an objective function
Dive in
Why
Maximum Likelihoodis equivalent to ?
BecauseMaximum Likelihood=Minimize KL Divergence
VAE
For VAE (Variational Autoencoder), following the process described in the previous section. Sample , put in the network which describe the relationship
DDPM
Denoising Diffusion Probabilistic Models (DDPM)
Comparison
VAE: Maximize Maximize
DDPM: Maximize Maximize
Forward Process