Skip to content

A Deep Convolutional Approach Toward Farsi Character Recognition. Used for both machine printed and handwritten datasets

Notifications You must be signed in to change notification settings

JavadMokhtari/DeepConvFarsiOCR

 
 

Repository files navigation

DeepConvFarsiOCR

Implementation of A Deep Convolutional Approach Toward Farsi Character Recognition in Python.
Used for both machine printed and handwritten datasets.

Papers

Usage

Step 1: Data

  • Download all images from this link and extract them.

  • Execute Convert_to_PNG.py with the following parameters:

python Convert_to_PNG.py --images_dir 'PATH-TO-IMAGES-FOLDER' --dir_to_save 'PATH-TO-NEW-DIRECTORY'

Like the following command:

python Convert_to_PNG.py --images_dir 'PDB-Train/' --dir_to_save 'Train-Data/'
  • Run this command for both PDB-Train and PDB-Test folders. This will:
    • Convert all downloaded bpm images into png and store them in the new directory.
    • extract labels from file names and store images of each class in a separate directory.

Step 2: Train

  • There are two models PersianOCR.Plain.v1.py and PersianOCR.v2.py. Run one of them with the following parameters:
python OCR-MODEL-FILE.py --train_data_dir 'PATH-TO-CLASSIFIED-TRAIN-DATA' --epochs NO-EPOCHS --model_storage_dir 'PATH-FOR-SAVE-MODEL'

Example:

python PersianOCR.Plain.v1.py --train_data_dir 'Train-Data/' --epochs 10 --model_storage_dir 'models/'
  • The --epochs and --model_storage_dir arguments are optional but --train_data_dir is required.
  • The data directory should include all classes in a distinct folders.

Step 3: Predict

  • Run Predict.py module like the below command:
python Predict.py --img_dir 'PATH-TO-AN-IMAGE' --saved_model_dir 'PATH-TO-A-SAVED-MODEL'

Example:

python Predict.py --img_dir 'Test-Data/0/100_0.png' --saved_model_dir 'models/ocr_model_v1.h5'

Thanks for your attention ♥

About

A Deep Convolutional Approach Toward Farsi Character Recognition. Used for both machine printed and handwritten datasets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 90.4%
  • Python 9.6%