Who Drew That Pixel?

Fine-Grained Visual Attribution for Image-to-Code Generation and Editing

Hexuan Wang1, Zixian Ma2, Ranjay Krishna2, Jaemin Cho1
1Johns Hopkins University, 2University of Washington

Who drew that pixel? Render attribution traces each rendered pixel back to the code that drew it, so visual feedback reaches the responsible code, as credit in reinforcement learning and as tools for a coding agent. (1) A VLM’s code for a reference image renders with two errors (red dashed boxes): the Encoder box has the wrong color and the Decoder box sits too low. (2) An id render names the code line behind every pixel. (3) In training, each element’s code receives its own credit instead of one score per sample. (4) At inference, tools tell a coding agent which line to edit and to what value. LPIPS ×100 on VFIG-Bench.

Abstract

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.

Render Attribution

Which code drew each pixel, and how well does it match the reference? Hover over the images to see.

How it works

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.

1Id render

Each drawing unit is rendered in a unique color, so the id render names the code line behind every pixel.

2Matching

Rendered elements are matched one to one to reference elements by Chamfer distance.

3Score

Each reference element gets a score s = ½(appearance + geometry). An unmatched element gets geometry 0.

4Credit

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.

Try it: hover over any box, arrow or label in either image. Step 1 shows the code that drew it, step 2 the reference element it is matched to and its score. Hovering a line of code or a score works too.
1
Id render: which code drew it? The id render paints each drawing unit in its own color, so every pixel names the code behind it. The color bar next to the code shows the same color.
Id render
Hover over the figure
Code
2–3
Matching and score: how well does it match? Each rendered element is matched to one reference element and scored on appearance and geometry.
Program’s render
Reference image

Training: RA-GRPO

GRPO gives one score to a whole program. RA-GRPO gives each line the credit of what it draws.

Element credit

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.

Reference
reference image
A sampled program, rendered
negative credit from RA-GRPO
Its codeGRPORA-GRPO

Structure credit

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.

Structure credit

Four programs render the same image. Follow the four steps, or drag a box.

where the same edit moves the referencetry dragging any box or the arrow in any sample
<g> in the codethe line the edit changes

Editing: Attribution Tools for Coding Agents

The 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

Attribution tools for a coding agent

Two real 16-turn runs of Claude Code on the same draft, replayed from their logs. Drag the slider or press play.

Reference
the reference image both runs reproduce
LPIPS after each turn ×100, lower is better
standard tool callattribution tool callprogram changedchanged in this turn (on the renders)

Results: Image-to-Code Generation

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.

BibTeX

@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}
}