NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DiffEdit: Diffusion-based semantic image editing with mask guidance

Guillaume Couairon, Jakob Verbeek, Holger Schwenk, Matthieu Cord

TL;DR

DiffEdit is a zero-shot method for semantic image editing that automatically identifies which parts of an image need to change based on a text query. By contrasting noise predictions from different prompts and utilizing DDIM encoding, it achieves state-of-the-art results in localized editing without requiring manual masks or specialized model fine-tuning.

What Problem Does This Paper Address?

Semantic image editing is the task of modifying an image according to a text description (e.g., "change the bowl of apples to a bowl of pears") while keeping the rest of the scene—the bowl, the table, the lighting—exactly the same.

DiffEdit automatically generates a mask based on the text query to edit only the relevant parts of the image.

Current diffusion-based approaches face two major hurdles:

  1. The Masking Burden: Most high-quality editing methods require a user-provided mask to define the edit area, essentially treating the problem as a "conditional inpainting" task. Manual masking is tedious and counter-intuitive for a language-guided interface.
  2. Content Preservation: Methods that don't use masks (like SDEdit) often modify the entire image. Even if they only change the intended object, they frequently lose fine details of the original image (like the specific pose or texture of a dog being turned into a cat) because they rely on adding random Gaussian noise, which destroys information.

Methods

DiffEdit proposes a three-step framework that leverages a pre-trained, text-conditioned diffusion model (like Stable Diffusion) without any additional training.

The DiffEdit pipeline: (1) Automatic mask generation via contrastive noise, (2) DDIM encoding, and (3) Masked decoding.
  1. Step 1: Automatic Mask Generation. The core innovation is how DiffEdit "asks" the model where to edit. The researchers add noise to the input image and then compare the model's noise predictions when conditioned on two different prompts: a query (e.g., "zebra") and a reference (e.g., "horse"). The regions where the noise estimates differ most are precisely the areas that need to change. This difference is binarized to create an editing mask.
  2. Step 2: DDIM Encoding. Instead of just adding random noise to the image (which is "lossy"), DiffEdit uses DDIM encoding to find a latent representation that, when decoded unconditionally, would perfectly reconstruct the original image. This provides a much more stable starting point for the edit.
  3. Step 3: Masked Decoding. The model performs the diffusion process starting from the DDIM latent, conditioned on the query text. At each step, the generated mask is used to "paste" the background from the original (encoded) image back into the result, while allowing the model to synthesize new content only within the masked region.

Datasets

The authors evaluated DiffEdit across three distinct scenarios:

  • ImageNet: Used to evaluate class-to-class transformations (e.g., one animal species to another) using the evaluation protocol from the FlexIT paper.
  • Imagen-generated images: A set of 300 synthetic images generated from complex prompts to test compositional edits (changing backgrounds, adding clothes to animals, etc.).
  • COCO: Used for complex, multi-object scenes. They leveraged the BISON dataset, which provides captions that are similar to the original COCO images but contain one contradictory element, making them perfect "edit queries."

Key Insights and Ideas

  • The "Aha" of Contrastive Noise: The model's internal noise estimator is a powerful proxy for semantic location. If you change the text prompt, the model's "confusion" (noise estimate) shifts specifically in the pixels corresponding to that semantic change.
  • DDIM vs. Random Noise: The paper provides a mathematical proof showing that DDIM encoding provides a tighter bound on the distance between the original and edited image compared to the random noise approach used in SDEdit. In plain English: DDIM encoding "remembers" the original image better.
  • Reference Prompts Matter: While an empty reference prompt works, using a specific description of the original image (e.g., "a horse") significantly improves mask quality by helping the model ignore background elements that might be common to both prompts.

Key Results

  • State-of-the-Art Performance: On ImageNet, DiffEdit achieved a better trade-off between image realism (CSFID) and similarity to the original (LPIPS) than existing methods like SDEdit, ILVR, and FlexIT.
  • Qualitative Superiority: In side-by-side comparisons, DiffEdit was much better at preserving the "identity" of the scene. For example, when changing a cat to a dog, DiffEdit could maintain the cat's original pose and the exact background, whereas other methods often shifted the entire composition.
  • Efficiency: The process is fast, taking roughly 10 to 20 seconds on a single high-end GPU, making it viable for interactive tools.

Limitations and Future Work

  • Smooth Region Insertion: The mask generation module struggles to identify regions for inserting objects into empty, smooth areas (like adding a painting to a plain white wall) because the noise estimates don't vary much there.
  • Object Confusion: If an image contains multiple similar objects (e.g., two parrots) and the query is "a parrot," the mask might highlight both, leading to "over-editing."
  • Spatial Relations: The model still struggles with complex spatial reasoning, such as "move the car from the left to the right."
  • Future Direction: The authors suggest that future work could focus on automatically generating the "reference" text from the image itself, further reducing the input required from the user.

Summary updated

BibTeX
@inproceedings{couairon2023diffedit,
  author = {Guillaume Couairon and Jakob Verbeek and Holger Schwenk and Matthieu Cord},
  title = {{DiffEdit: Diffusion-based semantic image editing with mask guidance}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=3lge0p5o-M-},
}
Figure