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| 11 |
+
- webdataset
|
| 12 |
+
- eval
|
| 13 |
+
configs:
|
| 14 |
+
- config_name: original
|
| 15 |
+
data_files:
|
| 16 |
+
- split: test
|
| 17 |
+
path: data/*.tar
|
| 18 |
+
- config_name: augmented
|
| 19 |
+
data_files:
|
| 20 |
+
- split: test
|
| 21 |
+
path: data_aug/*.tar
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# OCR Eval
|
| 25 |
+
|
| 26 |
+
A small, fixed **evaluation** set of synthetic Arabic document images with layout
|
| 27 |
+
annotations — the held-out companion to [OCR-Data/ocr_data](https://huggingface.co/datasets/OCR-Data/ocr_data).
|
| 28 |
+
|
| 29 |
+
**Do not train on this.** It exists so OCR models trained on `ocr_data` can be scored on
|
| 30 |
+
unseen pages from the same generator.
|
| 31 |
+
|
| 32 |
+
| | |
|
| 33 |
+
|---|---|
|
| 34 |
+
| Originals | **1500** (lossless PNG + JSON) |
|
| 35 |
+
| Augmented | **1500** — exactly one variant per original (lossless PNG + JSON) |
|
| 36 |
+
| Shards | 2 (`data/shard_001.tar`, `data_aug/shard_001_aug1.tar`) |
|
| 37 |
+
| Templates | the same 14 document genres as `ocr_data` |
|
| 38 |
+
| Augmentations | the same 10 transforms as `ocr_data`, same weighting |
|
| 39 |
+
| Language | Arabic (RTL) |
|
| 40 |
+
|
| 41 |
+
## Loading
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
from datasets import load_dataset
|
| 45 |
+
|
| 46 |
+
clean = load_dataset("OCR-Data/ocr_eval", "original", split="test")
|
| 47 |
+
noisy = load_dataset("OCR-Data/ocr_eval", "augmented", split="test")
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
Both configs are WebDataset shards: files sharing a basename are one sample, so the image
|
| 51 |
+
arrives as the `image` column and the annotation as `json`.
|
| 52 |
+
|
| 53 |
+
## Pairing originals with their variants
|
| 54 |
+
|
| 55 |
+
A variant's key is its original's key plus a two-digit slot:
|
| 56 |
+
|
| 57 |
+
```
|
| 58 |
+
sample_0000042 -> data/shard_001.tar
|
| 59 |
+
sample_0000042_01 -> data_aug/shard_001_aug1.tar
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
**The shared stem is the only linkage** — there is no field inside the annotation pointing
|
| 63 |
+
back at the original. Strip the `_NN` suffix to join the two configs:
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
original_key = variant_key.rsplit("_", 1)[0]
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## Text is unique per image
|
| 70 |
+
|
| 71 |
+
This is the one place the eval set deliberately departs from how `ocr_data` was generated,
|
| 72 |
+
and the reason it can be used for independent measurements.
|
| 73 |
+
|
| 74 |
+
In the training set, workers share a pool of 3000 consecutive corpus pages and draw from it
|
| 75 |
+
at random, so the same page renders into many images. Here, **every image is given its own
|
| 76 |
+
private set of 10 corpus pages that no other image may use**, drawn from a shuffled read
|
| 77 |
+
across the whole 4.6M-page source corpus rather than one contiguous window. A document
|
| 78 |
+
consumes several pages (a page runs out and the next is pulled), so the guarantee is
|
| 79 |
+
enforced over the whole set a page may come from, not over a single page.
|
| 80 |
+
|
| 81 |
+
`meta.corpus_pages` lists the pages each document actually consumed, as truncated SHA-1
|
| 82 |
+
digests of the page text, so the property is checkable rather than merely claimed:
|
| 83 |
+
|
| 84 |
+
```python
|
| 85 |
+
pages = [p for r in clean for p in r["json"]["meta"]["corpus_pages"]]
|
| 86 |
+
assert len(pages) == len(set(pages)) # no corpus page used by two images
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
## Annotation schema
|
| 90 |
+
|
| 91 |
+
```json
|
| 92 |
+
{
|
| 93 |
+
"markdown": "...",
|
| 94 |
+
"dimensions": {"dpi": 96, "width": 0, "height": 0},
|
| 95 |
+
"blocks": [{"type": "title|text|table|image|header|footer",
|
| 96 |
+
"content": "...", "reading_index": 0,
|
| 97 |
+
"top_left_x": 0, "top_left_y": 0,
|
| 98 |
+
"bottom_right_x": 0, "bottom_right_y": 0}],
|
| 99 |
+
"images": [{"top_left_x": 0, "...": 0}],
|
| 100 |
+
"tables": [],
|
| 101 |
+
"header": null,
|
| 102 |
+
"footer": null,
|
| 103 |
+
"meta": {"template": "a4_report", "hybrid": null,
|
| 104 |
+
"page_font": "...", "title_font": "...",
|
| 105 |
+
"language": "ar", "script": "arabic", "direction": "rtl",
|
| 106 |
+
"corpus_pages": ["a1b2c3d4e5f6", "..."],
|
| 107 |
+
"augmentation": null}
|
| 108 |
+
}
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
`meta.augmentation` is `null` throughout the `original` config and
|
| 112 |
+
`{"name": ..., "params": {...}}` throughout `augmented`. Coordinates are pixels in the
|
| 113 |
+
image's own space; `rotation` is the only augmentation that changes dimensions, and its
|
| 114 |
+
boxes are transformed to match.
|
| 115 |
+
|
| 116 |
+
Augmentation counts are the training weighting applied to 1500 draws — roughly 160 samples
|
| 117 |
+
for each of `gaussian_blur`, `bad_photocopy`, `bleed_through`, `color_shift`, `letterpress`,
|
| 118 |
+
`rotation`, `reflected_light`, `shadow_cast`, `gaussian_noise`, and ~37 `watermark`. Group
|
| 119 |
+
by `meta.augmentation.name` to report per-transform robustness.
|
| 120 |
+
|
| 121 |
+
## Caveats
|
| 122 |
+
|
| 123 |
+
- **Not deduplicated against the training set.** Corpus *text* is unique per image and
|
| 124 |
+
scattered across the whole source corpus, but the generator does no content hashing, so
|
| 125 |
+
an eval layout can coincidentally resemble a training layout. This is a synthetic
|
| 126 |
+
in-distribution eval, not a contamination-proof benchmark.
|
| 127 |
+
- **Not reproducible.** The generator does not seed its RNG, so this exact set of 1500
|
| 128 |
+
cannot be regenerated. These shards are the only copy of the ground truth. Each variant's
|
| 129 |
+
parameters are recorded in `meta.augmentation.params` and each page's text provenance in
|
| 130 |
+
`meta.corpus_pages`.
|
| 131 |
+
- Ground truth is **synthetic**, not human-annotated: boxes and reading order come from the
|
| 132 |
+
renderer's own DOM, so they are exact by construction rather than by agreement.
|
| 133 |
+
|
| 134 |
+
To get loose files back out of a shard, use `unpack_shard.py` from the generator repo.
|