Blended Latent Diffusion

Omri Avrahami, Ohad Fried, Dani Lischinski

TL;DR

Blended Latent Diffusion (BLD) is a "zero-shot" method for local, text-driven image editing that is 10x–20x faster than previous pixel-space approaches. By performing diffusion in a compressed latent space and introducing novel techniques for background preservation and thin-mask handling, it produces seamless, high-precision edits without requiring model retraining.

What Problem Does This Paper Address?

While text-to-image models like Stable Diffusion can create stunning visuals from scratch, editing an existing image remains a challenge. Specifically, "local editing"—where a user wants to change a specific object or area (defined by a mask) while keeping the rest of the image perfectly intact—is difficult for two reasons:

  1. Efficiency: Early state-of-the-art methods like Blended Diffusion operated in pixel space, requiring roughly 25 minutes on a high-end GPU to produce a single result.
  2. Fidelity: Diffusion models often struggle to perfectly reconstruct the "background" (the unmasked area). Even small changes in the background are jarring to human eyes, especially in faces or text.
  3. Spatial Resolution: Latent Diffusion Models (LDMs) operate in a compressed space (usually 1/8th the resolution of the original image). This makes editing very thin or highly localized areas nearly impossible, as the mask becomes too small to influence the latent denoising process.

Methods

The authors propose Blended Latent Diffusion, which adapts the concept of spatial blending to the latent space of a pre-trained LDM. Their pipeline includes three key innovations:

  • Latent Blending: At each denoising step, the model generates a "foreground" latent (guided by the text prompt) and a "background" latent (the original image with added noise). These are blended using a downsampled version of the user's mask.
  • Per-Sample Decoder Optimization: Because the LDM’s Variational Autoencoder (VAE) is lossy, simply decoding the blended latent results in a blurry background. To fix this, the authors fine-tune the weights of the decoder for each specific image. This ensures the unmasked area is reconstructed with perfect high-frequency detail.
  • Progressive Mask Shrinking: To handle thin masks (like a thin bracelet or a wisp of smoke), the authors start the diffusion process with a dilated (thickened) mask. As the denoising progresses from global shapes to fine details, they gradually shrink the mask back to the user's original thin selection.
  • CLIP-Based Ranking: Since diffusion is stochastic, the model generates a batch of predictions. These are automatically ranked using a CLIP model to find the result that best matches the text prompt.

Datasets

The authors evaluated their method using:

  • Pre-trained Models: The standard Latent Diffusion Model (LDM) and CLIP (ViT-B/16).
  • Evaluation Set: 50 random images sourced from the web and private collections, paired with random rectangular masks and text prompts sampled from ImageNet classes.
  • User Study: A large-scale study on Amazon Mechanical Turk (AMT) comparing BLD against baselines like GLIDE, DALL-E 2, and the original Blended Diffusion.

Key Insights and Ideas

  • Latent Space is a "Safe Space": Operating in latents rather than pixels naturally avoids "clipping artifacts" (pixels going out of the 0-255 range) and makes the process more robust against adversarial examples that often plague CLIP-guided pixel diffusion.
  • Weight Optimization vs. Latent Optimization: In GAN inversion, researchers often optimize the latent vector to reconstruct an image. Here, the authors found that optimizing the decoder weights is far superior for preserving fine textures like skin pores or text on a book cover.
  • The Temporal Nature of Diffusion: The "Aha!" moment for thin masks was realizing that early diffusion steps determine coarse colors and shapes. By using a fat mask early on, the model has enough "room" in the latent space to establish the new object's presence before the mask shrinks to enforce the final boundaries.

Key Results

  • Speedup: BLD achieves a massive performance boost. While pixel-based Blended Diffusion takes ~23 seconds per image in a batch, BLD takes only 2.2 seconds (a ~10x improvement). When considering the full pipeline, it is roughly 20x faster.
  • Precision: In quantitative tests using an ImageNet classifier, BLD achieved 28.66% batch precision, nearly triple the precision of the original Blended Diffusion (~10.4%).
  • Qualitative Superiority: Human evaluators preferred BLD over baselines in terms of both visual quality and how well the edit matched the text prompt. It successfully avoided the "noise artifacts" common in previous methods.

Limitations and Future Work

  • Piece-wise Realism: Because the CLIP ranking only looks at the masked area, the model can sometimes produce an object that looks realistic on its own but doesn't quite "fit" the lighting or perspective of the global scene.
  • Text Bias: The underlying LDM sometimes interprets prompts literally as a request for text (e.g., trying to generate a book cover with the words "big mountain" rather than an actual mountain).
  • Inference Time: While much faster than before, taking ~1 minute to generate and rank a batch of 24 images is still too slow for some real-time creative workflows. Future work may involve using faster sampling methods like DDIM or consistency models.

Summary updated

BibTeX
@article{avrahami2023blended,
  author = {Omri Avrahami and Ohad Fried and Dani Lischinski},
  title = {{Blended Latent Diffusion}},
  journal = {ACM Trans. Graphics},
  year = {2023},
  url = {https://openreview.net/forum?id=eWP6KmB-4O},
}
Figure