{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/prompt-to-prompt-image-editing-with-cross","title":"Prompt-to-Prompt Image Editing with Cross Attention Control","arxiv_id":"2208.01626","date":"2022-08-02","proceeding":null,"authors":["Amir Hertz","Ron Mokady","Jay Tenenbaum","Kfir Aberman","Yael Pritch","Daniel Cohen-Or"],"abstract":"Recent large-scale text-driven synthesis models have attracted much attention thanks to their remarkable capabilities of generating highly diverse images that follow given text prompts. Such text-based synthesis methods are particularly appealing to humans who are used to verbally describe their intent. Therefore, it is only natural to extend the text-driven image synthesis to text-driven image editing. Editing is challenging for these generative models, since an innate property of an editing technique is to preserve most of the original image, while in the text-based models, even a small modification of the text prompt often leads to a completely different outcome. State-of-the-art methods mitigate this by requiring the users to provide a spatial mask to localize the edit, hence, ignoring the original structure and content within the masked region. In this paper, we pursue an intuitive prompt-to-prompt editing framework, where the edits are controlled by text only. To this end, we analyze a text-conditioned model in depth and observe that the cross-attention layers are the key to controlling the relation between the spatial layout of the image to each word in the prompt. With this observation, we present several applications which monitor the image synthesis by editing the textual prompt only. This includes localized editing by replacing a word, global editing by adding a specification, and even delicately controlling the extent to which a word is reflected in the image. We present our results over diverse images and prompts, demonstrating high-quality synthesis and fidelity to the edited prompts.","url_abs":"https://arxiv.org/abs/2208.01626v1","url_pdf":"https://arxiv.org/pdf/2208.01626v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"prompt-to-prompt-image-editing-with-cross","repo_url":"https://github.com/google/prompt-to-prompt","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"prompt-to-prompt-image-editing-with-cross","repo_url":"https://github.com/bloc97/CrossAttentionControl","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"prompt-to-prompt-image-editing-with-cross","repo_url":"https://github.com/chenwu98/cycle-diffusion","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"prompt-to-prompt-image-editing-with-cross","repo_url":"https://github.com/hansam95/nmg","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"prompt-to-prompt-image-editing-with-cross","repo_url":"https://github.com/miguelCalado/prompt-to-prompt-tensorflow","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"prompt-to-prompt-image-editing-with-cross","repo_url":"https://github.com/phymhan/prompt-to-prompt","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"prompt-to-prompt-image-editing-with-cross","repo_url":"https://github.com/wandb/examples/blob/master/colabs/cross-attention-control/Cross_Attention_Control_WandB.ipynb","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"jax","reach":{"status":"ok"}}],"tasks":[{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"text-based-image-editing","task_name":"Text-based Image Editing"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/text-based-image-editing-on-pie-bench","task":"Text-based Image Editing","dataset":"PIE-Bench","model":"DDIM Inversion+Prompt-to-Prompt","rank_in_archive_order":17,"of":18,"metrics":{"Background LPIPS":"208.80","Background PSNR":"17.87","CLIPSIM":"25.01","Structure Distance":"69.43"},"uses_additional_data":false}],"syntology":{"syntology_url":"https://syntology.ai/paper/2208.01626","atlas_url":"https://app.syntology.ai/?focus=2208.01626","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2208.01626"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/miguelCalado/prompt-to-prompt-tensorflow","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hansam95/nmg","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/chenwu98/cycle-diffusion","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/google/prompt-to-prompt","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/wandb/examples/blob/master/colabs/cross-attention-control/Cross_Attention_Control_WandB.ipynb","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/phymhan/prompt-to-prompt","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/bloc97/CrossAttentionControl","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":4,"ran_violates":1,"ran_honours":1,"ran_draft_wrong":2,"unverified":7},"by_repo_kind":{"official":{"samples":1,"ran":0,"repositories":1},"listed":{"samples":12,"ran":6,"repositories":4}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":3,"samples":[{"code_sha256_prefix":"f92b0f0ea89b9495","entry":"AttentionStore","repo":"hansam95/nmg","repo_kind":"listed","path":"prompt_to_prompt/ptp_utils.py","file_url":"https://github.com/hansam95/nmg/blob/HEAD/prompt_to_prompt/ptp_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f92b0f0ea89b9495"}},{"code_sha256_prefix":"eb721f1e5050ad01","entry":"CrossAttention","repo":"chenwu98/cycle-diffusion","repo_kind":"listed","path":"model/lib/stable_diffusion/ldm/modules/attention.py","file_url":"https://github.com/chenwu98/cycle-diffusion/blob/HEAD/model/lib/stable_diffusion/ldm/modules/attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"eb721f1e5050ad01"}},{"code_sha256_prefix":"424012cb37b31172","entry":"default","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"424012cb37b31172"}},{"code_sha256_prefix":"e756b026e8544be8","entry":"get_mapper","repo":"miguelCalado/prompt-to-prompt-tensorflow","repo_kind":"listed","path":"seq_aligner.py","file_url":"https://github.com/miguelCalado/prompt-to-prompt-tensorflow/blob/HEAD/seq_aligner.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e756b026e8544be8"}},{"code_sha256_prefix":"90914e1d22798d8a","entry":"get_word_inds","repo":"hansam95/nmg","repo_kind":"listed","path":"prompt_to_prompt/ptp_utils.py","file_url":"https://github.com/hansam95/nmg/blob/HEAD/prompt_to_prompt/ptp_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"90914e1d22798d8a"}},{"code_sha256_prefix":"f019b0bdea83a11a","entry":"global_align","repo":"miguelCalado/prompt-to-prompt-tensorflow","repo_kind":"listed","path":"seq_aligner.py","file_url":"https://github.com/miguelCalado/prompt-to-prompt-tensorflow/blob/HEAD/seq_aligner.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f019b0bdea83a11a"}},{"code_sha256_prefix":"f2fe51a4a5646c6f","entry":"max_neg_value","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"f2fe51a4a5646c6f"}},{"code_sha256_prefix":"35d28dc49040562c","entry":"update_alpha_time_word","repo":"hansam95/nmg","repo_kind":"listed","path":"prompt_to_prompt/ptp_utils.py","file_url":"https://github.com/hansam95/nmg/blob/HEAD/prompt_to_prompt/ptp_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"35d28dc49040562c"}},{"code_sha256_prefix":"2f95aad416a92bda","entry":"AttentionControl","repo":"hansam95/nmg","repo_kind":"listed","path":"prompt_to_prompt/ptp_utils.py","file_url":"https://github.com/hansam95/nmg/blob/HEAD/prompt_to_prompt/ptp_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2f95aad416a92bda"}},{"code_sha256_prefix":"8681c8453f5e2137","entry":"AttentionControlEdit","repo":"hansam95/nmg","repo_kind":"listed","path":"prompt_to_prompt/ptp_utils.py","file_url":"https://github.com/hansam95/nmg/blob/HEAD/prompt_to_prompt/ptp_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8681c8453f5e2137"}},{"code_sha256_prefix":"8a805bc148037fbd","entry":"LocalBlend","repo":"hansam95/nmg","repo_kind":"listed","path":"prompt_to_prompt/ptp_utils.py","file_url":"https://github.com/hansam95/nmg/blob/HEAD/prompt_to_prompt/ptp_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8a805bc148037fbd"}},{"code_sha256_prefix":"81db21bf982ca0fe","entry":"get_matrix","repo":"miguelCalado/prompt-to-prompt-tensorflow","repo_kind":"listed","path":"seq_aligner.py","file_url":"https://github.com/miguelCalado/prompt-to-prompt-tensorflow/blob/HEAD/seq_aligner.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"81db21bf982ca0fe"}},{"code_sha256_prefix":"b84383c30daa723c","entry":"get_time_words_attention_alpha","repo":"hansam95/nmg","repo_kind":"listed","path":"prompt_to_prompt/ptp_utils.py","file_url":"https://github.com/hansam95/nmg/blob/HEAD/prompt_to_prompt/ptp_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b84383c30daa723c"}},{"code_sha256_prefix":"ea0c551b3830dfeb","entry":"register_attention_control","repo":"phymhan/prompt-to-prompt","repo_kind":"listed","path":"ptp_utils.py","file_url":"https://github.com/phymhan/prompt-to-prompt/blob/HEAD/ptp_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ea0c551b3830dfeb"}},{"code_sha256_prefix":"5427f43aa7709411","entry":"register_attention_control","repo":"google/prompt-to-prompt","repo_kind":"official","path":"ptp_utils.py","file_url":"https://github.com/google/prompt-to-prompt/blob/HEAD/ptp_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5427f43aa7709411"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}