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

Prompt-to-Prompt Image Editing with Cross-Attention Control

Amir Hertz, Ron Mokady, Jay Tenenbaum, Kfir Aberman, Yael Pritch, Daniel Cohen-Or

Introduction

Large-scale text-to-image diffusion models, such as Stable Diffusion and Imagen, have demonstrated remarkable capabilities in generating highly diverse and realistic images from text prompts. However, these models are notoriously "fickle" when it comes to editing. If a user generates an image of a "lemon cake" and subsequently changes the prompt to "apple cake," the model typically generates a completely different composition, altering the lighting, background, and overall structure.

Current state-of-the-art editing techniques mitigate this issue by requiring the user to provide a spatial mask to localize the edit. Unfortunately, manual masking is cumbersome and often destroys the underlying structural information of the object being edited—for instance, masking out a cake to change its flavor often results in losing its original texture and shape. To address this, researchers have developed Prompt-to-Prompt, an intuitive framework that enables semantic image editing using only text, allowing users to change the what without losing the where.

The Role of Cross-Attention Maps

The core innovation of Prompt-to-Prompt lies in the discovery that cross-attention maps act as the "blueprints" of a generated image. In the U-Net architecture of a diffusion model, cross-attention layers sit between the visual features and the text embedding. These layers produce a spatial map for every word in the prompt, essentially dictating which pixels should "pay attention" to which words.

The authors observed that the spatial layout and geometry of an image are determined very early in the diffusion process. Furthermore, these cross-attention maps are highly interpretable; for example, the map for the word "bear" visually resembles the silhouette of a bear. By manipulating these maps, the system can perform precise, mask-free editing.

Prompt-to-Prompt Manipulation Techniques

The Prompt-to-Prompt method performs two parallel diffusion processes: one for the original prompt and one for the edited prompt. By "injecting" the attention maps from the original process into the edited version, the system can guide the new composition. The authors introduce three primary types of manipulation:

1. Word Swap To replace an object (e.g., changing a "dog" to a "cat"), the system replaces the target word in the prompt but forces the new generation to utilize the original object's attention maps. This perfectly preserves the original pose, position, and background.

2. Prompt Refinement To add new details or alter the overall style, the system preserves the attention maps for the words common to both prompts while allowing the newly introduced words to generate their own maps.

Prompt Refinement

3. Attention Re-weighting To amplify or dampen a specific attribute, the system scales the values of the attention map associated with that word. For example, a user can control the extent to which a word like "fluffy" is reflected in the final image.

Attention Re-weighting

By comparing the attention maps of the original and edited prompts, the system automatically deduces which parts of the image are changing. This enables localized edits while mathematically guaranteeing that the unedited background remains bit-for-bit identical.

Evaluation and Results

The researchers evaluated Prompt-to-Prompt across several high-profile models, including Google's Imagen and open-source models like Latent/Stable Diffusion. To quantify performance, they created a benchmark of 20 random examples across various descriptive templates.

  • User Preference: In a user study with 32 participants, Prompt-to-Prompt significantly outperformed existing methods such as VQGAN+CLIP and Text2Live. It scored 4.64/5 for background preservation (compared to 3.38 for the baseline) and 4.55/5 for text alignment.
  • Speed: Unlike GAN-based methods that require minutes of optimization per image, Prompt-to-Prompt runs in a single diffusion pass, taking roughly 20 seconds.
  • Real Image Editing: By utilizing DDIM Inversion—a process that turns a real photo back into the latent noise that would have generated it—the authors demonstrated that this technique can be successfully applied to real-world photographs, extending its utility beyond purely model-generated images.

Limitations and Future Directions

While highly effective, the method has a few limitations. When editing real photos, the DDIM inversion process is not always perfect, which can occasionally lead to slight distortions in the reconstructed image. Additionally, current attention maps are generated at relatively low resolutions (e.g., 16x16 or 64x64), limiting the precision of extremely fine-grained edits.

Finally, the method struggles with massive structural changes. Because the attention maps are tightly bound to the original spatial layout, it cannot easily change an object's fundamental pose, such as altering a dog from "sitting" to "running." Future work may explore incorporating cross-attention control into higher-resolution layers or developing more complex "pose-shifting" manipulations to overcome these structural limits.

Summary updated

BibTeX
@inproceedings{hertz2023prompt,
  author = {Amir Hertz and Ron Mokady and Jay Tenenbaum and Kfir Aberman and Yael Pritch and Daniel Cohen-Or},
  title = {{Prompt-to-Prompt Image Editing with Cross-Attention Control}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=_CDixzkzeyb},
}
Figure