Add dataset card
Browse files
README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pretty_name: ocr_data
|
| 3 |
+
task_categories:
|
| 4 |
+
- image-to-text
|
| 5 |
+
language:
|
| 6 |
+
- ar
|
| 7 |
+
tags:
|
| 8 |
+
- ocr
|
| 9 |
+
- arabic
|
| 10 |
+
- synthetic
|
| 11 |
+
- webdataset
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# ocr_data
|
| 15 |
+
|
| 16 |
+
Synthetic Arabic document images with layout annotations, for OCR training.
|
| 17 |
+
|
| 18 |
+
## Layout
|
| 19 |
+
|
| 20 |
+
WebDataset `.tar` shards. Files sharing a basename are one sample, so the
|
| 21 |
+
image becomes the `image` column and the annotation the `json` column.
|
| 22 |
+
|
| 23 |
+
```
|
| 24 |
+
data/<contributor>_<NNN>.tar originals (PNG + JSON)
|
| 25 |
+
data_aug/<contributor>_<NNN>_aug<K>.tar augmented variants (JPEG/PNG + JSON)
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
Each shard holds up to 9990 samples (~1.2 GB). `data/` and `data_aug/`
|
| 29 |
+
are separate so you can train on clean originals alone.
|
| 30 |
+
|
| 31 |
+
## Loading
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
from datasets import load_dataset
|
| 35 |
+
|
| 36 |
+
# one shard
|
| 37 |
+
ds = load_dataset("webdataset",
|
| 38 |
+
data_files="hf://datasets/OCR-Data-new/ocr_data/data/<contributor>_001.tar",
|
| 39 |
+
split="train", streaming=True)
|
| 40 |
+
|
| 41 |
+
# a range of shards
|
| 42 |
+
ds = load_dataset("webdataset",
|
| 43 |
+
data_files="hf://datasets/OCR-Data-new/ocr_data/data/<contributor>_{001..010}.tar",
|
| 44 |
+
split="train", streaming=True)
|
| 45 |
+
|
| 46 |
+
# everything, originals + augmented
|
| 47 |
+
ds = load_dataset("webdataset", data_files={"train": [
|
| 48 |
+
"hf://datasets/OCR-Data-new/ocr_data/data/*.tar",
|
| 49 |
+
"hf://datasets/OCR-Data-new/ocr_data/data_aug/*.tar"]},
|
| 50 |
+
split="train", streaming=True)
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
To get loose files back, use `unpack_shard.py` from the generator repo.
|
| 54 |
+
|
| 55 |
+
## Annotation schema
|
| 56 |
+
|
| 57 |
+
```json
|
| 58 |
+
{
|
| 59 |
+
"dimensions": {"width": 0, "height": 0},
|
| 60 |
+
"blocks": [{"type": "...", "text": "...", "top_left_x": 0, "top_left_y": 0,
|
| 61 |
+
"bottom_right_x": 0, "bottom_right_y": 0, "reading_index": 0}],
|
| 62 |
+
"images": [{"top_left_x": 0, "...": 0}],
|
| 63 |
+
"meta": {"template": "...", "hybrid": null, "page_font": "...",
|
| 64 |
+
"language": "ar", "script": "arabic", "direction": "rtl",
|
| 65 |
+
"augmentation": null}
|
| 66 |
+
}
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
`meta.augmentation` is `null` for originals and
|
| 70 |
+
`{"name": ..., "params": {...}}` for augmented variants.
|