Fine-Grained Visual Attribution for Image-to-Code Generation and Editing
Reinforcement learning for image-to-code generation typically rewards the overall visual similarity between rendered outputs and reference images. However, methods such as GRPO assign the same advantage to every token in a program, giving code that draws an element correctly the same learning signal as code that draws it incorrectly. To address this, we introduce render attribution, which traces rendered elements back to their source code, enabling fine-grained visual feedback. During training, we decompose the reference and rendered images into individual elements, match them one-to-one based on geometric similarity, and assign element-specific advantages to the responsible code tokens, even across shared definitions. Across five benchmarks (VFIG-Bench, VFIG-OOD, SVG-Bench Emoji, DaTikZ-v3, and Design2Code) spanning SVG, TikZ, and HTML with three different starting models, our method outperforms GRPO (e.g., 23% lower LPIPS on VFIG-Bench), improving all 28 benchmark–metric comparisons with at most 1.3% additional training-step time. With an additional code-aware reward and corresponding credit assignment, it also better preserves code structure and improves editability. As an agent tool, render attribution improves LPIPS by 17% at the same turn budget even for a frontier agent (Claude Sonnet 5.5), and lets an open 27B agent surpass its 16-turn result in four turns with 84% fewer tokens. By linking rendered elements to their code, render attribution turns visual feedback into precise guidance for learning and editing.
Which code drew each pixel, and how well does it match the reference? Hover over the images to see.
Given a reference image, a model generates a program (SVG, TikZ or HTML). A drawing unit is code that draws a visual object, such as a box, arrow or text, and the pixels it draws form an element. Render attribution finds which code drew each element and scores how well each reference element is reproduced. The appendix of the paper gives the full details.
Each drawing unit is rendered in a unique color, so the id render names the code line behind every pixel.
Rendered elements are matched one to one to reference elements by Chamfer distance.
Each reference element gets a score
GRPO gives one advantage per sample. RA-GRPO mixes it half and half with the element’s score, standardized over the samples, and gives the result to that element’s code.
GRPO gives one score to a whole program. RA-GRPO gives each line the credit of what it draws.
23% lower LPIPS than GRPO on VFIG-Bench, with the same reward
One program sampled for a real figure. Hover a line or an element to compare the two credits.
Element credit only sees pixels. Structure credit also rewards code that is easy to edit.
53% groups kept 4080% containment kept 5670% agent edits succeed 55
Gray: GRPO with the same reward.

Four programs render the same image. Follow the four steps, or drag a box.
<g> in the codethe line the edit changesThe same attribution tells a coding agent which line to fix, and to what value.
84% fewer tokens for Qwen3.8-27B17% better LPIPS for Claude Sonnet 5.5

Two real 16-turn runs of Claude Code on the same draft, replayed from their logs. Drag the slider or press play.
Test images from the five benchmarks of the main tables, each next to the program RA-GRPO wrote for it, rendered. Click a pair to compare all models at full size.
@article{wang2026whodrew,
title = {Who Drew That Pixel? Fine-Grained Visual Attribution for Image-to-Code Generation and Editing},
author = {Hexuan Wang and Zixian Ma and Ranjay Krishna and Jaemin Cho},
journal = {arXiv preprint arXiv:TBD.00000},
year = {2026}
}