Skip to content

Persian Pixel: A large-scale synthetic OCR dataset for Persian language

Source: arXiv:2607.20385 · Published 2026-07-22 · By Pouria Mahdi, Haq Nawaz Malik

TL;DR

This paper addresses the chronic scarcity of large-scale annotated datasets for Persian OCR—a low-resource, highly complex script used by over 110 million speakers. Persian OCR is challenged by the script's obligatory cursive joining, context-dependent glyph shapes, diacritics, ligatures, and dual calligraphic styles (Naskh and Nastaliq), which complicate character segmentation and recognition. Additionally, manual data annotation is prohibitively expensive for such visually intricate text, creating a persistent data bottleneck that limits progress. To overcome this, the authors introduce Persian Pixel: a large-scale, open synthetic OCR dataset of over 343,000 image-text pairs generated from a carefully curated 7-million-word Persian corpus using the SynthOCR-Gen rendering engine. Crucially, the synthetic generation pipeline models Persian script shaping, bidirectional layout, multiple fonts (including Nastaliq), and realistic document degradation through 25+ stochastic augmentations, bridging the gap to real-world scans.

The dataset spans sentence, paragraph, and page levels, providing diverse granularity for fine-tuning modern transformer-based OCR models such as TrOCR and Donut. The authors detail methodology for corpus curation, shaping-aware rendering, multi-font synthesis, and complex degradation to produce typographically faithful and visually diverse data. They demonstrate Persian Pixel’s potential to break the Persian OCR data deadlock by supplying scalable, richly annotated training data that prior real collections lacked. The dataset is openly released to accelerate development in Persian document digitization and related NLP workflows.

Key findings

  • The Persian Pixel dataset contains over 343,000 unique image–text pairs spanning sentence (251,000), paragraph (110,138), and page (31,108) granularities.
  • The underlying text corpus includes over 7 million words sourced from diverse, openly licensed web domains covering encyclopedic, literary, news, administrative, social media, and historical Persian registers.
  • SynthOCR-Gen's shaping-aware rendering faithfully resolves context-dependent glyph forms, ligatures like Lam-Aleph, diacritics, Nastaliq's sloping baseline and vertical stacking, and applies the Unicode Bidirectional Algorithm.
  • Seven Persian typefaces were used spanning modern Naskh (Vazirmatn, Sahel, Shabnam), classical Naskh (Amiri), Nastaliq (IranNastaliq), and two display fonts to maximize typographic diversity.
  • More than twenty-five stochastic degradation operators simulate realistic document artifacts, including ink bleed, paper aging, blur, illumination variation, scanner imperfections, noise types, and geometric distortions.
  • The resulting dataset yields nearly infinite visual variety, forcing OCR models toward font- and degradation-invariant features necessary for robust generalization.
  • No exact quantitative evaluation is reported in the paper, but the dataset is demonstrated as ready for fine-tuning transformer OCR models like TrOCR and Donut to improve Persian OCR performance in practice.
  • The dataset covers mixed-direction bidirectional text and includes noisy realistic scanning artifacts, addressing common failure modes in Persian OCR pipelines.

Threat model

Not applicable as a security paper. The work addresses the challenge of data scarcity in Persian OCR for benign document digitization tasks. Implicitly, the dataset enables OCR models to robustly handle noise and degradation typical of real-world scanning conditions, but adversarial or malicious manipulation scenarios are not considered.

Methodology — deep read

  1. Threat Model & Assumptions: The dataset is designed for training OCR models to recognize printed Persian text. The adversary is implicit as real-world document and imaging noise that confounds recognition. The authors assume availability of a diverse Persian text corpus to synthesize realistic ground truth. The focus is on generating faithful printed text renderings capturing Persian script complexity rather than on adversarial attacks.

  2. Data: A corpus of over 7 million Persian words was assembled from open-licensed web sources representing multiple domains: encyclopedic prose, classical and modern literature, news articles, government texts, social media posts, and digitized historical documents. The corpus was cleaned thoroughly — fixing encoding errors, stripping markup, removing personal data, enforcing script purity for Perso-Arabic characters, normalizing Unicode, standardizing whitespace, and removing duplicates and extremes in length. This curation ensured broad linguistic and orthographic diversity.

  3. Architecture/Algorithm: The SynthOCR-Gen rendering engine transforms Unicode Persian text into images by applying a full shaping stack that handles:

  • Selecting isolated, initial, medial, and final glyph variants based on context
  • Replacing character sequences with ligatures such as Lam-Aleph
  • Placing diacritics (harakat) accurately
  • Applying Nastaliq-style sloping baselines and vertical stacking
  • Executing the Unicode Bidirectional Algorithm to visually reorder mixed RTL and LTR text runs The engine rasterizes the shaped glyphs using seven different Persian fonts spanning Naskh and Nastaliq styles.

Formally, the input is a Unicode text string; the output is a pixel image with pixel-aligned ground truth text, along with metadata specifying granularity (sentence, paragraph, page), font, and size.

  1. Training Regime: While no training blueprint is fixed, the dataset is intended for fine-tuning large OCR models like TrOCR or Donut in various downstream tasks. Users can adopt curriculum learning by progressing from clean to progressively degraded synthetic images. Batch size, epochs, and hyperparameters depend on user setups; authors highlight the compute barrier for training on hundreds of thousands of images but propose parameter-efficient models or managed platforms.

  2. Evaluation Protocol: The paper does not report numerical OCR model benchmarks directly. Instead, it emphasizes dataset diversity and coverage as key contributions. Evaluation metrics from prior OCR literature (character error rate, word error rate) would be standard when benchmarking models fine-tuned on Persian Pixel. No explicit cross-validation or adversarial evaluation reported.

  3. Reproducibility: The dataset and code for the SynthOCR-Gen pipeline are publicly released on Hugging Face under open licenses. The dataset includes structured metadata for every image-text pair supporting supervised training and analysis. Seven fonts used are openly licensed.

