Latent diffusion model
The latent diffusion model (LDM) is a diffusion model architecture developed by the CompVis (Computer Vision & Learning) group at LMU Munich. Introduced in 2015, diffusion models (DMs) are trained with the objective of removing successive applications of noise (commonly Gaussian) on training images. The LDM is an improvement on standard DM by performing diffusion modeling in a latent space, and by allowing self-attention and cross-attention conditioning. LDMs are widely used in practical diffusion models. For instance, Stable Diffusion versions 1.1 to 2.1 were based on the LDM architecture. Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
The latent diffusion model (LDM) is a diffusion model architecture developed by the CompVis (Computer Vision & Learning) group at LMU Munich. Introduced in 2015, diffusion models (DMs) are trained with the objective of removing successive applications of noise (commonly Gaussian) on training images. The LDM is an improvement on standard DM by performing diffusion modeling in a latent space, and by allowing self-attention and cross-attention conditioning. LDMs are widely used in practical diffusion models. For instance, Stable Diffusion versions 1.1 to 2.1 were based on the LDM architecture. A latent image array, produced by the VAE encoder. It has dimensions (\text{channel}, \text{width}, \text{height}) . Typically, (\text{channel}, \text{width}, \text{height}) = (4, 64, 64) . A timestep-embedding vector, which tells the backbone how much noise there is in the image. For example, an embedding of timestep t = 0 would indicate that the input image is already noiseless, while t = 100 would mean there is much noise. A modality-embedding vector sequence, which indicates to the backbone about additional conditions for denoising. For example, in text-to-image generation, the text is divided into a sequence of tokens, then encoded by a text encoder, such as a CLIP encoder, before feeding into the backbone. As another example, an input image can be processed by a Vision Transformer into a sequence of vectors, which can then be used to condition the backbone for tasks such as generating an image in the same style. Each run through the U-Net backbone produces a predicted noise vector. This noise vector is scaled down and subtracted away from the latent image array, resulting in a slightly less noisy latent image. The denoising is repeated according to a denoising schedule ("noise schedule"), and the output of the last step is processed by the VAE decoder into a finished image. Similar to the standard U-Net, the U-Net backbone used in the SD 1.5 is essentially composed of down-scaling layers followed by up-scaling layers. However, the U-Net backbone has additional modules to allow for it to handle the embedding. As an illustration, we describe a single down-scaling layer in the backbone: The latent array and the time-embedding are processed by a ResBlock : The latent array is processed by a convolutional layer. The time-embedding vector is processed by a one-layered feedforward network, then added to the previous array (broadcast over all pixels). This is processed by another convolutional layer, then another time-embedding. The latent array and the embedding vector sequence are processed by a SpatialTransformer , which is essentially a standard pre-LN Transformer decoder without causal masking. In the cross-attentional blocks, the latent array itself serves as the query sequence, one query-vector per pixel. For example, if, at this layer in the U-Net, the latent array has dimensions (128, 32, 32) , then the query sequence has 1024 vectors, each of which has 128 dimensions. The embedding vector sequence serves as both the key sequence and as the value sequence. When no embedding vector sequence is input, a cross-attentional block defaults to self-attention, with the latent array serving as the query, key, and value. In pseudocode, def ResBlock(x, time, residual_channels): x_in = x time_embedding = feedforward_network(time) x = concatenate(x, residual_channels) x = conv_layer_1(activate(normalize_1(x))) + time_embedding x = conv_layer_2(dropout(activate(normalize_2(x)))) return x_in + x def SpatialTransformer(x, cond): x_in = x x = normalize(x) x = proj_in(x) x = cross_attention(x, cond) x = proj_out(x) return x_in + x def unet(x, time, cond): residual_channels = [] for resblock, spatialtransformer in downscaling_layers: x = resblock(x, time) residual_channels.append(x) x = spatialtransformer(x, cond) x = middle_layer.resblock_1(x, time) x = middle_layer.spatialtransformer(x, time) x = middle_layer.resblock_2(x, time) for resblock, spatialtransformer in upscaling_layers: residual = residual_channels.pop() x = resblock(concatenate(x, residual), time) x = spatialtransformer(x, cond) return x The detailed architecture may be found in.
Cite this
"Latent diffusion model". 1791346224. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1378986443 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy