| --- |
| license: cc-by-nd-4.0 |
| language: |
| - fa |
| task_categories: |
| - image-to-text |
| - text-to-image |
| tags: |
| - ocr |
| - synthetic |
| - persian |
| - farsi |
| - naskh |
| - document-ai |
| pretty_name: Persian Pixel |
| size_categories: |
| - 100K<n<1M |
| configs: |
| - config_name: sentence |
| data_files: |
| - split: train |
| path: data/sentence-*.parquet |
| - config_name: paragraph |
| data_files: |
| - split: train |
| path: data/paragraph-*.parquet |
| - config_name: page |
| data_files: |
| - split: train |
| path: data/page-*.parquet |
| - config_name: full |
| data_files: |
| - split: train |
| path: |
| - data/sentence-*.parquet |
| - data/paragraph-*.parquet |
| - data/page-*.parquet |
| --- |
| |
| # Persian Pixel |
|
|
| **Persian Pixel** is a synthetic optical character recognition (OCR) dataset for **Persian / Farsi (`fa`)**, in which Unicode text is rendered to images and paired with its exact transcription. It is built for OCR recognition, image-to-text modeling, fine-tuning, and evaluation workflows that need clean, controllable image/label pairs at scale. |
|
|
| Because the text is rendered programmatically, every image ships with a perfectly aligned ground-truth label — making the dataset well suited for pretraining, curriculum learning, and isolating model behavior before introducing noisy real-world scans. |
|
|
|
|
| **Authors:** [Haq Nawaz Malik](https://huggingface.co/Omarrran) · [PouriaMahdi84](https://huggingface.co/PouriaMahdi84) |
|
|
| ### Sentences |
|
|
| | | | | | |
| |---|---|---|---| |
| | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/DaUvNkGNwIg8WWN_p_8tI.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/tnB2Mm4szGrH9aXQR59rh.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/5hp_TrKyM2SRegVP_YNOq.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/adsv_GMKAN2ZmFG9BkjfM.png" width="220"> | |
| | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/NoCHc0RQqIO0GBtY3ihf6.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/TYo56JUOnxJWZCVpoiS8g.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/pog584pXTsNGxjakBrptL.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/XejD-RDT9L7PnFh71wBe3.png" width="220"> | |
| | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/osTMjKu8qLoh2HMRfLU04.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/xGZGOmqQ05H2OZXcSqL4d.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/sHSSLObetkLYqIhmRzpLu.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/VPp8wFA4whw_d1GZ-3CM9.png" width="220"> | |
|
|
|
|
|
|
| ### Paragraphs |
|
|
| | | | | | |
| |---|---|---|---| |
| | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/QjoEM3E1rax5WnMr898Qb.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/PT8lfxu2peI3D4VQp_ZNW.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/7E8X_GP5NXIP3Rgga-d-u.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/_8KY-hjAi2xk6Uq8x4odm.png" width="220"> | |
| | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/X9n14KHjWiIw4zWLJZrik.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/RMGuPbWlyO0zcMP1-LBz0.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/YuOPUx8uIazmwLcTx8ejU.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/1peSzR7out6Y_vdb_7F0r.png" width="220"> | |
| | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/5CB9Nw0UFXkJA8MwuUfsw.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/at_0aB7_HfOFJeSoXPaxC.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/MUwCrT-Ao_z936skgpU3-.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/nFUCpAmwPTYAOtH4WWC6D.png" width="220"> | |
|
|
|
|
|
|
|
|
| ### Pages |
|
|
| | | | | | |
| |---|---|---|---| |
| | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/KYeuz-Xr2oXVM5DXyPWRq.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/3J6adzWLvZktaNRO7oUp2.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/zf_2Shk-gRwkNk_cwQ_wS.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/0JVX6ZauIW8Zd4wLsrPgO.png" width="220"> | |
| | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/lhOSV90M4KldIYDxUREm2.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/gtvYQkgeg-bJ0_Gq3smnX.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/ZEysUBC0oTaXXVJE_pprk.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/C7Tm-hE_HuMbnnBsEzpjs.png" width="220"> | |
| | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/9h6agmJn5wZoIz8i_i0od.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/PeY29MfMKeafQ6Rabijuz.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/QWqGVo9Z-yL7na7_1eW6g.png" width="220"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/FAzH6OeSabiDKlEYhI9sd.png" width="220"> | |
|
|
|
|
| ## Dataset summary |
|
|
| | Property | Value | |
| |---|---| |
| | Language | Persian / Farsi (`fa`) | |
| | Script | Perso-Arabic | |
| | Modality | Image → Text (OCR) | |
| | Source | Synthetic (font-rendered) | |
| | Total rows (`full`) | 343,246 | |
| | License | CC BY-ND 4.0 | |
|
|
| ## Configurations and sizes |
|
|
| The dataset is organized by render granularity. Each granularity is exposed as its own config, plus a `full` config that virtually concatenates all three. |
|
|
| | Config | Description | Rows | Typical width | |
| |---|---|---:|---| |
| | `sentence` | Short line / sentence-level crops |251,000 | 640 px | |
| | `paragraph` | Multi-line paragraph blocks | 110,138 | 512 px | |
| | `page` | Page-level renders | 31,108 | 768 px | |
| | `full` | Concatenation of all three configs above | 343,246 | — | |
|
|
| Verified from Parquet shard metadata on **2026-06-25 05:34:30 UTC** (320 Parquet files, ~31.8 GB). |
|
|
| ### Page-config statistics |
|
|
| | Metric | Min | Max | Mean | |
| |---|---:|---:|---:| |
| | Height (px) | 38 | 1100 | 597.92 | |
| | Text length (chars) | 13 | 1896 | 824.22 | |
| | Line count | 2 | 75 | 7.88 | |
|
|
| ## Data fields |
|
|
| Every row shares the same schema across all configs: |
|
|
| | Field | Type | Description | |
| |---|---|---| |
| | `bytes` | `bytes` | Encoded image bytes | |
| | `path` | `string` | Image path/name stored with the image bytes | |
| | `text` | `string` | Exact Persian Unicode OCR target / transcription | |
| | `sample_type` | `string` | One of `sentence`, `paragraph`, or `page` | |
| | `source_run_id` | `string` | Internal generation / publish run identifier | |
| | `image_path` | `string` | Original relative image path | |
| | `width` | `int` | Rendered image width in pixels | |
| | `height` | `int` | Rendered image height in pixels | |
| | `text_chars` | `int` | Number of Unicode characters in `text` | |
| | `line_count` | `int` | Number of text lines in the label | |
|
|
| ## Usage |
|
|
| Install the dependency: |
|
|
| ```bash |
| pip install datasets pillow |
| ``` |
|
|
| Load a single config: |
|
|
| ```python |
| from datasets import load_dataset |
| |
| train = load_dataset("Omarrran/Persian_Pixel", "sentence", split="train") # or "paragraph" / "page" |
| |
| print(train.column_names) |
| print(train[0]["text"]) |
| ``` |
|
|
| Load the combined config: |
|
|
| ```python |
| from datasets import load_dataset |
| |
| full = load_dataset("Omarrran/Persian_Pixel", "full", split="train") |
| print(len(full)) # 343246 |
| ``` |
|
|
| Stream a config (recommended for the heavier `paragraph` / `page` renders): |
|
|
| ```python |
| from datasets import load_dataset |
| |
| ds = load_dataset( |
| "Omarrran/Persian_Pixel", |
| name="page", |
| split="train", |
| streaming=True, |
| ) |
| |
| for sample in ds: |
| txt = sample["text"] |
| # feed into OCR preprocessing / tokenizer pipeline |
| ``` |
|
|
| If your loader sees raw `bytes` and `path` columns rather than a decoded `image` object, reconstruct a PIL image: |
|
|
| ```python |
| from io import BytesIO |
| from PIL import Image |
| |
| row = train[0] |
| img = Image.open(BytesIO(row["bytes"])) |
| print(img.size, row["text"]) |
| ``` |
|
|
| ### Loading each config |
|
|
| ```python |
| from datasets import load_dataset |
| |
| sentence = load_dataset("Omarrran/Persian_Pixel", "sentence", split="train") |
| paragraph = load_dataset("Omarrran/Persian_Pixel", "paragraph", split="train") |
| page = load_dataset("Omarrran/Persian_Pixel", "page", split="train") |
| full = load_dataset("Omarrran/Persian_Pixel", "full", split="train") |
| ``` |
|
|
| ## Recommended training split strategy |
|
|
| The repo publishes data as `train` shards. For model development, create your own deterministic split: |
|
|
| ```python |
| ds = load_dataset("Omarrran/Persian_Pixel", "sentence", split="train") |
| split = ds.train_test_split(test_size=0.02, seed=42) |
| train_ds, val_ds = split["train"], split["test"] |
| ``` |
|
|
| For page-level OCR, keep validation smaller and representative because page images are much heavier than sentence crops. |
|
|
| ## Recommended use cases |
|
|
| - Fine-tuning image-to-text and OCR models such as TrOCR, Donut, BLIP-2, and PaliGemma-style decoders. |
| - Pretraining or curriculum stages before introducing noisy scanned or photographed OCR corpora. |
| - Evaluating normalization, decoding, and post-correction pipelines on Perso-Arabic script. |
| - Benchmarking Persian text recognition under controlled synthetic conditions and variable line counts. |
|
|
| ## Limitations and considerations |
|
|
| - This is **synthetic** OCR data. Performance on font-rendered text does not guarantee performance on real scans, photographs, or handwriting — validate on in-domain data before any production deployment. |
| - Synthetic rendering can introduce artifacts, unusual line wrapping, punctuation variation, or source-text noise. |
| - The `paragraph` and `page` configs contain long, multi-line labels and large images; always consume them through the `datasets` library rather than raw parsing. |
|
|
| ## License |
|
|
| Released under **Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0)**. You may copy and redistribute the dataset for any purpose with attribution, but you may not distribute modified versions. |
|
|
| ## Citation |
|
|
| ```bibtex |
| @dataset{persian_pixel_2026, |
| title = {Persian Pixel: A Synthetic OCR Dataset for Persian/Farsi}, |
| author = { Haq Nawaz Malik, Pouria Mahdi}, |
| year = {2026}, |
| publisher = {Hugging Face}, |
| url = {https://huggingface.co/datasets/Omarrran/Persian_Pixel} |
| } |
| ``` |
| ## Repository |
|
|
| - Dataset repo: https://huggingface.co/datasets/Omarrran/Persian_Pixel |
| - Format: Parquet shards |
| - Primary task: Persian OCR / image-to-text |