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

Towards Efficient Diffusion-Based Image Editing with Instant Attention Masks

Siyu Zou, Jiji Tang, Yiyi Zhou, Jing He, Chaoyi Zhao, Rongsheng Zhang, Zhipeng Hu, Xiaoshuai Sun

Abstract

Diffusion-based Image Editing (DIE) has emerged as a powerful paradigm for text-driven image modification. However, achieving precise local control remains a significant challenge, typically requiring either labor-intensive manual masking or computationally expensive automated pre-processing. We introduce InstDiffEdit, a training-free, "plug-and-play" framework that generates accurate semantic masks instantly during the denoising process. By refining internal cross-attention maps, InstDiffEdit achieves state-of-the-art editing performance while running 5 to 6 times faster than existing automated methods like DiffEdit.

Introduction

A major hurdle in diffusion-based editing is isolating specific objects for modification without altering the background. For instance, changing a "British Shorthair cat" into a "Persian cat" requires a precise mask to preserve the surrounding context. Current approaches face a difficult trade-off: manual masking is accurate but slow; attention-based methods are often too noisy for direct use; and automated methods like DiffEdit require multiple extra diffusion iterations just to generate a mask, creating a significant computational bottleneck.

InstDiffEdit breaks this bottleneck by treating mask generation as an integrated, on-the-fly component of the diffusion process, eliminating the need for heavy pre-computation or manual intervention.

Methodology

The InstDiffEdit framework consists of two primary components designed to work within the standard denoising loop of Latent Diffusion Models (LDMs).

1. Instant Attention Mask Generation

While raw cross-attention maps in LDMs are inherently noisy, they contain latent semantic structures. InstDiffEdit utilizes a training-free refinement scheme:

  • Indexing: The system identifies an "index token" (the word most relevant to the edit) by comparing all token maps to a broad "start token" anchor using cosine similarity.
  • Refinement: It aggregates attention distributions from related tokens and applies adaptive thresholds to suppress background noise and sharpen object boundaries.

2. Hybrid Editing Pipeline

Once the mask is generated, the edit proceeds in two stages:

  • Mask-based Blending: In early denoising steps, the mask blends the predicted edited latent with the original noisy latent to lock the background.
  • Inpainting Refinement: In the final steps, an inpainting model uses the mask to ensure the new object integrates seamlessly with the original environment, preventing edge artifacts.
The InstDiffEdit framework compares manual masking with the proposed automated, instant mask generation process.

Experimental Evaluation

The authors evaluated InstDiffEdit on ImageNet, Imagen, and a new benchmark called Editing-Mask. This new dataset includes 200 images with human-labeled ground truth masks, allowing for the direct measurement of mask accuracy (Intersection over Union, IoU) and background preservation—metrics often overlooked in previous literature.

Key Results and Insights

InstDiffEdit demonstrates significant improvements in both efficiency and quality:

  • Speed: The method takes approximately 10.8 seconds per image, compared to 64.0 seconds for DiffEdit—a nearly 6x speedup achieved by generating masks in parallel with the edit.
  • Precision: On the Editing-Mask benchmark, InstDiffEdit achieved a 56.2% IoU, nearly doubling the 33.0% IoU of DiffEdit.
  • Fidelity: Qualitative results show that InstDiffEdit produces masks that closely align with human intent, allowing for complex edits (e.g., changing cat breeds) while keeping accessories like hats or skateboards perfectly intact.
Visual comparison showing the high fidelity of InstDiffEdit masks and the resulting edited images compared to manual baselines.

Conclusion and Future Work

InstDiffEdit provides a highly efficient path for automated local image editing. While its performance is currently tied to the quality of the underlying text-to-image model's attention maps, it offers a robust, training-free solution for real-time applications. Future research may extend this instant masking logic to video editing and more complex multi-object scenes.

Summary updated

BibTeX
@inproceedings{zou2024towards,
  author = {Siyu Zou and Jiji Tang and Yiyi Zhou and Jing He and Chaoyi Zhao and Rongsheng Zhang and Zhipeng Hu and Xiaoshuai Sun},
  title = {{Towards Efficient Diffusion-Based Image Editing with Instant Attention Masks}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i7.28622},
}
Figure