Editor’s introduction
The study introduces Vision2Code, a multi-domain benchmark with 539 test examples from 15 datasets, assessing image-to-code generation without relying on reference code. It evaluates generated programs by executing them and comparing outputs to source images using domain-specific rubrics applied by vision-language models. The evaluation is robust across repeated sampling, varying rubric weights, and controlled errors. Performance varies significantly by domain, with charts and graphs achieving higher accuracy than scientific diagrams, documents, or spatial scenes. The study also shows that using the evaluator to filter generated outputs during fine-tuning improves model performance, with Qwen3.5-9B and Phi-4-MM seeing gains of 16% and 28% respectively. The evaluation method was validated using Qwen3.5-122B as the judge, though no additional judges were used in the data selection process.
Introduction
Image-to-code generation evaluates whether a vision-language model (VLM) can write executable code to reproduce an image. Unlike raw pixel generation, code provides an editable, interpretable, and verifiable representation, which is also what makes tools like LaTeX, Excalidraw, and Figma useful. It is also a demanding test of visual understanding. A model might correctly summarize a chart but still get the axis scale wrong, or identify the nodes in a graph while reversing the edge directions. Reconstructing the image through code requires the model to preserve these details, rather than just understanding the overall visual content. While prior benchmarks have made progress in studying image-to-code generation, there are still several limitations. Most of them focus on a particular visual domain. ChartMimic, Plot2Code, RealChart2Code, and Chart2Code evaluate charts and plots, while Design2Code, Web2Code, and Widget2Code focus on webpages and UI elements. Another limitation is the dependence on reference source code. Broader benchmarks like Omni-I2C require the original rendering code, which makes code-level evaluation straightforward but also restricts which images can be included. For most real-world visual data, this code is simply not available. Another issue is the evaluation of model-generated images. Current methods often use the same evaluation criteria across very different domains which makes it hard to detect fine-grained domain-specific errors. If the evaluator cannot detect such errors, it becomes difficult to reliably measure reconstruction quality across domains without reference code.
To bridge this gap, we introduce Vision2Code, a multi-domain, reference-code-free benchmark containing 539 test examples from 15 different datasets, spanning charts and plots, geometry, graphs, scientific diagrams, documents and 3D spatial scenes. Given the heterogeneous nature of the dataset with lack of source code, we perform evaluation on the rendered images and not their intermediate code. The images are compared against the source using dataset-specific rubrics and guardrails, where the different categories were semantically motivated based on visual inspection of different failure modes. We compared these scores against ratings from four human annotators and found stronger correlations than generic VLM rubrics and traditional metrics, including SSIM, PSNR, CLIP ViT-B/32, DreamSim, and Qwen3-VL-Embedding-8B cosine similarity. Another aspect we studied was VLM evaluator robustness, by modifying generated code to see if it catches the fine-grained details for respective domains. We also compared two independent VLM judges, repeated the evaluations and studied the sensitivity to rubric weights. Both judges gave the exact same leaderboard ranking across all nine models, with very little variance between runs, and were able to catch most of the manually introduced errors. We also found that perturbing the weights still preserves the leaderboard ranking, suggesting that the results are not overly dependent on the particular choice of weights. From the evaluation of nine open-weight and proprietary models, we observe that image-to-code performance varies considerably across domains. While models recreate charts and graphs relatively well, they still struggle with chemistry, scientific diagrams, document layouts, and 3D spatial scenes. Since ground-truth source code is missing from most visual datasets, we also investigated whether the evaluator could be used to select training data from a model’s own generations. Our evaluator-guided self-training approach filters image-code pairs by identifying cases where the model generates a good reconstruction initially but struggles to reproduce the same output when it is given back as input. Fine-tuning with these selected examples improves Qwen3.5-9B from 1.60 to 1.86 and Phi-4-MM from 0.58 to 0.74, with the gains holding under independent evaluators as well.
Code as a Medium for Visual Reasoning
There are several works in this domain using code for visual reasoning, although the way it is used varies across different systems. VisProg, ViperGPT, and CodeVQA generate programs that combine perception modules to answer visual questions. Chameleon and CodeAct use code for planning and tool execution. Another line of work is using code as an intermediate representation of visual information. Here, RECODE derenders images into executable code, CodePlot-CoT generates plots as part of mathematical reasoning, while Visual Sketchpad allows VLMs to draw through code. Visual Program Distillation studies how much of this programmatic reasoning can be distilled into a standalone VLM. While these approaches differ in how they use code, in most cases it serves as an intermediate step for solving another task. What we study in Vision2Code is the generated code itself, specifically how well the program can reconstruct the source image when executed.
Image-to-Code Benchmarks
Prior image-to-code benchmarks mainly focus on a particular type of output, restricting them to narrow scope. ChartMimic, Plot2Code, RealChart2Code, and Chart2Code evaluate charts and scientific plots. Design2Code, Web2Code, WebSight, Widget2Code, and Figma2Code focus on webpages and UI generation. Image2Struct looks at webpages, LaTeX, and musical scores, while UniSVG, VCode, SVGenius, VectorGym, and OmniSVG study vector graphics. Concurrent with our work, Omni-I2C evaluates several types of technical graphics and multiple programming languages, but relies on reference code. Vision2Code does not require such reference programs, which allows us to include datasets where only the image is available. HumanEval-V and MMCode also take images as inputs, but the goal there is to solve a programming problem shown in the image rather than reconstruct the image itself.
Evaluation of Image-to-Code Generation
A generated program may run successfully and still reconstruct the source poorly, therefore motivating image-level evaluation. Standard image metrics are useful baselines, but the information they measure is different: SSIM, PSNR and MSE are sensitive to pixel-level differences, while CLIP and DreamSim measure broader visual similarity. Neither directly checks the structural details important to every dataset. There are several works in this domain using different combinations of evaluation measures. Plot2Code reports code pass rate, text-match ratio and GPT-4V scores. For ChartMimic, both the generated code and rendered chart are evaluated, whereas Design2Code uses visual metrics together with human evaluation. Omni-I2C combines perceptual and symbolic measures. Another line of work is using MLLMs directly as judges. For Vision2Code, the different categories were semantically motivated based on visual inspection of different failure modes. We use these manually designed, dataset-specific criteria to evaluate reconstruction quality, comparing the scores against human ratings, a second VLM judge and standard image similarity metrics. The VLM evaluator is also tested by modifying generated code to see if it catches the fine-grained details for respective domains.
Task
Vision2Code studies image reconstruction by asking a VLM to generate executable code from a given image. Given a source image, a model must generate code whose execution recreates the image as faithfully as possible, but the goal is not to have an exact pixel-level match. We are interested in whether the model is able to preserve the actual information represented in the image, including plotted values, labels, topology, notation, document layout and spatial relations. Models are prompted to generate Python code using Matplotlib and NumPy, and are evaluated based on the rendered output rather than the specific code that produced it.
Domain coverage
We include six different domains in Vision2Code, each testing different capabilities. In charts and plots, models need to understand and recover numerical values, axes, scales, labels and the mapping between legends and plotted values. Geometry and graph images depend more on shape, proportions, connectivity and direction. Scientific figures in physics, chemistry and electrical circuits are particularly sensitive to small details where getting these wrong could change the meaning of the image. Documents test text and layout recovering capability, while spatial scenes require the model to capture object identity, depth and relative 3D placement. This gives us a well balanced mix of quantitative, symbolic, text-heavy and spatial images.
Dataset-specific rubric
For every sample, the rater is given the source image, the rendered reconstruction, reference metadata and the rubric corresponding to that dataset. Each rubric consists of four categories, with weights that sum to one. The different categories are scored from 0 to 5 in increments of 0.1, and we calculate the final score as their weighted sum. The first two categories are meant to capture the most important aspects of the image. If either receives a score below a specified threshold, the overall score is capped. We also have additional dataset-specific caps to account for severe errors, since getting certain details wrong could change the actual meaning of the image even if the other parts are reconstructed well. In cases where the rater returns an invalid response or misses a required category, we ask it to evaluate the same pair again. The complete rules and prompts are provided in Appendix A.
Validation protocol
We validate our evaluation framework by correlating our scores with human scores and compare these correlations with several other baselines. To test the effect of our dataset-specific rubric, we compare against a dataset invariant rubric with four equally weighted criteria for all samples in the dataset. These include core information fidelity, structure and layout fidelity, text and annotation accuracy, and visual completeness. We also include standard similarity methods like SSIM, PSNR, CLIP ViT-B/32, DreamSim, and Qwen3-VL-Embedding-8B. For Qwen3-VL, we test similarity on both the image embedding alone and a version that includes short dataset-specific text describing what should be preserved in the image. We use Pearson and Spearman correlation against the mean score of the four human annotators and also report Inter-Annotator Agreement (IAA) using the Intraclass Correlation Coefficient (ICC). Appendix E provides the rating instructions, interface and annotator details.
Reasoning effects
While test-time reasoning helps improve the score for all three models under both judges, the gains vary across domains. Some datasets have lower scores with reasoning, and several of these decreases appear under both judges. This is particularly clear on SpatialVLM-QA for Kimi-K2.5 and Qwen3.5-397B-A17B. We also observe decreases on Matplotlib and Graph-Algorithms for Kimi-K2.5, and on Geometry3K and Physics for GPT-5.4 Mini. This could happen because reasoning may help the model decompose the image and plan the overall code structure but not with the extraction of exact visual details.
Domain-specific error sensitivity
Another thing we studied was VLM evaluator robustness by modifying generated code to see if it catches the fine-grained details for respective domains. For this experiment, we selected 71 reconstructions from 14 datasets across all nine evaluated models, where every reconstruction had received a score of at least 4.5 from both judges. We then modified the corresponding programs to introduce one controlled error targeting a particular rubric category, while keeping the remaining content unchanged. The idea is to see if the score of that category decreases when an error is introduced. We find that the targeted score drops in 65/71 cases for Qwen3.5-122B and 68/71 for Kimi-K2.6, with mean decreases of 2.36 and 2.02 points on the 0–5 scale. The final score also decreases in 66/71 cases for Qwen and all 71 cases for Kimi, and neither judge assigns a higher score to any of the modified images. Both judges struggle the most with geometry, missing errors such as a shortened trapezoid segment, a broken parallelogram connection or a removed right-angle label. Qwen also misses an absent chart bar, a changed chemical bond and a circuit gap, while Kimi misses a modified graph edge weight. Qualitative examples are provided in Appendix L.
Reconstruction Failures
For charts and plots, we observe flipped axes, plot trends that are not preserved, and overlapping legends or labels. Geometry reconstructions often have incorrect proportions, missing components, wrong shapes and overlapping text. In graphs, the errors include reversed arrow directions, incorrect overall topology and wrong node or edge labels. Chemistry examples frequently have incorrect molecular shapes, missing double or triple bonds, wrong atom identities and heavy overlap. Object placement is a problem in physics examples, where objects may overlap slopes or appear to float. Circuit reconstructions often have missing components, malformed component shapes or disconnected paths. While document reconstructions may capture the rough content, they can still lose the formatting, relative proportions and layout. Spatial scenes are particularly difficult, with models often failing to preserve depth and relative object placement. Qualitative examples are provided in Appendix I.
Conclusion
Vision2Code is a comprehensive, multi-domain, reference-code-free benchmark for evaluating image-to-code generation capability in VLMs. Our experiments show that our dataset-specific evaluator agrees more closely with human ratings than several other metrics and is robust to various ablations. The benchmark reveals that current models are much stronger on charts and graphs than on spatial scenes, scientific diagrams, and documents, which are signals for directions of improvement for frontier models. We also demonstrated that using our evaluator to curate model-generated outputs is a viable strategy for self-training, yielding clear performance boosts for both Qwen3.5-9B and Phi-4-MM. That being said, several limitations remain. The benchmark’s scope is restricted to its source datasets and can be extended to many more domains. The leaderboard scores are based on Python generated code (specifically Matplotlib and NumPy). Exploring the impact of the intermediate code representation could be an interesting future direction. Additionally, while robust, our VLM evaluator can still miss subtle errors that humans can catch. Future work can expand the benchmark to include more datasets, programming languages, and evaluation methods to further advance image-to-code generation capabilities.
Data sources
Vision2Code is built from 15 visual source datasets. Each example is converted to a common schema containing a source image, source metadata, source provenance, dataset identity, and a stable sample identifier. The sources are ChartQA, DVQA, FigureQA, Matplotlib Gallery examples, Geoperception, GEOQA_8K_R1V from the GeoQA-8K direct-synthesizing release associated with GeoQA and MM-UPT, Geometry3K from Inter-GPS, Graph-Algorithms and Physics from Zebra-CoT, GraphVQA-Swift, ChemVQA-2K, EEE-Bench, OlympiadBench, DocVQA, and SpatialVLM-QA. All sources except Matplotlib are obtained from public Hugging Face releases; the Matplotlib examples are scraped from the official gallery, retaining only successfully rendered figures. For release, we document the exact source URI, license or access status, split policy, and redistribution status for each dataset in the accompanying license and provenance table.
Rendering environment
Generated code is executed in a temporary directory with MPLBACKEND=Agg. The evaluator defines OUTPUT_PATH and monkey-patches Matplotlib savefig calls so that the output is saved to the expected path at the same pixel dimensions as the source image. The renderer sets the figure size from the source width and height with target DPI 100, enforces bbox_inches=None and pad_inches=0, and times out executions after 30 seconds unless overridden by a run configuration. If code execution fails, exits without producing an image, or produces an unreadable image, the sample is counted as a render failure and receives benchmark score 0.0.
Embedding Similarity baseline
We also compare against embedding-similarity baselines using Qwen3-VL-Embedding-8B. These baselines do not use a VLM rater or rubric. Instead, they embed the source image and rendered output and compute cosine similarity between the two embeddings. We evaluate two variants. The image-only variant embeds each image directly. The image+text variant embeds each image together with a short dataset-specific focus text that describes the visual information that should matter for that source dataset. The same focus text is used for the source image and rendered output of a given example. Appendix D.2.1 lists the focus texts. For both embedding variants, the common embedding instruction is: “Represent the input for comparing the visual fidelity of a recreated figure to its source.”
Test-time scaling
We also test whether repeated refinement over four stages improves reconstruction at inference time. At stage 1, the model receives only the source image. At later stages, it receives the source image together with its previous code and rendered output, and is asked to improve the reconstruction. For Qwen3.5-9B, the first refinement gives a small gain, but later stages do not improve further. For GPT-5.4 Mini, repeated refinement slightly reduces performance. One possible reason is that after the first pass, the main challenge is no longer generating code but identifying exactly what is wrong with the rendered image. Without a separate verifier, the model has to judge its own mistakes and may keep modifying an already incorrect structure.
Stage 1 uses the standard image-to-code prompt. For stages 2–4, the model receives the original reference image, the previous rendered output, and the previous Python code, and is asked to rewrite the code so that the rendered output better matches the reference.
Code format
Vision2Code does not require a specific programming language or rendering tool; it only requires an executable artifact that can be rendered into an image. To test this, we rerun GPT-5.4 Mini on a separate 292-example DocVQA held-out set with LaTeX instead of the default Python/Matplotlib target, then compile and rasterize the LaTeX output before applying the same DocVQA rater and rubric. LaTeX performs worse in both render success and reconstruction score, likely because many DocVQA pages contain scanned forms, dense tables, and irregular layouts that are difficult to reproduce with LaTeX. We also test Excalidraw on a small set of 48 web-scraped examples, where it reaches 100% render success and a generic-rubric score of 3.90. Appendix M shows qualitative reconstruction examples for LaTeX and Excalidraw.


