{"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/compositional-text-to-image-synthesis-with","title":"Compositional Text-to-Image Synthesis with Attention Map Control of Diffusion Models","arxiv_id":"2305.13921","date":"2023-05-23","proceeding":null,"authors":["Ruichen Wang","Zekang Chen","Chen Chen","Jian Ma","Haonan Lu","Xiaodong Lin"],"abstract":"Recent text-to-image (T2I) diffusion models show outstanding performance in generating high-quality images conditioned on textual prompts. However, they fail to semantically align the generated images with the prompts due to their limited compositional capabilities, leading to attribute leakage, entity leakage, and missing entities. In this paper, we propose a novel attention mask control strategy based on predicted object boxes to address these issues. In particular, we first train a BoxNet to predict a box for each entity that possesses the attribute specified in the prompt. Then, depending on the predicted boxes, a unique mask control is applied to the cross- and self-attention maps. Our approach produces a more semantically accurate synthesis by constraining the attention regions of each token in the prompt to the image. In addition, the proposed method is straightforward and effective and can be readily integrated into existing cross-attention-based T2I generators. We compare our approach to competing methods and demonstrate that it can faithfully convey the semantics of the original text to the generated content and achieve high availability as a ready-to-use plugin. Please refer to https://github.com/OPPOMente-Lab/attention-mask-control.","url_abs":"https://arxiv.org/abs/2305.13921v2","url_pdf":"https://arxiv.org/pdf/2305.13921v2.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":"compositional-text-to-image-synthesis-with","repo_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"attribute","task_name":"Attribute"},{"task_slug":"image-generation","task_name":"Image Generation"}],"methods":[{"method_slug":"align","method_name":"ALIGN"},{"method_slug":"diffusion","method_name":"Diffusion"},{"method_slug":"fail","method_name":"fail"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2305.13921","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2305.13921"}},"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/OPPO-Mente-Lab/attention-mask-control","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_violates":1,"ran_draft_wrong":1,"ran":1,"unverified":11},"by_repo_kind":{"official":{"samples":14,"ran":3,"repositories":1}},"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":0,"samples":[{"code_sha256_prefix":"ac8fe530cdad4d8c","entry":"dice_loss","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"boxnet_models/segmentation.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/boxnet_models/segmentation.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ac8fe530cdad4d8c"}},{"code_sha256_prefix":"5c0711aada67957e","entry":"sigmoid_focal_loss","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"boxnet_models/segmentation.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/boxnet_models/segmentation.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5c0711aada67957e"}},{"code_sha256_prefix":"534b549a2186b672","entry":"tokenize","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"train_boxnet.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/train_boxnet.py","link_basis":"plan_row","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":"534b549a2186b672"}},{"code_sha256_prefix":"9083e7dd88fe1570","entry":"build_transformer","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"boxnet_models/transformer.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/boxnet_models/transformer.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":"9083e7dd88fe1570"}},{"code_sha256_prefix":"2948eb1d2e3a4170","entry":"custom_decoder","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"custom_dataset.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/custom_dataset.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":"2948eb1d2e3a4170"}},{"code_sha256_prefix":"8569a155ef139702","entry":"cv2ImgAddText","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"p2p.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/p2p.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":"8569a155ef139702"}},{"code_sha256_prefix":"156b5fef80b6fc81","entry":"expand_text","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"custom_dataset.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/custom_dataset.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":"156b5fef80b6fc81"}},{"code_sha256_prefix":"ff6b336fe24b3a0e","entry":"get_consume_samples","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"universal_datamodule.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/universal_datamodule.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":"ff6b336fe24b3a0e"}},{"code_sha256_prefix":"4ceef3594b69a5ef","entry":"load_bbox","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"coco_preprocess.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/coco_preprocess.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":"4ceef3594b69a5ef"}},{"code_sha256_prefix":"75fc999b2834b581","entry":"load_captions","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"coco_preprocess.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/coco_preprocess.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":"75fc999b2834b581"}},{"code_sha256_prefix":"ae52c3450f164ea5","entry":"save_input_hook","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"train_boxnet.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/train_boxnet.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":"ae52c3450f164ea5"}},{"code_sha256_prefix":"bd578666f3556b90","entry":"save_out_hook","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"train_boxnet.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/train_boxnet.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":"bd578666f3556b90"}},{"code_sha256_prefix":"75f3f5c72eded945","entry":"text_under_image","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"p2p.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/p2p.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":"75f3f5c72eded945"}},{"code_sha256_prefix":"9911847e9b3e81ac","entry":"view_images","repo":"OPPO-Mente-Lab/attention-mask-control","repo_kind":"official","path":"p2p.py","file_url":"https://github.com/OPPO-Mente-Lab/attention-mask-control/blob/HEAD/p2p.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":"9911847e9b3e81ac"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}