Frontier models can generate very nice images from code.
@LiangZheng_061.4K followers
14,096 views
22 Comments
Comments from the original post on X (Twitter)

@LiangZheng_06
Why code? Three reasons. 1. Deterministic rendering: better code means a better image. 2. Interpretable: every image comes from a program you can read and edit. 3. Scales with coding ability: a better coding model is a better image generator. 2/n
7 likes

@LiangZheng_06
We evaluate 14 LLMs on five benchmarks: GenEval2, PRSIM, GenOlypiad, Wise, and DPG-bench. LLMs are stronger than diffusion image models on tasks requiring strong reasoning. Full leaderboard: 3/n
4 likes

@LiangZheng_06
We develop an SFT+RL baseline for Qwen post-training. - We use a mixture of GPT models as teachers and SFT the Qwen model. - We use a set of prompts for GRPO. We use the rendered image for computing the reward with a GPT judge. 4/n
5 likes

@LiangZheng_06
drawback of image-only reward: visual misjudgement. drawback of code-only reward: can't see. image+code reward trains the best model. Our final recipe: Qwen-27B + SFT + GRPO with image+code reward. 5/n
5 likes

@LiangZheng_06
Paper: GitHub: Hugging Face: Project page: Amazing work by @nicolewangr @xingjian_leng @zinho_leung 6/n
12 likes

@WilcoKr
3d models next?
1 like

@LiangZheng_06
well, yeah, 3d and videos would be interesting.
1 like

@MixtTensi8198
This is amazing! Thank you for the github also! :)
1 like

@EternitiesAI
writing code that renders the image makes the output easy to inspect.
1 like

@LiangZheng_06
yeah, verification becomes easier by inspecting the code. but there can also be errors, e.g., an object in the code may be occluded in the rendered image. so perhaps using both image and code for reward modeling.

@kevin_t_ngo
very cool! all of the art on my personal website were made with code
1 like

@LiangZheng_06
retire diffusion models?

@reachmeviz
Great experiment, though I wonder why train the model specifically to generate code that renders as a static image? Why not train it to generate native HTML/Canvas components directly? That could make it easier to build Claude Opus–style motion graphics too.

@FeatherlessAI
This looks very cool. Has python code performance been tested as well? For example, python is very useful to create scenes in blender for 3d image generation.

@LiangZheng_06
we only did JS code. it's absolutely interesting to think about python and blender for 3d gen!

@XDanielDev
did you guys try a final t2i? also how does it do with reflections, I have this prompt: A scrambled 3x3 Rubik's cube placed beside a mirror, clearly showing its mirror reflection. Beside the cube is a wine glass filled to the brim, and a clock shows the hands placed at 5 and 8.

@LiangZheng_06
this can be added to GenOlympiad prompt base😅 - looks pretty challenging. will see the results later

@XDanielDev
Yeah, I believe the only one that kinda solve it is nano banana pro, maybe 2.1 with thinking? GPT always messes up the reflected cube stickers

@LiangZheng_06
i think Astra and Fable might do a better job. we tested such hard prompts on GenOlympiad - LLMs are generally better than diffusion.

@XDanielDev
It’s unfortunate, it would be nice to have precision like this locally. SN-U1.6 would be nice with the code planning. What’s really needed is also the agentic self correction, maybe not so much however if starting from code-generated images
1 like
