Skip to content

swagatobag2000/digit-recognition-webapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Forks Stargazers Contributors Issues MIT License


Logo

Handwritten Digit Recognition

Logo Logo

Android App (Click Android), Web Application (Click Windows) and Beyond

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Project Implementation
  3. License
  4. Acknowledgments

About The Project

Digit.Recog.mp4

Abstract

This project deals with the very popular learning process called Deep learning using Neural Networks. There are various ways by which one can achieve the goal to a desired output, but in machine learning Neural network gives a way that machine learns the way to reach the output by creating human brain like structures i.e. 'NEURONS'.

Overview

In this given project we were required to make a full-stack application backed by a Deep Learning Model to predict the handwritten digit.

Problem Definition

The goal was to create an appropriate model that can give the output of the handwritten character by drawing that character. This project has to be created by image processing and the machine learning. Both the techniques will be needed because these two techniques will enhance the technique of the machine learning and that can shape this project.

Purpose

Neural Network and Deep Learning are the trending topics for now. And this is a simple project for handwriting recognition. The extension of the project can be used in large scale to detect the written character from images and to extract them in no time.Or in banking signature recognition or in license plate verification, Real time image chaining or filtering or object detection etc.

Scope

This includes making an DL model, then making a beautiful UI, so that we could draw the digits, and with the help of the DL model, we can predict the handwritten character.

(back to top)


Project Implementation

DL - DATA ANALYSIS & MODELLING

The MNIST dataset (Modified National Institute of Standards and Technology) is used. It is widely used for training and testing in the field of machine learning. It was created by "re-mixing" the samples from NIST's original datasets. The black and white images from NIST were normalized to fit into a 28x28 pixel bounding box with grayscale color channel.

Built With

Machine Learning Stack Web Application Stack Mobile App
Python HTML5 Flutter
Pandas CSS3 Dart
NumPy JavaScript
scikit-learn jQuery
Keras Bootstrap
TensorFlow

(back to top)

Model Used

  • CNN is used.
  • [[Conv2D->relu]2 -> MaxPool2D -> Dropout]2 -> Flatten -> Dense -> Dropout -> Out
  • Optimizer : RMSprop -> Root Mean Squared Propagation
  • Loss Function : categorical_crossentropy -> Used in multi-class classification model
  • Learning Rate Annealer : ReduceLROnPlateau -> Reduce learning rate when a metric has stopped improving
  • Metric : accuracy
  • Model: "sequential"
Layer (type) Output Shape Param
conv2d (Conv2D) (None, 28, 28, 32) 832
conv2d_1 (Conv2D) (None, 28, 28, 32) 25632
max_pooling2d (MaxPooling2D) (None, 14, 14, 32) 0
dropout (Dropout) (None, 14, 14, 32) 0
conv2d_2 (Conv2D) (None, 14, 14, 64) 18496
conv2d_3 (Conv2D) (None, 14, 14, 64) 36928
max_pooling2d_1 (MaxPooling 2D) (None, 7, 7, 64) 0
dropout_1 (Dropout) (None, 7, 7, 64) 0
flatten (Flatten) (None, 3136) 0
dense (Dense) (None, 256) 803072
dropout_2 (Dropout) (None, 256) 0
dense_1 (Dense) (None, 10) 2570

Total params: 887,530

Trainable params: 887,530

Non-trainable params: 0


  • Time Elapsed: 00:05:12.63
  • Training Accuracy : 0.9887
  • Validation Accuracy : 0.991

(back to top)

Model With Data augmentation

In order to avoid overfitting problem, we need to expand artificially our handwritten digit dataset. We can make your existing dataset even larger. The idea is to alter the training data with small transformations to reproduce the variations occuring when someone is writing a digit.

datagen = ImageDataGenerator(
  featurewise_center=False,  # set input mean to 0 over the dataset
  samplewise_center=False,  # set each sample mean to 0
  featurewise_std_normalization=False,  # divide inputs by std of the dataset
  samplewise_std_normalization=False,  # divide each input by its std
  zca_whitening=False,  # apply ZCA whitening
  rotation_range=10,  # randomly rotate images in the range (degrees, 0 to 180)
  zoom_range = 0.1, # Randomly zoom image 
  width_shift_range=0.1,  # randomly shift images horizontally (fraction of total width)
  height_shift_range=0.1,  # randomly shift images vertically (fraction of total height)
  horizontal_flip=False,  # randomly flip images
  vertical_flip=False,  # randomly flip images
  fill_mode='nearest')
  • Time Elapsed: 00:15:11.24
  • Training Accuracy : 0.9850
  • Validation Accuracy : 0.991

Exporting Model

  • To save whole model configuration + weights
    model.save('digit_recognition.h5') 
  • To save the architecture of a model
    model_json = model.to_json()
    with open("digit_recognition_config.json","w") as json_file:
        json_file.write(model_json) 
  • To save model with .tflite extension
    converter = tf.lite.TFLiteConverter.from_keras_model(model)
    tflite_model = converter.convert()
    
    with open('digit_recognition.tflite', 'wb') as tfliteFile:
      tfliteFile.write(tflite_model)
  • To save model with tensorflowjs
    import tensorflowjs as tfjs
    tfjs.converters.save_keras_model(model,".")

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Acknowledgments

Well, this is the last part of this repository. Here are the list of links which helped me to build this whole project, the android one and the web one.

(back to top)