Skip to content

Sedighe-Raeisi/Object_Detection_Persian_Digit_Detection

Repository files navigation

Object Detection Persian Digit Detection

In this Persian project, I identify the Persian Digits in a given image. An example of the results of my project is below:
image

This repository consists of three parts.

1- A draft of the first, successful effort: You can ignore the draft, it was my first successful classifier. unfortunately, it wasn't saved in my personal space. Therefore, I missed it.
2- A classifier: classifier is a model that recognizes between the Persian digits and non-Persian digits. in the final part of this notebook, you can see a function that performs all the tasks automatically.
3- A function: I separated the function that can recognize between Persian digits objects in images and other objects. this function needs two paths, one belongs to the image and the other belongs to the classifier model.

Data:

In the first part, I made a dataset from the following data:

I copy all non-digit images to the same directory, and then I read them and after a preprocessing, I convert them to np-array.
Then, I concatenate the np-array of Persian digits and non-digit np-array.

Model

I made a binary CNN classifier. Then I trained it with my data for different epochs. I tested different bach-sizes: 32, 64, 128. The accuracy of the model on test data was .997. Here you can see the confusion matrix:
image

The plot of the accuracy of train data and validation data is bellow:
image
Then, I saved the model and downloaded it.

Persian Digit Recognizer Function:

I made a function to implement the model on the given image.

  • Firstly, this function receives the path of image and the path of classifier model I introduced it in the previous part.
  • Then, it read the image.
  • Afterward, I put a part in the function to preprocess images and detect objects in images.
  • I crop images from these objects.
  • I save the position of these objects for later use.
  • I load the classifier using the given path.
  • I give the cropped images of objects to the classifier after resizing them to the appropriate size of classier input.
  • I save the prediction of the classifier for the label of these objects.
  • I separate those objects labeled as Persian digits.
  • I add rectangle lines to the original image for those objects labeled as Persian digits on their position in the original image.
  • As an output, I show two images, on the left the images with objects labeled as Persian digits, and on the right the image with all recognized objects.

You can see an example of implementation of image:
image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published