CoCo: Code as CoT for Text-to-Image Preview and Rare Concept Generation
Recent advancements in Unified Multimodal Models (UMMs) have significantly advanced text-to-image (T2I) generation, particularly through the integration of Chain-of-Thought (CoT) reasoning. However, existing CoT-based T2I methods largely rely on abstract natural-language planning, which lacks the precision required for complex spatial layouts, structured visual elements, and dense textual content. In this work, we propose CoCo (Code-as-CoT), a code-driven reasoning framework that represents the reasoning process as executable code, enabling explicit and verifiable intermediate planning for image generation. Given a text prompt, CoCo first generates executable code that specifies the structural layout of the scene, which is then executed in a sandboxed environment to render a deterministic draft image. The model subsequently refines this draft through fine-grained image editing to produce the final high-fidelity result. To support this training paradigm, we construct CoCo-10K, a curated dataset containing structured draft-final image pairs designed to teach both structured draft construction and corrective visual refinement. Empirical evaluations on StructT2IBench, OneIG-Bench, and LongText-Bench show that CoCo achieves improvements of +68.83%, +54.8%, and +41.23% over direct generation, while also outperforming other generation methods empowered by CoT. These results demonstrate that executable code is an effective and reliable reasoning paradigm for precise, controllable, and structured text-to-image generation. The code is available at: https://github.com/micky-li-hd/CoCo
69afb97cb3ab31dee1281ec5
Haodong Li
claimed_verified
2026-03-10T09:44:34.636Z
65ddea8b2d26e59a5a33330f
/avatars/3104ddafd6dda3c05ea9a771dbf2deeb.svg
li haodong
mickyhimself
user
mickyhimself
69afb97cb3ab31dee1281ec6
Chunmei Qing
69afb97cb3ab31dee1281ec7
Huanyu Zhang
69afb97cb3ab31dee1281ec8
Dongzhi Jiang
claimed_verified
2026-03-16T10:44:20.275Z
6349214f8146350b3a4c5cdf
/avatars/cfd24caac9a87efb528d0f4c375932bc.svg
Dongzhi Jiang
CaraJ
user
CaraJ
69afb97cb3ab31dee1281ec9
Yihang Zou
69afb97cb3ab31dee1281eca
Hongbo Peng
claimed_verified
2026-03-10T09:44:25.188Z
68106c88b924dd6c328889c2
/avatars/8accf835b711bffa2ea307158950ab33.svg
Hongbo Peng
M1chaelPeng
user
M1chaelPeng
69afb97cb3ab31dee1281ecb
Dingming Li
69afb97cb3ab31dee1281ecc
Yuhong Dai
claimed_verified
2026-03-11T16:31:47.778Z
65d70e775e971572da16c05b
https://cdn-avatars.huggingface.co/v1/production/uploads/65d70e775e971572da16c05b/8Cv71Clfk_C7k6U4yI6ln.jpeg
Yuhong Dai
BroAlanTaps
user
BroAlanTaps
69afb97cb3ab31dee1281ecd
ZePeng Lin
69afb97cb3ab31dee1281ece
Juanxi Tian
claimed_verified
2026-03-10T09:44:27.530Z
670880950e79a8b46f7ff9dd
https://cdn-avatars.huggingface.co/v1/production/uploads/670880950e79a8b46f7ff9dd/hA1TLhwlQblkFsq8wLrkB.jpeg
Juanxi Tian
Juanxi
user
Juanxi
69afb97cb3ab31dee1281ecf
Yi Zhou
69afb97cb3ab31dee1281ed0
Siqi Dai
69afb97cb3ab31dee1281ed1
Jingwei Wu
CoCo: Code as CoT for Text-to-Image Preview and Rare Concept Generation
Recent advancements in Unified Multimodal Models (UMMs) have significantly advanced text-to-image (T2I) generation, particularly through the integration of Chain-of-Thought (CoT) reasoning. However, existing CoT-based T2I methods largely rely on abstract natural-language planning, which lacks the precision required for complex spatial layouts, structured visual elements, and dense textual content. In this work, we propose CoCo (Code-as-CoT), a code-driven reasoning framework that represents the reasoning process as executable code, enabling explicit and verifiable intermediate planning for image generation. Given a text prompt, CoCo first generates executable code that specifies the structural layout of the scene, which is then executed in a sandboxed environment to render a deterministic draft image. The model subsequently refines this draft through fine-grained image editing to produce the final high-fidelity result. To support this training paradigm, we construct CoCo-10K, a curated dataset containing structured draft-final image pairs designed to teach both structured draft construction and corrective visual refinement. Empirical evaluations on StructT2IBench, OneIG-Bench, and LongText-Bench show that CoCo achieves improvements of +68.83%, +54.8%, and +41.23% over direct generation, while also outperforming other generation methods empowered by CoT. These results demonstrate that executable code is an effective and reliable reasoning paradigm for precise, controllable, and structured text-to-image generation. The code is available at: https://github.com/micky-li-hd/CoCo
CoCo is a code-driven framework for text-to-image generation that uses executable code for precise spatial layout planning and structured image creation, achieving superior performance over traditional CoT-based methods.
Unified Multimodal Models Chain-of-Thought reasoning text-to-image generation executable code structured draft construction image editing CoCo-10K dataset StructT2IBench OneIG-Bench LongText-Bench