/OCR_Hoda_dataset

OCR for Hoda farsi digit dataset

Primary LanguageJupyter NotebookMIT LicenseMIT

In the name of God

Hoda Dataset Classification

This repository contains Python code for reading Hoda farsi digit dataset.

Hoda Farsi Digit Dataset

Hoda dataset is the first dataset of handwritten Farsi digits that has been developed during an MSc. project in Tarbiat Modarres University entitled: Recognizing Farsi Digits and Characters in SANJESH Registration Forms. This project has been carried out in cooperation with Hoda System Corporation. It was finished in summer 2005 under supervision of Prof. Ehsanollah Kabir. Samples of the dataset are handwritten characters extracted from about 12000 registration forms of university entrance examination in Iran. The dataset specifications is as follows:

  • Resolution of samples: 200 dpi
  • Total samples: 102,352 samples
  • Training samples: 60,000 samples
  • Test samples: 20,000 samples
  • Remaining samples: 22,352 samples

Number of samples per each class:

  • 0: 10070
  • 1: 10330
  • 2: 9923
  • 3: 10334
  • 4: 10333
  • 5: 10110
  • 6: 10254
  • 7: 10363
  • 8: 10264
  • 9: 10371

For more information please refer to the paper: Introducing a very large dataset of handwritten Farsi digits and a study on their varieties

This dataset is free of charge for research purposes and non commercial uses only.

Dataset website: http://farsiocr.ir/

Dataset Samples

Samples with different writing styles in the dataset:

Samples with different writing styles in the dataset

Samples with different qualities in the dataset:

Samples with different qualities in the dataset

Reading Datasets

To read Hoda .cdb files as datasets (for example Train 60000.cdb), use the following code snippet:

from HodaDatasetReader import read_hoda_dataset

print('Reading train dataset (Train 60000.cdb)...')
X_train, Y_train = read_hoda_dataset(dataset_path='./DigitDB/Train 60000.cdb',
                                images_height=32,
                                images_width=32,
                                one_hot=False,
                                reshape=True)


print('Reading test dataset (Test 20000.cdb)...')
X_test, Y_test = read_hoda_dataset(dataset_path='./DigitDB/Test 20000.cdb',
                              images_height=32,
                              images_width=32,
                              one_hot=True,
                              reshape=False)


print('Reading remaining samples dataset (RemainingSamples.cdb)...')
X_remaining, Y_remaining = read_hoda_dataset('./DigitDB/RemainingSamples.cdb',
                                             images_height=32,
                                             images_width=32,
                                             one_hot=True,
                                             reshape=True)

Figure 2

Defining model

model = keras.Sequential()
model.add(keras.layers.Input(shape=x_train[0].shape))
model.add(keras.layers.Conv2D(filters=128, kernel_size=(5, 5), activation='relu'))
model.add(keras.layers.MaxPool2D())
model.add(keras.layers.Conv2D(filters=128, kernel_size=(5, 5), activation='relu'))
model.add(keras.layers.MaxPool2D())
model.add(keras.layers.Flatten())
model.add(keras.layers.Dense(units=120, activation='relu'))
model.add(keras.layers.Dense(units=84, activation='relu'))
model.add(keras.layers.Dense(units=num_classes, activation='softmax'))

model.summary()

Links