Type standard_image / noise_image as image columns
Browse files
README.md
CHANGED
|
@@ -4,6 +4,8 @@ license: odc-by
|
|
| 4 |
task_categories:
|
| 5 |
- image-to-text
|
| 6 |
- text-generation
|
|
|
|
|
|
|
| 7 |
tags:
|
| 8 |
- screenshot-to-code
|
| 9 |
- multimodal
|
|
@@ -18,7 +20,52 @@ configs:
|
|
| 18 |
default: true
|
| 19 |
data_files:
|
| 20 |
- split: train
|
| 21 |
-
path:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
---
|
| 23 |
|
| 24 |
# Pattern2Code
|
|
@@ -55,22 +102,30 @@ value from the image.
|
|
| 55 |
## Layout
|
| 56 |
|
| 57 |
```text
|
| 58 |
-
data/
|
|
|
|
| 59 |
metadata/dataset_info.json # summary statistics
|
| 60 |
metadata/validation_report.json
|
| 61 |
html/{cards,texts}/ # perturbed HTML
|
| 62 |
-
images/{cards,texts}/{standard,noise}/ #
|
| 63 |
```
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
## Row schema
|
| 66 |
|
| 67 |
| Field | Description |
|
| 68 |
|---|---|
|
|
|
|
|
|
|
| 69 |
| `example_id` | Unique instance id |
|
| 70 |
| `source_id` | Seed webpage id (Design2Code) |
|
| 71 |
| `pattern_family` | `structural_card` or `text_style` |
|
| 72 |
| `pattern_name`, `pattern_description`, `element_description` | The repeated pattern being probed |
|
| 73 |
-
| `attribute_name` | Masked CSS property (`width` or `
|
| 74 |
| `attribute_token` | The mask token (`__`) |
|
| 75 |
| `position` | Which element was perturbed: `first`, `mid`, `last` |
|
| 76 |
| `modified_index` | Index of the perturbed element within the pattern |
|
|
@@ -79,21 +134,20 @@ images/{cards,texts}/{standard,noise}/ # rendered screenshots
|
|
| 79 |
| `code_snippet_line` | The masked element's HTML |
|
| 80 |
| `code_snippet_context` | Masked element plus its sibling elements (model input) |
|
| 81 |
| `html_path` | Relative path to the full perturbed HTML |
|
| 82 |
-
| `
|
| 83 |
|
| 84 |
## Loading
|
| 85 |
|
| 86 |
```python
|
| 87 |
-
from datasets import load_dataset
|
| 88 |
|
| 89 |
ds = load_dataset("knguyennguyen/pattern2code", split="train")
|
| 90 |
|
| 91 |
-
# Attach the images (paths are relative to the repo root)
|
| 92 |
-
ds = ds.cast_column("standard_image", Image())
|
| 93 |
-
ds = ds.cast_column("noise_image", Image())
|
| 94 |
-
|
| 95 |
ex = ds[0]
|
|
|
|
|
|
|
| 96 |
print(ex["attribute_name"], ex["target_value"], "vs baseline", ex["bias_value"])
|
|
|
|
| 97 |
```
|
| 98 |
|
| 99 |
## Evaluation protocol
|
|
|
|
| 4 |
task_categories:
|
| 5 |
- image-to-text
|
| 6 |
- text-generation
|
| 7 |
+
language:
|
| 8 |
+
- en
|
| 9 |
tags:
|
| 10 |
- screenshot-to-code
|
| 11 |
- multimodal
|
|
|
|
| 20 |
default: true
|
| 21 |
data_files:
|
| 22 |
- split: train
|
| 23 |
+
path: data/train-*.parquet
|
| 24 |
+
dataset_info:
|
| 25 |
+
features:
|
| 26 |
+
- name: standard_image
|
| 27 |
+
dtype: image
|
| 28 |
+
- name: noise_image
|
| 29 |
+
dtype: image
|
| 30 |
+
- name: example_id
|
| 31 |
+
dtype: string
|
| 32 |
+
- name: source_id
|
| 33 |
+
dtype: string
|
| 34 |
+
- name: pattern_family
|
| 35 |
+
dtype: string
|
| 36 |
+
- name: pattern_name
|
| 37 |
+
dtype: string
|
| 38 |
+
- name: attribute_name
|
| 39 |
+
dtype: string
|
| 40 |
+
- name: attribute_token
|
| 41 |
+
dtype: string
|
| 42 |
+
- name: position
|
| 43 |
+
dtype: string
|
| 44 |
+
- name: target_value
|
| 45 |
+
dtype: string
|
| 46 |
+
- name: target_value_from_filename
|
| 47 |
+
dtype: string
|
| 48 |
+
- name: bias_value
|
| 49 |
+
dtype: string
|
| 50 |
+
- name: pattern_description
|
| 51 |
+
dtype: string
|
| 52 |
+
- name: element_description
|
| 53 |
+
dtype: string
|
| 54 |
+
- name: code_snippet_line
|
| 55 |
+
dtype: string
|
| 56 |
+
- name: code_snippet_context
|
| 57 |
+
dtype: string
|
| 58 |
+
- name: html_path
|
| 59 |
+
dtype: string
|
| 60 |
+
- name: standard_image_path
|
| 61 |
+
dtype: string
|
| 62 |
+
- name: noise_image_path
|
| 63 |
+
dtype: string
|
| 64 |
+
- name: modified_index
|
| 65 |
+
dtype: int32
|
| 66 |
+
splits:
|
| 67 |
+
- name: train
|
| 68 |
+
num_examples: 720
|
| 69 |
---
|
| 70 |
|
| 71 |
# Pattern2Code
|
|
|
|
| 102 |
## Layout
|
| 103 |
|
| 104 |
```text
|
| 105 |
+
data/train-*.parquet # the dataset: one row per instance, screenshots embedded
|
| 106 |
+
data/examples.jsonl # the same rows as raw JSON (image columns are paths only)
|
| 107 |
metadata/dataset_info.json # summary statistics
|
| 108 |
metadata/validation_report.json
|
| 109 |
html/{cards,texts}/ # perturbed HTML
|
| 110 |
+
images/{cards,texts}/{standard,noise}/ # the screenshots as loose PNG files
|
| 111 |
```
|
| 112 |
|
| 113 |
+
The Parquet files carry the screenshots inline, so both image columns render
|
| 114 |
+
directly in the dataset viewer and decode to `PIL.Image` with no extra setup.
|
| 115 |
+
The loose PNGs under `images/` are the same files, kept for anyone who wants to
|
| 116 |
+
work with them outside the `datasets` library.
|
| 117 |
+
|
| 118 |
## Row schema
|
| 119 |
|
| 120 |
| Field | Description |
|
| 121 |
|---|---|
|
| 122 |
+
| `standard_image` | **Image** — the rendered screenshot |
|
| 123 |
+
| `noise_image` | **Image** — the same page with eight opaque rectangles overlaid |
|
| 124 |
| `example_id` | Unique instance id |
|
| 125 |
| `source_id` | Seed webpage id (Design2Code) |
|
| 126 |
| `pattern_family` | `structural_card` or `text_style` |
|
| 127 |
| `pattern_name`, `pattern_description`, `element_description` | The repeated pattern being probed |
|
| 128 |
+
| `attribute_name` | Masked CSS property (`width` or `font_size`) |
|
| 129 |
| `attribute_token` | The mask token (`__`) |
|
| 130 |
| `position` | Which element was perturbed: `first`, `mid`, `last` |
|
| 131 |
| `modified_index` | Index of the perturbed element within the pattern |
|
|
|
|
| 134 |
| `code_snippet_line` | The masked element's HTML |
|
| 135 |
| `code_snippet_context` | Masked element plus its sibling elements (model input) |
|
| 136 |
| `html_path` | Relative path to the full perturbed HTML |
|
| 137 |
+
| `standard_image_path` / `noise_image_path` | Relative paths to the two screenshot files |
|
| 138 |
|
| 139 |
## Loading
|
| 140 |
|
| 141 |
```python
|
| 142 |
+
from datasets import load_dataset
|
| 143 |
|
| 144 |
ds = load_dataset("knguyennguyen/pattern2code", split="train")
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
ex = ds[0]
|
| 147 |
+
ex["standard_image"] # PIL.Image — already decoded, no cast_column needed
|
| 148 |
+
ex["noise_image"] # PIL.Image
|
| 149 |
print(ex["attribute_name"], ex["target_value"], "vs baseline", ex["bias_value"])
|
| 150 |
+
print(ex["code_snippet_context"])
|
| 151 |
```
|
| 152 |
|
| 153 |
## Evaluation protocol
|