{"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/masactrl-tuning-free-mutual-self-attention","title":"MasaCtrl: Tuning-Free Mutual Self-Attention Control for Consistent Image Synthesis and Editing","arxiv_id":"2304.08465","date":"2023-04-17","proceeding":"ICCV 2023 1","authors":["Mingdeng Cao","Xintao Wang","Zhongang Qi","Ying Shan","XiaoHu Qie","Yinqiang Zheng"],"abstract":"Despite the success in large-scale text-to-image generation and text-conditioned image editing, existing methods still struggle to produce consistent generation and editing results. For example, generation approaches usually fail to synthesize multiple images of the same objects/characters but with different views or poses. Meanwhile, existing editing methods either fail to achieve effective complex non-rigid editing while maintaining the overall textures and identity, or require time-consuming fine-tuning to capture the image-specific appearance. In this paper, we develop MasaCtrl, a tuning-free method to achieve consistent image generation and complex non-rigid image editing simultaneously. Specifically, MasaCtrl converts existing self-attention in diffusion models into mutual self-attention, so that it can query correlated local contents and textures from source images for consistency. To further alleviate the query confusion between foreground and background, we propose a mask-guided mutual self-attention strategy, where the mask can be easily extracted from the cross-attention maps. Extensive experiments show that the proposed MasaCtrl can produce impressive results in both consistent image generation and complex non-rigid real image editing.","url_abs":"https://arxiv.org/abs/2304.08465v1","url_pdf":"https://arxiv.org/pdf/2304.08465v1.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":"masactrl-tuning-free-mutual-self-attention","repo_url":"https://github.com/tencentarc/masactrl","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"masactrl-tuning-free-mutual-self-attention","repo_url":"https://github.com/hansam95/nmg","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"masactrl-tuning-free-mutual-self-attention","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":"masactrl-tuning-free-mutual-self-attention","repo_url":"https://github.com/thu-cvml/texturediffusion","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"text-to-image-generation-1","task_name":"Text to Image Generation"},{"task_slug":"text-based-image-editing","task_name":"Text-based Image Editing"},{"task_slug":"text-to-image-generation","task_name":"Text-to-Image Generation"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"},{"method_slug":"fail","method_name":"fail"}],"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+MasaCtrl","rank_in_archive_order":14,"of":18,"metrics":{"Background LPIPS":"106.62","Background PSNR":"22.17","CLIPSIM":"23.96","Structure Distance":"28.38"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2304.08465","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2304.08465"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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/tencentarc/masactrl","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/thu-cvml/texturediffusion","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/phymhan/prompt-to-prompt","reach":null},{"provenance":"deterministic:regex_extraction","url":"https://github.com/TencentARC/MasaCtrl","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":4,"unverified":3},"by_repo_kind":{"official":{"samples":3,"ran":1,"repositories":1},"listed":{"samples":4,"ran":3,"repositories":3}},"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":1,"samples":[{"code_sha256_prefix":"7fb9819fe4147760","entry":"MutualSelfAttentionControl","repo":"phymhan/prompt-to-prompt","repo_kind":"listed","path":"masactrl/masactrl.py","file_url":"https://github.com/phymhan/prompt-to-prompt/blob/HEAD/masactrl/masactrl.py","link_basis":"first_harvest_node","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":"7fb9819fe4147760"}},{"code_sha256_prefix":"dbd107e2eef6654a","entry":"MutualSelfAttentionControl","repo":"thu-cvml/texturediffusion","repo_kind":"listed","path":"TextureDiffusion/TextureDiffusion.py","file_url":"https://github.com/thu-cvml/texturediffusion/blob/HEAD/TextureDiffusion/TextureDiffusion.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dbd107e2eef6654a"}},{"code_sha256_prefix":"ae14fd1082f17918","entry":"MutualSelfAttentionControl","repo":"TencentARC/MasaCtrl","repo_kind":"official","path":"masactrl/masactrl.py","file_url":"https://github.com/TencentARC/MasaCtrl/blob/HEAD/masactrl/masactrl.py","link_basis":"first_harvest_node","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":"ae14fd1082f17918"}},{"code_sha256_prefix":"ae0e1836a243c7ca","entry":"MutualSelfAttentionControl","repo":"hansam95/nmg","repo_kind":"listed","path":"MasaCtrl/masactrl.py","file_url":"https://github.com/hansam95/nmg/blob/HEAD/MasaCtrl/masactrl.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":"ae0e1836a243c7ca"}},{"code_sha256_prefix":"e7835b35aa8a8036","entry":"AttentionBase","repo":"phymhan/prompt-to-prompt","repo_kind":"listed","path":"masactrl/masactrl.py","file_url":"https://github.com/phymhan/prompt-to-prompt/blob/HEAD/masactrl/masactrl.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":"e7835b35aa8a8036"}},{"code_sha256_prefix":"d321812b8f73ef4b","entry":"regiter_attention_editor_diffusers","repo":"tencentarc/masactrl","repo_kind":"official","path":"masactrl/masactrl_utils.py","file_url":"https://github.com/tencentarc/masactrl/blob/HEAD/masactrl/masactrl_utils.py","link_basis":"plan_row","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":"d321812b8f73ef4b"}},{"code_sha256_prefix":"431f768e76ae86fa","entry":"regiter_attention_editor_ldm","repo":"tencentarc/masactrl","repo_kind":"official","path":"masactrl/masactrl_utils.py","file_url":"https://github.com/tencentarc/masactrl/blob/HEAD/masactrl/masactrl_utils.py","link_basis":"plan_row","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":"431f768e76ae86fa"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}