{"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/cross-modal-contrastive-learning-for-text-to","title":"Cross-Modal Contrastive Learning for Text-to-Image Generation","arxiv_id":"2101.04702","date":"2021-01-12","proceeding":"CVPR 2021 1","authors":["Han Zhang","Jing Yu Koh","Jason Baldridge","Honglak Lee","Yinfei Yang"],"abstract":"The output of text-to-image synthesis systems should be coherent, clear, photo-realistic scenes with high semantic fidelity to their conditioned text descriptions. Our Cross-Modal Contrastive Generative Adversarial Network (XMC-GAN) addresses this challenge by maximizing the mutual information between image and text. It does this via multiple contrastive losses which capture inter-modality and intra-modality correspondences. XMC-GAN uses an attentional self-modulation generator, which enforces strong text-image correspondence, and a contrastive discriminator, which acts as a critic as well as a feature encoder for contrastive learning. The quality of XMC-GAN's output is a major step up from previous models, as we show on three challenging datasets. On MS-COCO, not only does XMC-GAN improve state-of-the-art FID from 24.70 to 9.33, but--more importantly--people prefer XMC-GAN by 77.3 for image quality and 74.1 for image-text alignment, compared to three other recent models. XMC-GAN also generalizes to the challenging Localized Narratives dataset (which has longer, more detailed descriptions), improving state-of-the-art FID from 48.70 to 14.12. Lastly, we train and evaluate XMC-GAN on the challenging Open Images data, establishing a strong benchmark FID score of 26.91.","url_abs":"https://arxiv.org/abs/2101.04702v5","url_pdf":"https://arxiv.org/pdf/2101.04702v5.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":"cross-modal-contrastive-learning-for-text-to","repo_url":"https://github.com/google-research/xmcgan_image_generation","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"jax","reach":null}],"tasks":[{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":null,"task_name":"Generative Adversarial Network"},{"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":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/text-to-image-generation-on-coco","task":"Text-to-Image Generation","dataset":"COCO (Common Objects in Context)","model":"XMC-GAN","rank_in_archive_order":25,"of":69,"metrics":{"FID":"9.33"},"uses_additional_data":true}],"syntology":{"syntology_url":"https://syntology.ai/paper/2101.04702","atlas_url":"https://app.syntology.ai/?focus=2101.04702","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2101.04702"}},"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/google-research/xmcgan_image_generation","reach":null}],"summary":{"ran_fixture":1,"ran_honours":1,"ran_draft_wrong":2},"by_repo_kind":{"official":{"samples":4,"ran":4,"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":4,"samples":[{"code_sha256_prefix":"ba3acab33b57ea69","entry":"contrastive_loss","repo":"google-research/xmcgan_image_generation","repo_kind":"official","path":"xmcgan/libml/attention_lib.py","file_url":"https://github.com/google-research/xmcgan_image_generation/blob/HEAD/xmcgan/libml/attention_lib.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ba3acab33b57ea69"}},{"code_sha256_prefix":"e3232048125b7baa","entry":"get_statistics","repo":"google-research/xmcgan_image_generation","repo_kind":"official","path":"xmcgan/libml/attention_lib.py","file_url":"https://github.com/google-research/xmcgan_image_generation/blob/HEAD/xmcgan/libml/attention_lib.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e3232048125b7baa"}},{"code_sha256_prefix":"6355c1dcf1ced438","entry":"l2_normalize","repo":"google-research/xmcgan_image_generation","repo_kind":"official","path":"xmcgan/libml/attention_lib.py","file_url":"https://github.com/google-research/xmcgan_image_generation/blob/HEAD/xmcgan/libml/attention_lib.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":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6355c1dcf1ced438"}},{"code_sha256_prefix":"b9291a0c061e7a3e","entry":"tf_cross_entropy_loss_with_logits","repo":"google-research/xmcgan_image_generation","repo_kind":"official","path":"xmcgan/libml/attention_lib.py","file_url":"https://github.com/google-research/xmcgan_image_generation/blob/HEAD/xmcgan/libml/attention_lib.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":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b9291a0c061e7a3e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}