Stable Diffusion
13 memberslucid.models.generative.stable_diffusionStable Diffusion family — Rombach et al., CVPR 2022.
Rombach, Robin, et al. "High-Resolution Image Synthesis with Latent Diffusion Models." CVPR, 2022, pp. 10684–10695.
Diffusion in pixel space spends most of its capacity on detail the eye discards. Latent diffusion splits the problem in two: an autoencoder learns a perceptually equivalent space at a fraction of the resolution, and the diffusion model runs entirely inside it.
The first stage is an encoder and decoder with a downsampling factor . At a image becomes a latent — 48 times fewer values, so every subsequent convolution and attention costs proportionally less. The paper regularises this space rather than leaving it free: a slight KL penalty toward keeps the latents from drifting to arbitrary scale, which matters because the diffusion process assumes unit-ish variance.
The second stage is a time-conditional U-Net trained on the usual denoising objective, but on latents:
Conditioning enters by cross-attention rather than concatenation, which is what makes the modality of irrelevant to the U-Net. With the flattened intermediate representation,
so the latent asks the questions and the conditioning answers them. A text encoder, a class embedding and a layout map all present the same interface — a sequence of vectors — and the U-Net never learns which it is reading.
is deliberately left open by the paper, which evaluates several. The released models use a frozen CLIP text encoder, so the width below is CLIP's and the conditioning sequence is its 77 tokens.
Classes
AutoencoderKL4 methodsThe KL-regularised first stage of a latent diffusion model.
AutoencoderKLOutput1 methodsWhat AutoencoderKL returns.
DiagonalGaussian4 methodsThe posterior a spatial encoder emits, as a distribution.
StableDiffusionConfig2 methodsFrozen configuration dataclass for every Stable Diffusion variant.
StableDiffusionForImageGeneration3 methodsStable Diffusion posed as a sampler.
StableDiffusionModel4 methodsLatent diffusion: an autoencoder, a conditional U-Net, a sampler.
StableDiffusionOutput1 methodsWhat StableDiffusionModel returns.
DDIMScheduler4 methodsDeterministic (or partly stochastic) sampling over a step subset.
PNDMScheduler4 methodsThe release's default sampler — linear multistep over DDIM's step.
UNet2DConditionModel2 methodsThe denoiser .