File size: 5,522 Bytes
c9cc135 96294bc c9cc135 96294bc c9cc135 96294bc c9cc135 96294bc c9cc135 96294bc c9cc135 9f1c96f c9cc135 96294bc c9cc135 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | ---
license: bsl-1.0
pretty_name: Widget2Code Data V4.1
task_categories:
- image-to-text
tags:
- screenshot-to-code
- react
- jsx
- multimodal
---
# Widget2Code Data V4.1
Widget2Code Data V4.1 contains UI screenshots for training and evaluation, plus
renderable JSX reference examples. Prompt-ready image information and reusable
ground-truth evaluation features are stored directly in each screenshot's
`metadata.json`.
V4.1 is a backward-compatible label-quality patch. It keeps the `train/`, `test/`, and
`sft-v4/` paths stable, while repairing six train references that omitted or miscolored a major
background. Git tag `v4.0.0` preserves the pre-patch dataset and `v4.1.0` identifies this release;
consumers should pin one of those tags or an exact commit rather than a moving branch.
## Dataset layout
| directory | samples | contents |
| --- | ---: | --- |
| `train/` | 1,822 | training screenshots and canonical metadata |
| `test/` | 1,000 | evaluation screenshots and canonical metadata |
| `sft-v4/train/` | 1,822 | JSX references and their renders, linked to `train/` |
| `sft-v4/test/` | 1,000 | JSX references and their renders, linked to `test/` |
The canonical screenshot pools use this two-file layout:
```text
train/image_0004/
test/image_0001/
├── image.png
└── metadata.json
```
The SFT reference pools do not duplicate the target screenshots:
```text
sft-v4/train/image_0004/
sft-v4/test/image_0001/
├── code.jsx
├── rendered.png
└── metadata.json
```
An SFT sample's `metadata.json` contains `source_split: train` or
`source_split: test`. Combine that split with the same sample ID to locate its
target screenshot. `rendered.png` is the output of `code.jsx`; it is not the
target image. The test references are generated examples, not ground-truth
evaluation labels, and normal evaluation reads only `test/`.
## Screenshot metadata
Each `train/` and `test/` metadata file has this shape:
```jsonc
{
"id": "image_0004",
"split": "train",
"sha256": "...", // SHA-256 of image.png
"category": "tools", // null when not labelled
"has_chart": null, // null when not labelled
"eval": {
"layout": { "margin": [], "mask_empty": false, "bbox_ar": 0.0, "area_ratio": 0.0, "n_comp": 0 },
"legibility": { "text": "...", "contrast": 0.0, "contrast_local": 0.0 },
"style": { "hue_hist": [], "sat_hist": [], "polarity": [] },
"fill": { "black": {}, "white": {} }
},
"side_info": {
"dims": [976, 668],
"ocr": "- `\"Pesquisar\"` at (16.5%, 10.0%) of widget, font-height ≈ 7.2% of widget height",
"palette": "Target widget palette (top-4, after AA-fringe consolidation):\n #353A38 64.63%\n ..."
}
}
```
`side_info` is the complete prompt-ready representation derived from
`image.png`: exact `[width, height]`, formatted OCR output, and the formatted
dominant palette. Consumers should read these values directly; there are no
`dims.txt`, `ocr.txt`, or `palette.txt` sidecars.
`eval` caches the features that depend only on the ground-truth screenshot:
geometry/layout, OCR text and contrast, color/style, and missing-prediction fill
scores. A benchmark run can reuse these values for every prediction instead of
recomputing the ground-truth side. Pairwise metrics such as SSIM and LPIPS still
require the prediction image.
## SFT metadata
Each `sft-v4` metadata file identifies the canonical target and records
generation provenance:
```jsonc
{
"source_split": "train",
"generation": {
"model": "gemini-3.1-pro-preview",
"variant": "policy-repaired",
"code_sha256": "...",
"render_ok": true,
"rendered_sha256": "..."
}
}
```
Additional prompt, renderer, and validation fields are retained where they were
recorded. The six V4.1 repairs use `variant: policy-repaired-v4.1` and add
`repair_revision: v4.1.0` plus `repair_reason: restore-major-background`. All 2,822 references
have a successful render.
Every `rendered.png` is the output of `houstonzhang/w2c-render:1.3.1` under the
`m2` contract, and `rendered_sha256` is its checksum. That renderer draws the
same source the same way twice, which earlier ones did not: Chromium reused a
tile from a previous frame, so about one chart render in two hundred came back
a different picture, and a chart that did not disable its own animation was
screenshotted at whichever frame the clock allowed. Re-rendering the references
is therefore a check, not a coin flip:
```bash
W2C_RENDER_MODE=m2 docker/run.sh 16 # from the widget2code-render checkout
python scripts/verify_references.py --split sft-v4/train
```
## Rebuilding prompt side information
The canonical metadata was prepared with the Widget2Code benchmark 1.2.0 CPU
container. On the 96-vCPU reference host, 64 workers was the measured best
setting:
```bash
for split in train test; do
docker run --rm --user "$(id -u):$(id -g)" -e HOME=/tmp \
-v "$PWD/$split:/data" \
houstonzhang/w2c-bench:1.2.0 widget2code-sideinfo \
/data --out /data --workers 64 --force
done
```
CPU output is canonical. GPU OCR follows a different numeric path and is not
guaranteed to produce byte-identical OCR text.
## Download
```python
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="Djanghao/Widget2Code-Data-V4",
repo_type="dataset",
revision="v4.1.0",
local_dir="Widget2Code-Data-V4",
)
```
Files are stored raw and per sample. Training code can assemble its preferred
record format after download.
|