{"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/realcompo-dynamic-equilibrium-between-realism","title":"RealCompo: Balancing Realism and Compositionality Improves Text-to-Image Diffusion Models","arxiv_id":"2402.12908","date":"2024-02-20","proceeding":null,"authors":["Xinchen Zhang","Ling Yang","Yaqi Cai","Zhaochen Yu","Kai-Ni Wang","Jiake Xie","Ye Tian","Minkai Xu","Yong Tang","Yujiu Yang","Bin Cui"],"abstract":"Diffusion models have achieved remarkable advancements in text-to-image generation. However, existing models still have many difficulties when faced with multiple-object compositional generation. In this paper, we propose RealCompo, a new training-free and transferred-friendly text-to-image generation framework, which aims to leverage the respective advantages of text-to-image models and spatial-aware image diffusion models (e.g., layout, keypoints and segmentation maps) to enhance both realism and compositionality of the generated images. An intuitive and novel balancer is proposed to dynamically balance the strengths of the two models in denoising process, allowing plug-and-play use of any model without extra training. Extensive experiments show that our RealCompo consistently outperforms state-of-the-art text-to-image models and spatial-aware image diffusion models in multiple-object compositional generation while keeping satisfactory realism and compositionality of the generated images. Notably, our RealCompo can be seamlessly extended with a wide range of spatial-aware image diffusion models and stylized diffusion models. Our code is available at: https://github.com/YangLing0818/RealCompo","url_abs":"https://arxiv.org/abs/2402.12908v3","url_pdf":"https://arxiv.org/pdf/2402.12908v3.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":"realcompo-dynamic-equilibrium-between-realism","repo_url":"https://github.com/yangling0818/realcompo","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"realcompo-dynamic-equilibrium-between-realism","repo_url":"https://github.com/mlpc-ucsd/TokenCompose","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"denoising","task_name":"Denoising"},{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"text-to-image-generation-1","task_name":"Text to Image Generation"},{"task_slug":"text-to-image-generation","task_name":"Text-to-Image Generation"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2402.12908","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.12908"}},"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/mlpc-ucsd/TokenCompose","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/yangling0818/realcompo","reach":{"status":"ok"}}],"summary":{"ran_fixture":1,"ran":6,"ran_draft_wrong":1,"unverified":3},"by_repo_kind":{"official":{"samples":10,"ran":8,"repositories":1},"listed":{"samples":1,"ran":0,"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":10,"samples":[{"code_sha256_prefix":"b3e1f7172e4955ae","entry":"alpha_generator","repo":"YangLing0818/RealCompo","repo_kind":"official","path":"inference_layout.py","file_url":"https://github.com/YangLing0818/RealCompo/blob/HEAD/inference_layout.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b3e1f7172e4955ae"}},{"code_sha256_prefix":"a042902caede448b","entry":"diffusion_step","repo":"yangling0818/realcompo","repo_kind":"official","path":"keypoint_model/attention.py","file_url":"https://github.com/yangling0818/realcompo/blob/HEAD/keypoint_model/attention.py","link_basis":"harvester_set","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":"a042902caede448b"}},{"code_sha256_prefix":"19a9b6b29f7e63dc","entry":"get_img","repo":"yangling0818/realcompo","repo_kind":"official","path":"utils/loss_function.py","file_url":"https://github.com/yangling0818/realcompo/blob/HEAD/utils/loss_function.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":"19a9b6b29f7e63dc"}},{"code_sha256_prefix":"3fdd69d43a21557a","entry":"get_img2","repo":"yangling0818/realcompo","repo_kind":"official","path":"utils/loss_function.py","file_url":"https://github.com/yangling0818/realcompo/blob/HEAD/utils/loss_function.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":"3fdd69d43a21557a"}},{"code_sha256_prefix":"5fb5a9556099674c","entry":"get_loss","repo":"yangling0818/realcompo","repo_kind":"official","path":"utils/loss_function.py","file_url":"https://github.com/yangling0818/realcompo/blob/HEAD/utils/loss_function.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":"5fb5a9556099674c"}},{"code_sha256_prefix":"e3c3bb87bbe9b4a7","entry":"latent2image","repo":"yangling0818/realcompo","repo_kind":"official","path":"keypoint_model/attention.py","file_url":"https://github.com/yangling0818/realcompo/blob/HEAD/keypoint_model/attention.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e3c3bb87bbe9b4a7"}},{"code_sha256_prefix":"fa11e1f8bcafb6d1","entry":"text_under_image","repo":"yangling0818/realcompo","repo_kind":"official","path":"keypoint_model/attention.py","file_url":"https://github.com/yangling0818/realcompo/blob/HEAD/keypoint_model/attention.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":"fa11e1f8bcafb6d1"}},{"code_sha256_prefix":"b58e6fa98d3a254a","entry":"update_template","repo":"yangling0818/realcompo","repo_kind":"official","path":"get_layout.py","file_url":"https://github.com/yangling0818/realcompo/blob/HEAD/get_layout.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":"b58e6fa98d3a254a"}},{"code_sha256_prefix":"6e5276dc429a7d87","entry":"batch_to_device","repo":"YangLing0818/RealCompo","repo_kind":"official","path":"inference_layout.py","file_url":"https://github.com/YangLing0818/RealCompo/blob/HEAD/inference_layout.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6e5276dc429a7d87"}},{"code_sha256_prefix":"0905b0289949b392","entry":"get_layout","repo":"yangling0818/realcompo","repo_kind":"official","path":"get_layout.py","file_url":"https://github.com/yangling0818/realcompo/blob/HEAD/get_layout.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0905b0289949b392"}},{"code_sha256_prefix":"858ea4d2ddf8fcae","entry":"register_attention_control","repo":"mlpc-ucsd/TokenCompose","repo_kind":"listed","path":"train/src/attn_utils.py","file_url":"https://github.com/mlpc-ucsd/TokenCompose/blob/HEAD/train/src/attn_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":"858ea4d2ddf8fcae"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}