鴉神 KARASUKAMI

クリエイターのためのAIニュース

2D

Code as Pixels: a coding agent writes Python to fix images mid-denoising, frozen FLUX renders the rest

Code as Pixels is a research project in which a coding agent looks at an image while it is still being generated, repaints the pixels directly with Python, and then lets an unmodified, frozen image model finish the render. It needs no extra training and works with FLUX.1-dev, Qwen-Image and LongCat-Image, and the team reports that it beats Nano-Banana on an image-editing benchmark. The code is on GitHub under the MIT license, and the announcement post passed 70K views and 900 bookmarks.

Thumbnail of the Code as Pixels announcement video: coding agent on the left, FLUX.1-dev in the middle and benchmark results on the right

Pause mid-generation, fix it in code, then let the model continue

Code as Pixels does not change the image model at all. It splits the work in two: a coding agent rewrites pixels in Python to decide content and layout, and a frozen, pretrained flow model denoises the edited area into realistic detail. Supported models are FLUX.1-dev, Qwen-Image and LongCat-Image.

For text-to-image, it first runs one normal generation and pulls out the predicted final image at steps 15, 25, 34 and 42. If it spots a problem such as a wrong count, odd layout, or wrong color or object, the agent writes a Python function called edit_image(img) to fix the pixels and sends only that region back to a middle step to be re-rendered. It retries up to two times.

In the announcement video, with the prompt "four sheeps and a trumpet," one extra sheep is removed with code and the image keeps rendering into a natural photo.

For editing, it chooses how much of the original to keep, per edit

Editing does not use a model fine-tuned for editing. The agent looks at the source image and the instruction, picks a mask for what to change, such as only the person, only the background or the area around the head, and can sketch a draft with PIL or OpenCV. The frozen model then blends the draft in so it looks like a natural photo. The video shows a bear-shaped lamp being turned into glass.

How much of the original photo to keep is set by a value λ between 0 and 1, chosen by the agent for each edit. At 0 it redraws shapes and materials from the prompt alone; closer to 1 it keeps the source's fine texture. For edits that would blur if passed through the model, like text and charts, there is a mode that outputs the code-drawn pixels as they are. Results are reviewed up to three times, deciding whether to accept, tune the value or rewrite the code.

Benchmarks, and a studio you can run yourself

In the team's published results, compared with FLUX.1-dev alone, GenEval rises from 67.79 to 80.87, GenEval 2 from 22.72 to 68.05 and WISE from 44.90 to 74.50. On the GEditBench v2 arena Elo for editing (average of 1,000), the LongCat-Image version scores 1095.0, above Nano-Banana's 1090.1, with the Qwen-Image version at 1079.7 and the FLUX.1-dev version at 1076.7.

The code is public on GitHub under the MIT license, the dataset is on Hugging Face, and the paper is listed as coming soon. The included "code-as-pixels studio" is an interactive tool that shows generation and editing branches as a tree and lets you rewrite the prompt or the Python code at any step to fork a new branch. It has a demo mode that runs without a GPU, and results can be exported as HTML you can view offline.

Original post on X

Related stories

Thumbnail of @Kongkong's demo: the title "Nemotron-Labs-VisualCreation" over generated examples such as a bedroom ad, posters, an infographic and chartsNVIDIA releases its first Nemotron image model: VisualCreation treats pixels like code for images and slides alike2D Frame from the FLUX 3.1 Image launch video: a mountain and river landscape with "MADE WITH FLUX 3.1" over itFLUX 3.1 Image from Black Forest Labs generates and edits in about 3 seconds, with mask edits and up to 10 references2D Image from @dextune's post: the beanfx logo, the headline "Pixel-art VFX, from words to sprites.", a pixel-art character firing purple lightning from a sword, and six sprite frames of itType "a fire burst, 64x64, side view" and get a pixel-art effect back: beanfx, a Claude Code pluginGames Thumbnail of @dwhitedesign's demo video (scattered pixel art pieces)Four pixel art views in, a spinnable fake-3D sprite out: the sprite-stacking agent skill is out under MITGames Thumbnail of @lnkiai's video (a cat-eared character being modeled in Cubism Editor)lnkiai's VTuber kit agent now drives Live2D Cubism Editor itself, modeling face XY in about 2 hours2D The two-page spread from Kuusou Ken'iki 01, with the title Imaginal Domain and a braided girl looking up at a wallKuusou Ken'iki 01, a black-and-white AI manga one-shot, with its Claude Code × Krea2 × P-H3 × Clip Studio workflowComics

KARASUKAMI home · 日本語版

AD広告サンプル

ひらめきを、
次の作品へ。

AIとつくる、新しいクリエイティブ。

広告掲載スペースPROTOTYPE

新着記事