ocr_data / README.md
Nihvll's picture
Add dataset card
34714cd verified
|
Raw History Blame Contribute Delete
2 kB
---
pretty_name: ocr_data
task_categories:
- image-to-text
language:
- ar
tags:
- ocr
- arabic
- synthetic
- webdataset
---
# ocr_data
Synthetic Arabic document images with layout annotations, for OCR training.
## Layout
WebDataset `.tar` shards. Files sharing a basename are one sample, so the
image becomes the `image` column and the annotation the `json` column.
```
data/<contributor>_<NNN>.tar originals (PNG + JSON)
data_aug/<contributor>_<NNN>_aug<K>.tar augmented variants (JPEG/PNG + JSON)
```
Each shard holds up to 9990 samples (~1.2 GB). `data/` and `data_aug/`
are separate so you can train on clean originals alone.
## Loading
```python
from datasets import load_dataset
# one shard
ds = load_dataset("webdataset",
data_files="hf://datasets/OCR-Data-new/ocr_data/data/<contributor>_001.tar",
split="train", streaming=True)
# a range of shards
ds = load_dataset("webdataset",
data_files="hf://datasets/OCR-Data-new/ocr_data/data/<contributor>_{001..010}.tar",
split="train", streaming=True)
# everything, originals + augmented
ds = load_dataset("webdataset", data_files={"train": [
"hf://datasets/OCR-Data-new/ocr_data/data/*.tar",
"hf://datasets/OCR-Data-new/ocr_data/data_aug/*.tar"]},
split="train", streaming=True)
```
To get loose files back, use `unpack_shard.py` from the generator repo.
## Annotation schema
```json
{
"dimensions": {"width": 0, "height": 0},
"blocks": [{"type": "...", "text": "...", "top_left_x": 0, "top_left_y": 0,
"bottom_right_x": 0, "bottom_right_y": 0, "reading_index": 0}],
"images": [{"top_left_x": 0, "...": 0}],
"meta": {"template": "...", "hybrid": null, "page_font": "...",
"language": "ar", "script": "arabic", "direction": "rtl",
"augmentation": null}
}
```
`meta.augmentation` is `null` for originals and
`{"name": ..., "params": {...}}` for augmented variants.