Find your next open-source project

Search by name, purpose, or keyword, or paste a GitHub URL. Start with / to search agent skills (e.g. /pdf)

Hongyang-Du/code_as_pixels

Machine Learning

A zero-training framework that lets a coding agent write Python to control frozen flow-matching image models for generation and editing.

104
7
Python
MIT
3 days old
+6 stars in 10h

What it does

Code as Pixels is the reference implementation of a closed-loop control framework for frozen flow-matching diffusion backbones — FLUX.1-dev, Qwen-Image and LongCat-Image — covering both text-to-image generation and instruction-guided image editing. No backbone fine-tuning is involved: a vision-language model inspects intermediate results, writes sandboxed Python (with edit_image(img) and OpenCV/PIL helpers), and the framework re-enters or renders the latent trajectory accordingly code-as-pixels README.

For text-to-image, the default filmstrip strategy runs one Euler ODE pass, writes previews along the trajectory, and rewinds via masked latent re-entry when a defect is spotted. For editing, a four-knob renderer offers three modes — flowedit_fresh, unified_lambda, and code_only — over up to three review rounds.

Quick start

Requirements: Python 3.10+, an NVIDIA GPU with CUDA PyTorch, a Hugging Face token for the gated FLUX.1-dev weights, and an OpenAI API key (or an authenticated local Codex CLI) as the VLM backend.

git clone https://github.com/Hongyang-Du/code_as_pixels.git
cd code_as_pixels
uv venv -p 3.11 .venv
source .venv/bin/activate
uv pip install -e .
code-as-pixels check

A zero-GPU demo of the Studio UI needs no models or keys:

code-as-pixels studio --demo --port 7860

For a real generation run, export HF_TOKEN and OPENAI_API_KEY, optionally pre-download weights with code-as-pixels download-models flux qwen longcat, then:

code-as-pixels t2i \
  --prompt "Three red apples to the left of a blue ceramic mug on a wooden table" \
  --backbone qwen \
  --strategy filmstrip \
  --vlm-backend openai \
  --out outputs/t2i_demo

Results, trajectories and cached latents land in --out. A Python API (run_t2i_single, run_ti2i_single) and a ti2i command for instruction editing are also documented code-as-pixels README.

Hardware and cost constraints

VRAM requirements are substantial: roughly 32 GB for FLUX.1-dev and LongCat-Image, 48–80 GB for Qwen-Image, with component-level auto-swapping on smaller GPUs. FLUX.1-dev is gated behind a Hugging Face token. The OpenAI backend counts token spend against an explicit USD budget guard (--budget), and the Codex backend requires an authenticated local CLI. Generated Python runs in an AST-validated subprocess sandbox, but network-capable VLM backends still represent a real external dependency. The repository is MIT-licensed; the pretrained backbones and evaluation benchmarks keep their own licenses.

Benchmarks

The README reports T2I results on eight benchmarks and TI2I results on four, comparing base versus Code-as-Pixels variants and closed references. These are the authors' reported numbers on their own evaluation setup; independent verification is not provided here. Pre-downloaded evaluation manifests are built with code-as-pixels prepare-benchmarks.

HotRepo's take

HotRepo recorded the project on the Python new-project list on 2026-12-04, when it held 104 stars after gaining 4 within roughly 90 minutes of sampling; it has no all-language daily rank on record. The star curve over that short window (100 → 102 → 104) shows only steady early traction, which is too brief to say anything about broader adoption. Technically, the notable point is the zero-fine-tuning angle: the framework keeps the diffusion backbone frozen and pushes iteration into agent-generated code and latent re-entry, which makes benchmark claims dependent on the VLM backend quality — worth reading before judging results as backbone improvements.

Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.

You might also like

  1. inclusionAI/IDMResearch code and inference toolkit for one- or two-step text-to-image generation via intrinsic distribution matching.Python161
  2. MiniMax-AI/MiniMax-H3-ImageOpen-weights 16-megapixel image generation and editing model with a 33.1B DiT and 6-step sampling.117
  3. OpenMOSS/MOSS-ImageAn open 5B diffusion transformer for text-to-image that keeps text legible and lets you control element placement.Python1,752
  4. tarqmamdouh/agent-theaterA live pixel-art stage that visualizes Claude Code workflow runs, agent roles, and phase handoffs on your own machine.JavaScript132
  5. rubenhassid1/remakeCapture a public website, rebuild a pixel-matched copy with Claude Code, then swap in your own content.JavaScript102