LIME: Localized Image Editing via Attention Regularization in Diffusion Models

Enis Simsar, Alessio Tonioni, Yongqin Xian, Thomas Hofmann, Federico Tombari

Introduction: The Challenge of Entanglement

Diffusion models (DMs) like Stable Diffusion have revolutionized image generation, yet editing existing images with precision remains a significant challenge. A primary hurdle is entanglement, where a text-guided edit intended for a specific object inadvertently alters unrelated regions. For instance, an instruction to "put a hat on the horse" might unintentionally change the horse's color or the background landscape.

Existing solutions typically require manual masking—a tedious process—or complex, dataset-specific fine-tuning. LIME (Localized IMage Editing) introduces a zero-shot framework that achieves surgical precision in image editing without requiring user-provided masks or additional training.

Figure 1: Qualitative comparison between the baseline InstructPix2Pix (IP2P) and LIME across various editing tasks. LIME demonstrates superior localization, preserving the background and unrelated objects while accurately executing the instruction.

The LIME Framework

LIME operates as a modular, two-step pipeline that can be integrated with pre-trained models such as InstructPix2Pix (IP2P).

1. Automated Edit Localization

Rather than relying on external segmentation models, LIME leverages the internal semantic knowledge of the Diffusion Model's U-Net. By extracting intermediate features and applying K-means clustering, the framework segments the image into logical components (e.g., foreground objects vs. background). It then analyzes cross-attention maps—which represent the relationship between text tokens and image pixels—to automatically identify the Region of Interest (RoI) corresponding to the edit instruction.

2. Attention Regularization

The core innovation of LIME is its novel attention regularization technique applied during the denoising process. The framework identifies "unrelated" tokens in the text prompt (such as stop words or structural markers) and penalizes their attention scores specifically within the RoI. This forces the model to concentrate its "editing energy" on meaningful action words (e.g., "blue," "hat"), preventing background features from bleeding into the edited area and ensuring high fidelity to the original image structure.

Experimental Results

The authors evaluated LIME using the MagicBrush benchmark and the InstructPix2Pix (IP2P) Test Split.

  • Quantitative Performance: On MagicBrush, LIME significantly outperformed the base IP2P model across metrics including pixel accuracy (L1/L2) and semantic consistency (DINO/CLIP-I).
  • User Preference: A study involving 53 participants revealed that 72% of users preferred LIME over the standard IP2P, citing its superior ability to localize changes and maintain the integrity of the original scene.
  • Qualitative Precision: As shown in Figure 1, LIME successfully executes complex edits—such as changing the color of a carpet or adding accessories to an animal—while leaving the surrounding environment perfectly intact, a task where baseline models often fail by altering the entire image's style or color palette.

Conclusion and Future Work

LIME demonstrates that the internal features of diffusion models are sufficient for high-quality, zero-shot localized editing. By "silencing" irrelevant text tokens, LIME provides a plug-and-play solution for precise image manipulation. While the framework is currently limited by the underlying capabilities of its base model, future work may involve integrating Large Language Models (LLMs) to further refine edit instructions and minimize artifacts caused by complex feature mixing.

Summary updated

BibTeX
@inproceedings{simsar2025lime,
  author = {Enis Simsar and Alessio Tonioni and Yongqin Xian and Thomas Hofmann and Federico Tombari},
  title = {{LIME: Localized Image Editing via Attention Regularization in Diffusion Models}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2025},
  doi = {10.1109/wacv61041.2025.00032},
}
Figure