Spaces:
Running

File size: 3,036 Bytes
1e87862
 
b0d51aa
 
 
1e87862
 
 
 
b0d51aa
 
 
 
 
 
 
 
 
 
 
 
9de6e55
b0d51aa
 
 
 
 
cff63d5
b0d51aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1e9ecc7
 
 
 
 
 
 
b0d51aa
17f0fb6
b0d51aa
 
 
 
 
 
1e9ecc7
b0d51aa
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: README
emoji: 🖼️
colorFrom: green
colorTo: gray
sdk: static
pinned: false
---

<h1 align="center">Code-based Image Generation: Benchmarking, Baselines, and Improved Rewards</h1>

<p align="center">
  Nicole&nbsp;Wang &ensp;<b>&middot;</b>&ensp;
  Zhanhao&nbsp;Liang &ensp;<b>&middot;</b>&ensp;
  <a href="https://scholar.google.com.au/citations?user=GQzvqS4AAAAJ" target="_blank">Xingjian&nbsp;Leng</a> &ensp;<b>&middot;</b>&ensp;
  <a href="https://zheng-lab-anu.github.io/" target="_blank">Liang&nbsp;Zheng</a>
</p>

<p align="center">Australian National University</p>

<p align="center">
  🌐 <a href="https://codeimagegen.github.io" target="_blank">Project Page</a> &ensp;
  💻 Code (coming soon) &ensp;
  📃 Paper (coming soon)
</p>

<p align="center">
  <img src="https://huggingface.co/spaces/CodeImageGen/README/resolve/main/assets/teaser.png" width="75%" alt="Images generated by our model. Every image is a program.">
</p>

---

Every image above is a program. In **code-based image generation**, a language model writes a JavaScript program
and a fixed renderer turns it into an image, so every image can be read, edited and redrawn at any resolution.

We post-train Qwen3.8-27B for it with SFT from a mix of GPT teachers, then GRPO. A judge shown both the program and
the rendered image (**IPR**) is a better reward than either alone: **+18.0** GenEval2 GM over the base model,
against +15.5 for the program alone and +14.3 for the image alone.

## Models

| model | base | training | reward |
|---|---|---|---|
| [Pictor-27B](https://huggingface.co/CodeImageGen/Pictor-27B) (released model) | Qwen3.8-27B | SFT + GRPO | image + program |
| [Pictor-27B-ablation-IR](https://huggingface.co/CodeImageGen/Pictor-27B-ablation-IR) | Qwen3.8-27B | SFT + GRPO | image |
| [Pictor-27B-ablation-PR](https://huggingface.co/CodeImageGen/Pictor-27B-ablation-PR) | Qwen3.8-27B | SFT + GRPO | program |
| [Pictor-27B-ablation-avgR](https://huggingface.co/CodeImageGen/Pictor-27B-ablation-avgR) | Qwen3.8-27B | SFT + GRPO | mean of image and program |
| [Pictor-27B-SFT](https://huggingface.co/CodeImageGen/Pictor-27B-SFT) | Qwen3.8-27B | SFT | |
| [Pictor-9B](https://huggingface.co/CodeImageGen/Pictor-9B) | Qwen3.5-9B | SFT + GRPO | image + program |
| [Pictor-9B-SFT](https://huggingface.co/CodeImageGen/Pictor-9B-SFT) | Qwen3.5-9B | SFT | |

Dataset: [Pictor-SFT-35k](https://huggingface.co/datasets/CodeImageGen/Pictor-SFT-35k), 35k prompt and program pairs.

## Usage and training

The code for setup, generating images, training and evaluation is coming soon on GitHub. One prompt to one image:

```
python -m grpo.t2i.eval.generate_one --model CodeImageGen/Pictor-27B --prompt "a red fox in the snow" --out fox.png
```

## 📚 Citation

```bibtex
@article{wang2026codeimagegen,
  title   = {Code-based Image Generation: Benchmarking, Baselines, and Improved Rewards},
  author  = {Wang, Nicole and Liang, Zhanhao and Leng, Xingjian and Zheng, Liang},
  journal = {arXiv preprint},
  year    = {2026}
}
```