Edit images by tampering with Stable Diffusion's cross-attention
An unofficial Stable Diffusion port that edits images by rewiring internal cross-attention maps, skipping the need for manual masks or wishful prompting.

What it does This Jupyter notebook implements an unofficial, modified port of Google’s Prompt-to-Prompt paper for Stable Diffusion. It lets you edit generated or existing images by manipulating the model’s internal cross-attention maps during inference—no manual masks, no retraining. You can swap subjects, inject styles, shift seasons, or dial individual prompt tokens up and down.
The interesting bit The README demonstrates that simply adding “without fog and without rocks” to a prompt fails to remove fog and rocks, while this approach reaches into the diffusion process and edits attention weights directly. It also includes a modified inverse DDIM pipeline to find latent vectors for existing photos, plus a finite-difference refinement so you can invert images at higher CFG scales without everything breaking.
Key highlights
- Edits by patching attention maps instead of prompting harder or masking pixels
- Supports target replacement, style injection, global scene edits, and per-token weight tweaks
- Includes image inversion with a modified inverse DDIM compatible with schedulers like K-LMS
- Can invert at higher classifier-free guidance values via adaptive finite-difference refinement
- Exposes two main functions:
stablediffusion(...)andprompt_token(...)
Caveats
- Fragile dependency: the notebook targets
diffusers==0.4.1and injects code into the model, so newer library versions are likely to break compatibility - Requires prompt fine-tuning to keep results consistent; the README notes that changing hair color can accidentally introduce a smile, which must be edited out by adjusting the
smiletoken weight - Unofficial implementation with modifications from the original paper methods
Verdict Grab it if you’re experimenting with controllable diffusion and can tolerate pinned legacy dependencies. Skip it if you need a maintained, production-ready editing pipeline.
Frequently asked
- What is bloc97/CrossAttentionControl?
- An unofficial Stable Diffusion port that edits images by rewiring internal cross-attention maps, skipping the need for manual masks or wishful prompting.
- Is CrossAttentionControl open source?
- Yes — bloc97/CrossAttentionControl is open source, released under the MIT license.
- What language is CrossAttentionControl written in?
- bloc97/CrossAttentionControl is primarily written in Jupyter Notebook.
- How popular is CrossAttentionControl?
- bloc97/CrossAttentionControl has 1.3k stars on GitHub.
- Where can I find CrossAttentionControl?
- bloc97/CrossAttentionControl is on GitHub at https://github.com/bloc97/CrossAttentionControl.