You need to agree to share your contact information to access this dataset

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this dataset content.

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 · PouriaMahdi84

Sentences

Paragraphs

Pages

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:

pip install datasets pillow

Load a single config:

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:

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):

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:

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

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:

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

@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

Downloads last month
996