{"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/anytext2-visual-text-generation-and-editing","title":"AnyText2: Visual Text Generation and Editing With Customizable Attributes","arxiv_id":"2411.15245","date":"2024-11-22","proceeding":null,"authors":["Yuxiang Tuo","Yifeng Geng","Liefeng Bo"],"abstract":"As the text-to-image (T2I) domain progresses, generating text that seamlessly integrates with visual content has garnered significant attention. However, even with accurate text generation, the inability to control font and color can greatly limit certain applications, and this issue remains insufficiently addressed. This paper introduces AnyText2, a novel method that enables precise control over multilingual text attributes in natural scene image generation and editing. Our approach consists of two main components. First, we propose a WriteNet+AttnX architecture that injects text rendering capabilities into a pre-trained T2I model. Compared to its predecessor, AnyText, our new approach not only enhances image realism but also achieves a 19.8% increase in inference speed. Second, we explore techniques for extracting fonts and colors from scene images and develop a Text Embedding Module that encodes these text attributes separately as conditions. As an extension of AnyText, this method allows for customization of attributes for each line of text, leading to improvements of 3.3% and 9.3% in text accuracy for Chinese and English, respectively. Through comprehensive experiments, we demonstrate the state-of-the-art performance of our method. The code and model will be made open-source in https://github.com/tyxsspa/AnyText2.","url_abs":"https://arxiv.org/abs/2411.15245v1","url_pdf":"https://arxiv.org/pdf/2411.15245v1.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":"anytext2-visual-text-generation-and-editing","repo_url":"https://github.com/tyxsspa/anytext2","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2411.15245","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2411.15245"}},"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/tyxsspa/anytext2","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran_draft_wrong":2,"unverified":19},"by_repo_kind":{"official":{"samples":21,"ran":2,"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":"1923fc05163d207d","entry":"convert_to_unicode","repo":"tyxsspa/anytext2","repo_kind":"official","path":"bert_tokenizer.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/bert_tokenizer.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"1923fc05163d207d"}},{"code_sha256_prefix":"0dbf855dab1ab575","entry":"get_node_name","repo":"tyxsspa/anytext2","repo_kind":"official","path":"tool_add_anytext.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/tool_add_anytext.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0dbf855dab1ab575"}},{"code_sha256_prefix":"13d5598dd3d88751","entry":"arr2tensor","repo":"tyxsspa/anytext2","repo_kind":"official","path":"eval/anytext2_singleGPU.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/eval/anytext2_singleGPU.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":"13d5598dd3d88751"}},{"code_sha256_prefix":"e84251d6127e8b2b","entry":"check_channels","repo":"tyxsspa/anytext2","repo_kind":"official","path":"util.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/util.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":"e84251d6127e8b2b"}},{"code_sha256_prefix":"8f01a9b25bacd3fa","entry":"copy_and_rename_dict_keys","repo":"tyxsspa/anytext2","repo_kind":"official","path":"t3_dataset.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/t3_dataset.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":"8f01a9b25bacd3fa"}},{"code_sha256_prefix":"62e380ad4669ac47","entry":"draw_pos","repo":"tyxsspa/anytext2","repo_kind":"official","path":"eval/anytext2_singleGPU.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/eval/anytext2_singleGPU.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":"62e380ad4669ac47"}},{"code_sha256_prefix":"695f6baa162444b5","entry":"extract_all_images","repo":"tyxsspa/anytext2","repo_kind":"official","path":"eval/clipscore.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/eval/clipscore.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":"695f6baa162444b5"}},{"code_sha256_prefix":"cfc17707f35e7ec4","entry":"get_state_dict","repo":"tyxsspa/anytext2","repo_kind":"official","path":"cldm/model.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/cldm/model.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":"cfc17707f35e7ec4"}},{"code_sha256_prefix":"75c1cd45779a2497","entry":"load","repo":"tyxsspa/anytext2","repo_kind":"official","path":"eval/anytext2_multiGPUs.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/eval/anytext2_multiGPUs.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":"75c1cd45779a2497"}},{"code_sha256_prefix":"5958926c73426c86","entry":"load_json","repo":"tyxsspa/anytext2","repo_kind":"official","path":"eval/anytext2_multiGPUs.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/eval/anytext2_multiGPUs.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":"5958926c73426c86"}},{"code_sha256_prefix":"df733a879693145d","entry":"load_state_dict","repo":"tyxsspa/anytext2","repo_kind":"official","path":"cldm/model.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/cldm/model.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":"df733a879693145d"}},{"code_sha256_prefix":"c986b2b9b07493a4","entry":"load_txt","repo":"tyxsspa/anytext2","repo_kind":"official","path":"dataset_util.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/dataset_util.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":"c986b2b9b07493a4"}},{"code_sha256_prefix":"aaf1cb2c01043065","entry":"load_vocab","repo":"tyxsspa/anytext2","repo_kind":"official","path":"bert_tokenizer.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/bert_tokenizer.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":"aaf1cb2c01043065"}},{"code_sha256_prefix":"0e5615f8994003cf","entry":"printable_text","repo":"tyxsspa/anytext2","repo_kind":"official","path":"bert_tokenizer.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/bert_tokenizer.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":"0e5615f8994003cf"}},{"code_sha256_prefix":"68f27900e9bca55d","entry":"random_rotate","repo":"tyxsspa/anytext2","repo_kind":"official","path":"t3_dataset.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/t3_dataset.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":"68f27900e9bca55d"}},{"code_sha256_prefix":"399a269e327cf154","entry":"renew_attention_paths","repo":"tyxsspa/anytext2","repo_kind":"official","path":"lora_util.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/lora_util.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":"399a269e327cf154"}},{"code_sha256_prefix":"dfb052a0af48540f","entry":"renew_resnet_paths","repo":"tyxsspa/anytext2","repo_kind":"official","path":"lora_util.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/lora_util.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":"dfb052a0af48540f"}},{"code_sha256_prefix":"a91c692ff279a01a","entry":"resize_image","repo":"tyxsspa/anytext2","repo_kind":"official","path":"util.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/util.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":"a91c692ff279a01a"}},{"code_sha256_prefix":"8f474e60fb5e395f","entry":"save","repo":"tyxsspa/anytext2","repo_kind":"official","path":"eval/anytext2_multiGPUs.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/eval/anytext2_multiGPUs.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":"8f474e60fb5e395f"}},{"code_sha256_prefix":"d1b4375d285cdec5","entry":"save_images","repo":"tyxsspa/anytext2","repo_kind":"official","path":"util.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/util.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":"d1b4375d285cdec5"}},{"code_sha256_prefix":"cea0bc82e0c96896","entry":"shave_segments","repo":"tyxsspa/anytext2","repo_kind":"official","path":"lora_util.py","file_url":"https://github.com/tyxsspa/anytext2/blob/HEAD/lora_util.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":"cea0bc82e0c96896"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}