Skip to content

siddhi-droid/MNIST-on-Android-with-TensorflowLite-and-OpenCV

 
 

Repository files navigation

MNIST-on-Android-with-TensorflowLite-and-OpenCV

Download APK

Apk can be found in apk folder, download and install the apk.

Inorder to recognize hand written digits, Deep learning model was trained. I used tensorflow's offical MNIST model and MNIST data set to train the Model.

Implemention

I converted the frozen model to mnist.tflite (optimized tensorflow lite model for mobile devices) Here is the mnist.tfile file.

On Android, recognizing hand written digits in image or camera feed is challenging. An Image with hand written digit feed directly (downscaled image of model input size) to well trained deep learning model to predict the written digits, But this won't work well!. Because the deep learning model was well trained on clean and prepocessed dataset, but Image with hand written digit taken from camera is not clean (contains noise) and not preprocessed!

Before feeding Image taken by the camera to Model, Image was preprocessed. I used OpenCV for Android for preprocessing on Image or Frames.

Preprocessing steps:

  1. converting color image/frame to grayscale

  2. crop the center region of image/frame

  3. blur the frame (to remove noise)

  4. Apply Adapative thresolding (convering to binary image)

  5. Apply Image morphological operations (dilation and erosion)

  6. Down scale the cropped image to Model Input size

After the prepocessing, Down scaled image(which is OpenCV Mat) is converted to tensorflow lite input format.

Note: Make sure that written digits are large and fits the middle square region shown in the app.

Below shows screenshots from the App.

screenshot0

screenshot1

screenshot2

screenshot3

screenshot4

screenshot5

screenshot6

screenshot7

screenshot8

screenshot9

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%