Spaces:
Running
Running
Update README.md
Browse filesFiles changed (3)
- .gitattributes+1
- README.md+20-129
- teaser.pngAdded
32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textteaser.png filter=lfs diff=lfs merge=lfs -text1234567891011345678912131415131415161718192021222324252627282930313233343536373839404142434445464716174950515253545518192021596061626364656667686970717273747576777879808182838485868788899091922223949596979899100101102103104105106107108109242526272829111112113114115116117118119120121122123124125126127128129130131132133134135136137138139303132334 unmodified lines38394015041---title: READMEemoji: 🎨colorFrom: bluecolorTo: indigosdk: staticpinned: false---
# Who Drew That Pixel? Fine-Grained Visual Attribution for Image-to-Code Generation and Editing
<p align="center"> <a href="https://arxiv.org/abs/TBD.00000"><img src="https://img.shields.io/badge/arXiv-Paper-b31b1b?style=for-the-badge&logo=arxiv&logoColor=white" alt="Paper"></a> <a href="https://render-attribution.github.io"><img src="https://img.shields.io/badge/%F0%9F%8C%90%20Project-Page-3F6496?style=for-the-badge" alt="Project page"></a> <a href="https://huggingface.co/render-attribution"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Models-FFD21E?style=for-the-badge" alt="Models"></a></p>[Paper](https://arxiv.org/abs/TBD.00000) | [Code](https://github.com/render-attribution/render-attribution) | [Project page](https://render-attribution.github.io)
[Hexuan Wang](https://mattwang123.github.io)<sup>1</sup>, [Zixian Ma](https://zixianma.github.io)<sup>2</sup>, [Ranjay Krishna](https://ranjaykrishna.com)<sup>2</sup>, [Jaemin Cho](https://j-min.io)<sup>1</sup><br><sup>1</sup>Johns Hopkins University, <sup>2</sup>University of Washington
[](https://render-attribution.github.io)
> [!NOTE]> The **[project page](https://render-attribution.github.io)** has an animated overview and interactive examples.
Render attribution finds which line of an SVG, TikZ or HTML program drew each pixel.RA-GRPO uses this to reward or penalize each line on its own during training.The attribution tools give the same information to a coding agent that edits a figure.
## Repository structure
```ragrpo/ render attribution and RA-GRPOtrain/ training code and the configs of all paper runsagent/ attribution tools for coding agentseval/ metrics used in the paperbaselines/ir4rl/ our version of IR4RLdata/ lists of training imagesscripts/ model and asset downloadtests/ quick tests that run on the CPU```
Most folders have their own README with more details.
## Installation
Training needs two Python environments. The first one runs the trainer, the attribution tools and the metrics. The second one holds [vLLM](https://github.com/vllm-project/vllm), which samples the programs during training and runs the models for evaluation. vLLM pins its own versions of PyTorch and transformers, so it gets a separate environment. If you only use the attribution tools or score existing outputs, the first environment is enough.
```pip install -r requirements.txt # trainer, tools and metricspython -m playwright install chromium # renders HTMLpip install -r requirements-vllm.txt # in the second environment```
TikZ also needs [tectonic](https://tectonic-typesetting.github.io), for example `conda install -c conda-forge tectonic=0.17.0`. HTML needs three files that `bash scripts/get_html_assets.sh` downloads.
## Quick example
```python examples/run_example.py --out examples/out```
This runs render attribution on a toy SVG with eight sampled programs, on the CPU in under a minute. It prints the matched elements, the score of every element, and the advantage that GRPO and RA-GRPO give to each code line. It saves the renders and id renders of all programs to `examples/out`.Render attribution finds which line of an SVG, TikZ or HTML program drew each pixel. RA-GRPO uses it to reward or penalize each line on its own during training.
## Models
```bash scripts/download_models.sh```
This puts the start models in `models/` and our adapters in `checkpoints/`.
| Model | Paper | Base model ||---|---|---|| [RA-GRPO-SVG-4B](https://huggingface.co/render-attribution/RA-GRPO-SVG-4B) | Table 2 | [VFIG-4B](https://huggingface.co/XunmeiLiu/VFIG-4B) || [RA-GRPO-SVG-Code-4B](https://huggingface.co/render-attribution/RA-GRPO-SVG-Code-4B) | Table 6 | [VFIG-4B](https://huggingface.co/XunmeiLiu/VFIG-4B) || [RA-GRPO-TikZ-4B](https://huggingface.co/render-attribution/RA-GRPO-TikZ-4B) | Table 3 | [SciTikZer-4B](https://huggingface.co/JackieLin0123/SciTikZer-4B) || [RA-GRPO-HTML-4B](https://huggingface.co/render-attribution/RA-GRPO-HTML-4B) | Table 4 | Qwen3-VL-4B-SFT-HTML || [Qwen3-VL-4B-SFT-HTML](https://huggingface.co/render-attribution/Qwen3-VL-4B-SFT-HTML) | Table 4 (Qwen3-VL-4B-SFT) | [Qwen3-VL-4B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct) |
The RA-GRPO models are LoRA adapters. They are applied on top of the base model without merging, as in all our evaluations.
## Training
Build the training records as explained in `data/README.md`. Each run uses two GPUs.Use `ragrpo` for our method and `grpo` for the baseline.
```export TRAIN_PY=/path/to/train-env/python VLLM_PY=/path/to/vllm-env/python GPUS=0,1train/launch.sh train/configs/svg.yaml ragrpo runs/svg_ragrpotrain/launch.sh train/configs/tikz.yaml ragrpo runs/tikz_ragrpotrain/launch.sh train/configs/html.yaml ragrpo runs/html_ragrpotrain/launch.sh train/configs/svg.yaml grpo runs/svg_grpo```
All settings are in `train/configs/`. For a quick check, add `--set steps=2 eval_every=2 dev_n=4 save_every=2`.
We trained every run on two NVIDIA RTX PRO 6000 GPUs with 96 GB each. On each GPU, the vLLM server takes 35% of the memory (`--util` in `train/gen_server.py`) and the trainer uses the rest.
| Config | Steps | Time per run | Time per step || Model | Task | Base model | Paper ||---|---|---|---|| `svg.yaml` | 150 | 13.7 h | 328 s || `tikz.yaml` | 200 | 8.5 h | 153 s || `html.yaml` | 300 | 7.2 h | 87 s |
GRPO takes the same time as RA-GRPO, within 1.3%.
`launch.sh` first does a 2-step check in `runs/svg_ragrpo/smoke` and then the full run in `runs/svg_ragrpo/run`, which holds
```config.json the settings of the runlog_r0.jsonl one line per training step (mean reward, KL, gradient norm)dev_summary.jsonl render rate and LPIPS on the dev images, every 25 stepsstep25, step50, ... the LoRA adapters, to use with --lora```
## Evaluation| [RA-GRPO-SVG-4B](https://huggingface.co/render-attribution/RA-GRPO-SVG-4B) | image to SVG | [VFIG-4B](https://huggingface.co/XunmeiLiu/VFIG-4B) | Table 2 || [RA-GRPO-SVG-Code-4B](https://huggingface.co/render-attribution/RA-GRPO-SVG-Code-4B) | image to SVG, editable code | [VFIG-4B](https://huggingface.co/XunmeiLiu/VFIG-4B) | Table 6 || [RA-GRPO-TikZ-4B](https://huggingface.co/render-attribution/RA-GRPO-TikZ-4B) | image to TikZ | [SciTikZer-4B](https://huggingface.co/JackieLin0123/SciTikZer-4B) | Table 3 || [RA-GRPO-HTML-4B](https://huggingface.co/render-attribution/RA-GRPO-HTML-4B) | screenshot to HTML | [Qwen3-VL-4B-SFT-HTML](https://huggingface.co/render-attribution/Qwen3-VL-4B-SFT-HTML) | Table 4 || [Qwen3-VL-4B-SFT-HTML](https://huggingface.co/render-attribution/Qwen3-VL-4B-SFT-HTML) | screenshot to HTML (start model) | [Qwen3-VL-4B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct) | Table 4 |
```python data/build_records.py test --out data --bench_svgs VFIG_BENCH_SVGSpython eval/decode.py --domain svg --model models/VFIG-4B --lora checkpoints/RA-GRPO-SVG-4B --records data/vfig_bench_test.json --out preds/svg.jsonlpython eval/svg_metrics.py --records data/vfig_bench_test.json --pred preds/svg.jsonl --out scores/svg```
Run `decode.py` in the vLLM environment. It writes one model reply per test image to `preds/svg.jsonl`. `svg_metrics.py` prints the mean of every metric and saves `summary.json` and `per_item.json` to `scores/svg`. With our adapter, the numbers should match the RA-GRPO row of Table 2, for example LPIPS 15.9 and DreamSim 92.2 on VFIG-Bench. `eval/README.md` has the commands for every table.
## Attribution tools
```python -m agent.mcp_server --arm attribution --workdir DIR```
This starts an MCP server with the tools `who_draws`, `fit` and `findings` for a coding agent. `DIR` holds the reference `input.png` and the agent's `program.svg`.
```python agent/run_claude_code.py --image input.png --draft draft.svg --out runs/fig1 --arm attribution --max-turns 4```
This runs Claude Code with the tools on one figure. It saves the edited program to `runs/fig1/final.svg` and the turns, tokens and tool calls to `runs/fig1/run.json`. `agent/README.md` explains the tools and the setup.
## Tests
```PYTHONPATH=. python tests/test_smoke.py```
The tests take about a minute and end with `all smoke tests passed`.The RA-GRPO models are LoRA adapters, applied on top of the base model without merging. Each model page has a usage example.
## Citation
4 unmodified lines journal = {arXiv preprint arXiv:TBD.00000}, year = {2026}}``````.gitattributes+1
README.md+20-129
teaser.pngAdded

Large File Pointer Details
- SHA256: 5970d984d4a0a95c7d1ca70cdbe4bb989003c5640d60386616cd10272fe8ee75
- Pointer size: 131 Bytes
- Size of remote file: 235 kB