Concrete Example: A sentence from the corpus is normalized and passed to SynthOCR-Gen, which applies shaping to select correct Persian glyph forms and ligatures, then renders it into an image using the IranNastaliq font. The rendered image is then randomly degraded with blur, noise, ink bleed, and perspective warp. The resulting image-text pair includes ground-truth Unicode text. This sample can then be fed to a transformer OCR model for supervised learning, helping it generalize to Nastaliq style and noisy real-world conditions.

Overall, the methodology carefully integrates linguistic corpus construction, shaping and rendering faithful to Persian script complexity, and diversifying visual appearance via rich augmentations. This multi-stage pipeline addresses long-standing barriers in Persian OCR data scarcity.

Technical innovations

  • The first large-scale, multi-granularity synthetic Persian OCR dataset explicitly modeling unique Perso-Arabic script features such as contextual glyph shaping, ligatures, and diacritic placement.
  • A novel seven-font rendering strategy covering both modern Naskh and complex Nastaliq calligraphic styles, enabling robust cross-style OCR training.
  • Incorporation of more than twenty-five stochastic degradation operators simulating realistic Persian document capture artifacts to minimize synthetic-real domain gap.
  • Use of a shaping-aware rendering pipeline (SynthOCR-Gen) that fully implements the Unicode Bidirectional Algorithm ensuring alignment of visual layout and ground truth in mixed RTL/LTR Persian text.

Datasets

  • Persian Pixel — 343,246 image-text pairs — publicly released on Hugging Face (https://huggingface.co/datasets/Omarrran/Persian_Pixel)
  • Persian text corpus — over 7 million words — compiled from open-licensed web sources, publicly referenced but exact dataset locations vary

Figures from the paper

Figures are reproduced from the source paper for academic discussion. Original copyright: the paper authors. See arXiv:2607.20385.

Fig 1

Fig 1: Representative sentence-level samples from Persian Pixel, demonstrating varied fonts and subtle augmentations

Fig 2

Fig 2: Representative paragraph-level samples from Persian Pixel, illustrating multi-line text with varying layouts and

Fig 3

Fig 3: Representative page-level samples from Persian Pixel, showcasing full-page documents with complex layouts,

Fig 4

Fig 4 (page 8).

Fig 5

Fig 5 (page 8).

Fig 6

Fig 6 (page 8).

Fig 7

Fig 7 (page 8).

Fig 8

Fig 8 (page 9).

Limitations

  • Limited to printed, digitally rendered Persian text; handwriting recognition is outside the dataset’s scope.
  • Font coverage, though improved, is limited to seven openly licensed Persian typefaces; large stylistic variations in historical or ornamental calligraphy remain underrepresented.
  • While paragraph and page layouts are supported, complex non-linear or marginalia layouts common in historical documents are not modeled.
  • No reported quantitative OCR benchmarks or results on model performance fine-tuned with the dataset, leaving actual accuracy gains unspecified.
  • The dataset does not explicitly address OCR robustness under adversarial attacks or extreme domain shifts beyond synthetic degradation.
  • Computational cost for training on the full dataset with large transformer models may be prohibitive for smaller research groups.

Open questions / follow-ons

  • How effective is Persian Pixel in quantitatively improving OCR accuracy on real-world Persian print and historical documents compared to existing datasets?
  • Can generative handwriting synthesis techniques be adapted to extend this synthetic data strategy into the Persian handwritten OCR domain?
  • How can layout-aware synthetic generation be enhanced to accurately replicate the complex, non-linear arrangements found in many historical Persian manuscripts?
  • What methods can enable computationally efficient training or fine-tuning of large transformer OCR models on Persian Pixel for resource-constrained settings?

Why it matters for bot defense

Persian Pixel provides an essential large-scale data resource enabling OCR recognition of Persian script, which has direct implications for bot-defense systems needing to parse Persian textual CAPTCHA challenges or analyze Persian document images. Its explicit modeling of script shaping, ligatures, and diacritics is critical for any OCR pipeline processing Persian text, reducing error rates when extracting textual data. The inclusion of diverse fonts and realistic image degradation increases robustness against noisy inputs typical in adversarial or automated attack settings. Furthermore, the dataset’s multi-granularity structure supports both line-level recognition and full-document understanding architectures, which can aid in improving CAPTCHA solvers or bot-detection systems reliant on text extraction from Persian content. However, limitations include its focus on printed text rather than handwritten or complex layouts, indicating that further dataset expansion would be needed for full coverage in security-critical OCR applications.

Cite

bibtex
@article{arxiv2607_20385,
  title={ Persian Pixel: A large-scale synthetic OCR dataset for Persian language },
  author={ Pouria Mahdi and Haq Nawaz Malik },
  journal={arXiv preprint arXiv:2607.20385},
  year={ 2026 },
  url={https://arxiv.org/abs/2607.20385}
}

Read the full paper

Articles are CC BY 4.0 — feel free to quote with attribution