Code as Pixels gives a Python-writing agent a chance to correct an AI image before it’s finished. Researcher Hongyang Du announced the project on December 3; the team says the agent can edit pixels during generation, then hand the revised region back to an image model for realistic detail. An unwanted extra sheep needn’t get to stay just because it rendered nicely. Source Source Source
The researchers describe the method as training-free, working alongside models including FLUX.1-dev, Qwen-Image and LongCat-Image. Those image models stay frozen: the method doesn’t require additional training of their weights. Source Source
Correct the pixels, then resume rendering
For text-to-image generation, the agent inspects a preview and writes Python to change the pixels. The edited region is then encoded back into the model’s internal image representation and rewound to an earlier point in denoising, the step-by-step process of turning noise into an image. The model resumes from there with the correction in place. In the project page’s sheep-counting example, the agent edits a preview from step 34 and the image model resumes at step 30 after an extra sheep is removed. Source
Photo editing takes a different route. The agent edits the source image directly, then the selected region gets encoded and given noise before the frozen model renders it into a more realistic result. The page describes changing a bear lamp’s material to glass. Python supplies the material-change draft; the image model gets the job of making it look convincing. Source
The agent can also choose an edit-strength setting that trades freedom to change the picture against fidelity to the source. More preservation means less room for a substantial alteration. And prompts haven’t been fired: the project’s sampler still uses source and target text prompts alongside the code-based intervention. Source
The benchmark wins come with column headings
On GenEval 2, the team reports FLUX.1-dev rising from 22.72 alone to 68.05 with Code as Pixels. Qwen-Image rises from 41.18 to 77.98 on the same test. Source
For image editing, the authors’ table puts Code as Pixels with LongCat-Image at 1095.0 Elo on GEditBench v2, compared with Nano-Banana’s 1090.1. The page provides no confidence intervals or significance tests for that 4.9-point gap. Source
In the same table, Qwen-Image-Edit scores 7.100 overall on GEdit-Bench v1, ahead of the LongCat-Image version of Code as Pixels at 6.892. Adding the method to Qwen-Image nudges its text-to-image DPG-Bench score downward, from 88.99 to 88.86. Source
Code as Pixels Studio lets users branch from an edit without losing earlier results, according to co-author Cheng Wan’s announcement. The project page describes inspecting branches and their Python code. Source Source
The project page provides no cost-per-image or latency measurements for the workflow. Source
Comments