100% found this document useful (1 vote)
717 views15 pages

On Handwritten Digit Recognition

This document describes building a handwritten digit recognition model using a convolutional neural network in Python. It discusses pre-processing the MNIST dataset, creating and training a CNN model, evaluating the model's accuracy on test data, and creating a GUI to allow users to draw digits and have them classified by the model. The project achieves around 99% accuracy on the balanced MNIST dataset.

Uploaded by

Ankit Upadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
717 views15 pages

On Handwritten Digit Recognition

This document describes building a handwritten digit recognition model using a convolutional neural network in Python. It discusses pre-processing the MNIST dataset, creating and training a CNN model, evaluating the model's accuracy on test data, and creating a GUI to allow users to draw digits and have them classified by the model. The project achieves around 99% accuracy on the balanced MNIST dataset.

Uploaded by

Ankit Upadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

STREAM SEMINAR

(EEM609)
HANDWRITTEN
DIGIT RECOGNITION
USING PYTHON
By-
Ankit Upadhyay (1804828)
Anuj Baghel (1804830)
Anuj Goyal (1804831)
B.Tech Mechanical 3rd year (CS)
INTRODUCTION
 The handwritten digit recognition is the
ability of computers to recognize human
handwritten digits. It is a hard task for the
machine because handwritten digits are
not perfect and can be made with many
different flavors. The handwritten digit
recognition is the solution to this problem
which uses the image of a digit and
recognizes the digit present in the image.
LIBRARIES REQUIRED

 Make sure that the following libraries are


installed on your working machine before
proceeding further
 Keras
 Tensorflow
 OpenCV
 Sklearn
 Numpy
CONVOLUTION NEURAL
NETWORK
 A Convolution Neural Network or CNN is a
Deep Learning Algorithm which is very
effective in handling image classification tasks.
It is able to capture the Temporal and Spatial
dependencies in an image with the help of filters
or kernels.
 The kernel is just like a small window sliding
over the large window in order to extract the
spatial features and in the end, we get feature
maps.
CNN (CONT..)
 CNN contains 3 layers namely, an input layer, an
output layer, and multiple hidden layers which
include Convolutional layers, Pooling layers
(Max and Average pooling), Fully connected
layers (FC), and normalization layers. CNN uses
a filter (kernel) which is an array of weights to
extract features from the input image. CNN
employs different activation functions at each
layer to add some non-linearity.
THE MNIST DATASET

 This is probably one of the most popular datasets


among machine learning and deep learning
enthusiasts. The MNIST dataset contains 60,000
training images of handwritten digits from zero
to nine and 10,000 images for testing. So, the
MNIST dataset has 10 different classes. The
handwritten digits images are represented as a
28×28 matrix where each cell contains grayscale
pixel value.
IMPLEMENTATION
 Algorithm for handwritten digit recognition generally
comprise of three stages.
 Step1Pre-processing.This progression should eliminate
immaterial information and information that could have
negative impact on acknowledgement. Common steps in this
fluster are binarisation, standardisation,smoothing,denoising
 Step 2 Feature extraction. Feature extraction involves
reducing the number of resources required to describe a
large set of data.
 Step 3 Classification. Classification is a process related to
categorization, the process in which ideas and objects are
recognized, differentiated and understood.
IMPORT THE LIBRARIES
AND LOAD THE DATASET
 First,
we are going to import all the
modules that we are going to need for
training our model. The Keras library
already contains some datasets and
MNIST is one of them. So we can easily
import the dataset and start working with
it. The mnist.load_data() method returns
us the training data, its labels and also the
testing data and its labels.
PREPROCESS THE DATA
 The image data cannot be fed directly into
the model so we need to perform some
operations and process the data to make
it ready for our neural network. The
dimension of the training data is
(60000,28,28). The CNN model will
require one more dimension so we reshape
the matrix to shape (60000,28,28,1).
CREATE THE MODEL
 Now we will create our CNN model in Python
data science project. A CNN model generally
consists of convolutional and pooling layers. It
works better for data that are represented as grid
structures, this is the reason why CNN works
well for image classification problems. The
dropout layer is used to deactivate some of the
neurons and while training, it reduces offer
fitting of the model. We will then compile the
model with the Adadelta optimizer.
TRAIN THE MODEL
 The model.fit() function of Keras will
start the training of the model. It takes the
training data, validation data, epochs,
and batch size.
 It takes some time to train the model. After
training, we save the weights and model
definition in the ‘mnist.h5’ file.
EVALUATE THE MODEL
 We have 10,000 images in our dataset
which will be used to evaluate how good
our model works. The testing data was
not involved in the training of the data
therefore, it is new data for our model.
The MNIST dataset is well balanced so we
can get around 99% accuracy.
CREATE GUI TO PREDICT
DIGITS
 Now for the GUI, we have created a new file in which
we build an interactive window to draw digits on
canvas and with a button, we can recognize the digit.
The Tkinter library comes in the Python standard library.
We have created a function predict_digit() that takes the
image as input and then uses the trained model to predict
the digit.
 Then we create the App class which is responsible for
building the GUI for our app. We create a canvas where
we can draw by capturing the mouse event and with a
button, we trigger the predict_digit() function and
display the results.
RESULT AND ACCURACY
CONCLUSION
 Inthis article, we have successfully built a
Python deep learning project on handwritten
digit recognition app. We have built and
trained the Convolutional neural network
which is very effective for image
classification purposes. Later on, we build
the GUI where we draw a digit on the canvas
then we classify the digit and show the
results.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy