AliShafiee2003's picture
Update README.md
36bfdcd verified
metadata
dataset_info:
  features:
    - name: image
      dtype: image
    - name: text
      dtype: string
    - name: style
      dtype: string
  splits:
    - name: train
      num_bytes: 12777680156
      num_examples: 1300000
    - name: noisy_Bg
      num_bytes: 564270458
      num_examples: 100000
    - name: parabolic_text
      num_bytes: 964652903
      num_examples: 100000
    - name: parabolic_text_blur
      num_bytes: 1036157860
      num_examples: 100000
    - name: parabolic_text_shadow
      num_bytes: 1164050759
      num_examples: 100000
    - name: plain_text
      num_bytes: 481267597
      num_examples: 100000
    - name: plain_text_blur
      num_bytes: 691000068
      num_examples: 100000
    - name: plain_text_complex_bg
      num_bytes: 3899110442
      num_examples: 100000
    - name: plain_text_darkness
      num_bytes: 347759418
      num_examples: 100000
    - name: plain_text_shadow
      num_bytes: 818234147
      num_examples: 100000
    - name: sine_text
      num_bytes: 325560397
      num_examples: 100000
    - name: sine_text_blur
      num_bytes: 1081370287
      num_examples: 100000
    - name: sine_text_darkness
      num_bytes: 1277542234
      num_examples: 100000
    - name: white_noise
      num_bytes: 471704986
      num_examples: 100000
  download_size: 25905171625
  dataset_size: 25900361712
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*
      - split: noisy_Bg
        path: data/noisy_Bg-*
      - split: parabolic_text
        path: data/parabolic_text-*
      - split: parabolic_text_blur
        path: data/parabolic_text_blur-*
      - split: parabolic_text_shadow
        path: data/parabolic_text_shadow-*
      - split: plain_text
        path: data/plain_text-*
      - split: plain_text_blur
        path: data/plain_text_blur-*
      - split: plain_text_complex_bg
        path: data/plain_text_complex_bg-*
      - split: plain_text_darkness
        path: data/plain_text_darkness-*
      - split: plain_text_shadow
        path: data/plain_text_shadow-*
      - split: sine_text
        path: data/sine_text-*
      - split: sine_text_blur
        path: data/sine_text_blur-*
      - split: sine_text_darkness
        path: data/sine_text_darkness-*
      - split: white_noise
        path: data/white_noise-*
license: cc-by-4.0
task_categories:
  - image-to-text
language:
  - fa
  - ar
tags:
  - OCR
  - optical-character-recognition
  - text-recognition
  - image-to-text
  - persian
  - farsi
  - persian-ocr
  - synthetic
  - computer-vision
  - deep-learning
  - persian-OCR
pretty_name: 'Garshasp-70C: Persian Synthetic OCR Dataset'
size_categories:
  - 1M<n<10M

Persian OCR Garshasp: Large-Scale Synthetic Persian OCR Dataset

Persian-OCR-Garshasp is a large-scale Persian (Farsi) OCR dataset containing about 2.6M image–text pairs. It is designed for training and evaluating Optical Character Recognition (OCR) and scene text recognition models for Persian text in the wild.

Each sample consists of:

  • an RGB image with height 48 px and width 640 px
  • up to 70 Persian (Farsi) characters as the ground-truth text label
  • a style field describing the rendering / distortion style (e.g. plain_text, sine_text, parabolic_text, white_noise, *_blur, *_shadow, *_darkness, plain_text_complex_bg, noisy_Bg)

The dataset is fully synthetic: all images are generated programmatically from Persian text using multiple fonts, styles, geometric distortions and noisy backgrounds in order to approximate real-world Persian OCR scenarios (screenshots, signs, documents, noisy photos, etc.) as closely as possible.


Dataset summary

  • Name: Persian OCR Garshasp
  • Author: AliShafiee2003
  • Language: Persian (Farsi)
  • Script: Persian (Arabic-based) script
  • Primary task: Image-to-Text / Optical Character Recognition (OCR)
  • Secondary tasks:
    • Scene text recognition
    • Document text recognition
  • Modality: Image → Text
  • Total size: ~2.6M image–text pairs (14 splits)
  • Image resolution: 48 × 640 (height × width), RGB
  • Max text length: 70 characters per image
  • Number of styles: 13 rendering / distortion styles
  • Recommended usages:
    • Training Persian / Farsi OCR models
    • Pretraining on synthetic data before fine-tuning on real-world images
    • Robustness experiments to geometric distortions, blur, noise and complex backgrounds

Data fields

Each row has the following fields:

Field Type Description
image Image RGB image, height 48 px, width 640 px, containing Persian text
text string Ground-truth Persian (Farsi) text (up to 70 characters)
style string Rendering / distortion style (one of 13 possible values)

Example style values (non-exhaustive):

  • plain_text
  • plain_text_blur
  • plain_text_shadow
  • plain_text_darkness
  • plain_text_complex_bg
  • sine_text
  • sine_text_blur
  • sine_text_darkness
  • parabolic_text
  • parabolic_text_blur
  • parabolic_text_shadow
  • white_noise
  • noisy_Bg

Splits

The dataset is organized into one large split plus several style-specific splits:

  • train – 1.3M rows (main training split)
  • noisy_Bg – 100k rows
  • parabolic_text – 100k rows
  • parabolic_text_blur – 100k rows
  • parabolic_text_shadow – 100k rows
  • plain_text – 100k rows
  • plain_text_blur – 100k rows
  • plain_text_complex_bg – 100k rows
  • plain_text_darkness – 100k rows
  • plain_text_shadow – 100k rows
  • sine_text – 100k rows
  • sine_text_blur – 100k rows
  • sine_text_darkness – 100k rows
  • white_noise – 100k rows

You can:

  • use only the train split for large-scale training, or
  • build your own mixtures from style-specific splits to control the distribution of distortions / backgrounds.

Data source & generation

Text

  • Text length:
    • Each sample contains at most 70 characters.
  • Preprocessing (recommended, if applicable):
    • Normalization of Persian characters (e.g. unify ی/ي and ک/ك, remove zero-width characters, etc.).
    • Removal of control characters and very short / empty strings.
    • Optional filtering of non-Persian content (numbers, English tokens, etc.).

Please fill in the exact details of your preprocessing so others can better understand and reproduce the pipeline.

Fonts

The Persian text is rendered using 82 fonts from 18 font families, including:

  1. Arial
  2. B Homa
  3. B Lotus
  4. B Mitra
  5. B Tir
  6. B Traffic
  7. B Yagut
  8. B Zar
  9. B Nazanin
  10. Calibri
  11. Dubai
  12. Estedad
  13. Far Farnaz
  14. IRANSans
  15. Sahel
  16. Shabnam
  17. Tahoma
  18. Vazir / Vazirmatn

(Several weights and variants of these families are used to reach a total of 82 fonts.)

Rendering

  • All images are rendered as RGB with fixed size 48×640 (height × width).

  • Text is laid out to fit within the 640-pixel width, with at most 70 characters per image.

  • Different styles control geometric distortion and background / noise:

    • Geometric distortions

      • sine_text: sinusoidal warping of text baselines
      • parabolic_text: parabolic / curved baselines and perspective-like distortion
    • Photometric / noise effects

      • Blur (*_blur)
      • Dark / low-light (*_darkness)
      • Shadows (*_shadow)
      • Complex backgrounds (plain_text_complex_bg)
      • White noise and noisy backgrounds (white_noise, noisy_Bg)

Synthetic nature

This dataset is fully synthetic:

  • Persian text is sampled from a corpus and rendered with multiple fonts.
  • Distortions and augmentations simulate conditions such as:
    • screenshots and UI text
    • signs, banners, boards
    • noisy / low-quality photos
    • documents with various backgrounds

Although synthetic, the pipeline is designed to approximate real-world Persian OCR as much as possible.


Usage

Load with 🤗 Datasets

from datasets import load_dataset

dataset = load_dataset("AliShafiee2003/persian-ocr-garshasp", split="train")

example = dataset[0]
image = example["image"]   # PIL.Image.Image (48x640, RGB)
text = example["text"]     # str (Persian)
style = example["style"]   # str

Streaming (recommended for full dataset)

from datasets import load_dataset

streaming_dataset = load_dataset(
    "AliShafiee2003/persian-ocr-garshasp",
    split="train",
    streaming=True,
)

for example in streaming_dataset:
    image = example["image"]
    text = example["text"]
    style = example["style"]
    # training loop here

PyTorch example

from datasets import load_dataset
from torch.utils.data import DataLoader
from torchvision import transforms

dataset = load_dataset(
    "AliShafiee2003/persian-ocr-garshasp",
    split="train",
)

transform = transforms.Compose([
    transforms.ToTensor(),
])

def collate_fn(batch):
    images = [transform(x["image"]) for x in batch]
    texts = [x["text"] for x in batch]
    styles = [x["style"] for x in batch]
    return {
        "pixel_values": images,
        "labels": texts,
        "styles": styles,
    }

dataloader = DataLoader(
    dataset,
    batch_size=32,
    shuffle=True,
    collate_fn=collate_fn,
)

Intended uses

Recommended use-cases:

  • Training and evaluation of OCR models for Persian (Farsi).

  • Pretraining scene text recognition models on synthetic data before fine-tuning on:

    • real scanned documents,
    • mobile photos of text,
    • screenshots / UI text.
  • Robustness studies under:

    • geometric distortions (sine / parabolic),
    • blur and shadows,
    • noisy and complex backgrounds,
    • low-light conditions.

Not recommended for:

  • Handwritten text recognition (this dataset focuses on printed text).
  • Pure NLP / language modeling tasks (the text is primarily used as labels for images).

License

This dataset is released under the Creative Commons Attribution 4.0 International (CC BY 4.0) license.

You are free to:

  • Share — copy and redistribute the material in any medium or format
  • Adapt — remix, transform, and build upon the material for any purpose, even commercially

Under the following terms:

  • Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

For more details, see the full license text:
https://creativecommons.org/licenses/by/4.0/


Citation

If you use Persian OCR Garshasp in your research or product, please cite:

@misc{persian_ocr_garshasp,
  title        = {Persian OCR Garshasp: Large-Scale Synthetic OCR Dataset for Persian (Farsi)},
  author       = {Shafiee, Ali},
  year         = {2025},
  howpublished = {\url{https://huggingface.co/datasets/AliShafiee2003/persian-ocr-garshasp-70c}},
  note         = {Version 1.0},
}

(Feel free to adjust the author list, year, and version to match your preferred citation.)


خلاصه فارسی

Persian-OCR-Garshasp یک دیتاست بزرگ برای OCR فارسی است که حدود ۲.۶ میلیون جفت تصویر–متن دارد. هر نمونه شامل یک تصویر رنگی با سایز ۴۸×۶۴۰ پیکسل و متن فارسی (حداکثر ۷۰ کاراکتر) به‌عنوان برچسب است.

متن‌ها با استفاده از ۸۲ فونت از ۱۸ خانواده‌ی مختلف (مثل B Nazanin، B Zar، IRANSans، Sahel، Shabnam، Vazir/Vazirmatn و …) رندر شده‌اند و روی آن‌ها انواع اعوجاج‌های هندسی (sine، parabolic) و نویزها (تاری، سایه، پس‌زمینه پیچیده، نویز سفید و …) اعمال شده است.

این دیتاست کاملا مصنوعی است، اما سعی شده تا حد امکان به شرایط واقعی متن فارسی در تصاویر نزدیک باشد (اسکرین‌شات، تابلو، پوستر، عکس‌های نویزی، اسکن اسناد و غیره). از این دیتاست می‌توان برای آموزش و ارزیابی مدل‌های تشخیص متن فارسی، و همین‌طور پیش‌آموزش مدل‌ها قبل از فاین‌تیون روی دیتای واقعی استفاده کرد.

این دیتاست تحت لایسنس CC BY 4.0 منتشر شده است. یعنی.


Keywords (for search & discoverability)

persian ocr, farsi ocr, persian text recognition, farsi text recognition, persian scene text, persian document text, arabic script ocr, persian dataset, farsi dataset, synthetic ocr dataset, image to text, scene text recognition, document text recognition, persian news text, persian image text pairs, 48x640 images, noisy text images, sine text, parabolic text, white noise, shadow, blur, dark images, complex background, persian computer vision, persian deep learning