1822 B.E Ece Batchno 14
1822 B.E Ece Batchno 14
by
SATHYABAMA
INSTITUTE OF SCIENCE AND TECHNOLOGY
(DEEMED TO BE UNIVERSITY)
Accredited with Grade “A” by NAAC
JEPPIAAR NAGAR, RAJIV GANDHI SALAI, CHENNAI - 600 119
MAY - 2022
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BONAFIDE CERTIFICATE
This is to certify that this Project Report is the bonafide work of KOLLUKULURU SAI
THARUN(38130108),K.SUDHEER KUMAR REDDY(38130103) who carried out the
project entitled “HANDWRITTEN DIGITS CLASSIFICATION WITH CONVOLUTION
NEURAL NETWORK(CNN)” under our supervision from August, 2021 to May, 2022.
Internal Guide
Dr.M.R.EBENEZAR JEBARANI M.E.,Ph.D.,
____________________________________________________________
Submitted for Viva voce Examination held on ____________________
communication Engineering.
DATE : 1.
PLACE: 2.
We would like to express our sincere and deep sense of gratitude to our Project
Guide Dr.M.R.EBENEZAR JEBARANI, M.E.,Ph.D., for her valuable guidance,
suggestions and constant encouragement paved the way for the successful
completion of our project work
We would like to express our sincere and deep sense of gratitude to our Project
panel members Dr.S.EMALDA ROSLIN, Dr.N.R.KRISHNAMOORTHY for their
valuable guidance, suggestions and constant encouragement paved the way for
the successful completion of our project work.
We wish to express our thanks to all Teaching and Non-teaching staff and also
panel members of the Department of Electronics and Communication
Engineering who were helpful in many ways for the completion of the project.
ABSTRACT
The issue of transcribed digit acknowledgment has for some time been an
open issue in the field of example order. A few examinations have demonstrated that a
Neural Network has an incredible execution in information arrangement. The
fundamental target of this paper is to give effective and solid procedures to
acknowledge transcribed numerical by looking at different existing arrangement models.
This paper is about the exhibition of Convolutional Neural Network (CCN). Results
demonstrate that CNN classifier beat over Neural Network with critical improved
computational effectiveness without relinquishing execution. Handwritten digit
recognition can be performed using the Convolutional neural network from Machine
Learning. Basically to perform the model required some libraries such as NumPy,
Pandas', TensorFlow, Keras.
This discussion is about the Convolutional Neural Network and its importance.
It also covered how a dataset is divided into training and test dataset. A dataset was
taken to make predictions of handwritten digits from 0 to 9. The dataset was cleaned,
scaled, and shaped.Using TensorFlow, a CNN model was created and was eventually
trained on the training dataset. Finally, predictions,classification were made using the
trained model with an accuracy of 92.5%.
(i)
TABLE OF CONTENTS
ABSTRACT i
LIST OF FIGURES iv
1 INTRODUCTION 1
2 LITERATURE SURVEY 5
3 EXISTING SYSTEM 8
3.2 METHODOLOGY 9
4 PROPOSED SYSTEM 13
4.2 ADVANTAGES 15
(ii)
4.6 POOLING 19
4.5 NORMALIZATION 18
5.8 ACCURACY 40
REFERENCES 42
(iii)
LIST OF FIGURES
4.5 Pooling 19
(iv)
5.1 Captured Images 26
(v)
5.19 Prediction of Digit 7 39
5.22 Accuracy 40
(vi)
CHAPTER - 1
INTRODUCTION
Crane's early work culminated in a first patent in 1964 for a special pen device.
These initial efforts took a more advanced form in the early 1970s with a system that
used what was generally referred to as the “SRI pen” as a method of inputting
characters into a computer. Commercial products incorporating handwriting recognition
as a replacement for keyboard input were introduced in the early 1980s.
All of these areas deal with large databases and therefore require high
identification accuracy, low computational complexity, and consistent performance of the
identification system. Over time, the number of fields that can implement deep learning
is increasing. In deep learning, convolutional neural networks (CNN) are being used for
visual image analysis. CNN can be used in object detection, facial recognition, robotics,
video analysis, segmentation, pattern recognition, natural language processing, spam
detection, topical gradation, regression analysis, speech recognition, image
classification.
1
Detection of handwritten numbers, including accuracy in these areas, has
reached human perfection using deep convolutional neural networks (CNNs). Recently
CNN has become one of the most attractive approaches and has been the ultimate
factor in recent success and in several challenging machine learning applications.
Considering all the factors stated above have chosen CNN for our challenging tasks of
image classification.Used it to identify handwritten numbers, which is one of the higher
education and business transactions. There are many applications of handwritten digit
recognition for our real-life purposes. Hence using the Convolutional Neural Network
(CNN).
Handwriting recognition has been the main subject of research for almost the last
forty years. This research work analyzes the behaviour of classification techniques
(CNN) in a large handwriting dataset to predict a digit. Machine-learning techniques,
particularly when applied to Neural Networks like CNN or ANN, have played an
increasingly important role in the design of these recognition systems.
Several methods have been developed in handwritten digit recognition and these
methods have been classified into categories: knowledge-based methods,
feature-based methods, template-based methods and appearance-based methods.
Errors in Digit recognition cause severe problems like digits written on a bank cheque if
recognized erroneously could result in unfortunate consequences.
The goal of our work is to create a model that will be able to recognize and classify
the handwritten digits from images by using concepts of Convolution Neural Network.
Though the goal of our research is to create a model for digit recognition and
classification, it can also be extended to letters and an individual’s handwriting. The
major goal of the proposed system is understanding Convolutional Neural Network, and
applying it to the handwritten digit recognition system by working on the dataset
created.
2
There have already been significant advancements in this area previously.Tried to
form a model around the Conventional Neural Network as our own dataset so that the
model has high accuracy and has been trained and tested on a large dataset.Also
consider developing a robust test harness for estimating the performance of the model
and then exploring improvements to the model. With high accuracy rates, the model can
solve a lot of real life problems.In the field of digital image processing, pattern
recognition is the research area that studies the operation and design of systems that
recognize patterns in data. Its primary goal is the classification of objects into a number
of categories or classes. Depending on the use, these objects can be images, signal
waveforms or any other type of measurements that need to be classified. Common
applications of pattern recognition are automatic speech recognition, classification of
text into several categories (e.g. spam/non-spam email messages) and the automatic
recognition of handwritten postal codes on postal envelopes. Statistical approaches are
one of the most widely studied and used to perform pattern classification. In statistical
pattern recognition, an image is represented by a set of f features which constitute a
f-dimensional feature vector. A decision process (statistical classifier) based on this
vector is used to establish boundaries between image classes and then perform the
classification. Thus, the classification success depends entirely on the set of selected
features and the classification scheme.
A human brain can easily interpret a sophisticated image and can extract data from
it, but for a computer, an image is a collection of pixels which are nothing but a list of
combinations of numbers ranging from 0 to 255, blends being RGB, B.W., greyscale,
etc. Information in an image can be extracted from the pixel values. A human eye
contains light-sensitive cells that can segment the image into partitions which help to
interpret the information like shape, size, and colour which are called features, these
features are later sent to the visual cortex that analyses the characteristics and maps it
to our memory for identification. Thus our brain is capable of identifying an unseen
image.
3
Fig 1.1 : Handwritten Digits
4
CHAPTER - 2
LITERATURE SURVEY
Ahamed Hafiz (2018) developed a Support Vector Machine SVM Based Real
Time HandWritten Digits Classification using Support vector Machine but it is Not
suitable for Large Data sets.
Haider (2020) developed a new challenging digit Arabic dataset collected from
different study levels of schools. A large dataset is collected after paying vast effort for
distributing and collecting digit forms over hundreds of primary, high, college students.
After he found that there were few and not challenging Arabic digit dataset, He paid vast
effort for preparing such a challenging dataset.
5
Mukesh N (2018) implemented a Classification of Handwritten Characters Using
k-means clustering Machine Learning Algorithms But it is Not suitable for Large Data
sets and it has low accuracy and High Baseline Error.
Nitin Kali Raman (2021) proposed a Handwritten Digit Recognition using Artificial
Neural Network.An ANN is based on a collection of connected units or nodes called
artificial neurons, which loosely model the neurons in a biological brain. Each
connection, like the synapses in a biological brain, can transmit a signal to other
neurons. An artificial neuron receives a signal then processes it and can signal neurons
connected to it.But he got a High Baseline Error.
6
Naive Bayes that follows Gaussian normal distribution and supports continuous
data.The drawback of this is Low accuracy.
7
CHAPTER - 3
EXISTING SYSTEM
Fig 3.1 depicts Support Vector Machine Plot with different support vectors along x-axis
and y-axis.
8
Support Vectors are simply the coordinates of individual observation. The SVM
classifier is a frontier that best segregates the two classes (hyper-plane/ line).
At support vector machines and a few examples of their working here.All values for z
would be positive always because z is the squared sum of both x and y
In the original plot, red circles appear close to the origin of x and y axes, leading to
lower value of z and stars relatively away from the origin result in higher value of z.
3.2 METHODOLOGY
SVM is capable of doing both classification and regression. In this post I'll focus
on using SVM for classification. In particular I'll be focusing on non-linear SVM, or SVM
using a non-linear kernel. Non-linear SVM means that the boundary that the algorithm
calculates doesn't have to be a straight line. The benefit is that you can capture much
more complex relationships between your data points without having to perform difficult
transformations on your own. The downside is that the training time is much longer as
it's much more computationally intensive.
9
Fig 3.2 : SVM Methodology Code
Fig 3.2 shows Support Vector Machine Methodology code using random,randint
matplotlib.
Fig 3.3 represents Confusion Matrix of Support Vector Machine Confusion Matrix used
for evaluating the performance of a classification model,The matrix compares the actual
target values with those predicted by the machine learning model.
10
3.3 BLOCK DIAGRAM
Fig 3.4 explains about Support Vector Machine Block Diagram.Collection Digit
Database it will collect Handwritten Digits as images and convert them into a
dataset.preprocessing process the data and it will send to SVM/k-nn classifier using
k-nn classifier Algorithm digits were recognized.
ADVANTAGES
1)SVM works relatively well when there is a clear margin of
separation between classes.
11
3)SVM is effective in cases where the number of dimensions is greater than the number
of samples.
DISADVANTAGES
2)SVM does not perform very well when the data set has more noise i.e. target classes
are overlapping.
3)In cases where the number of features for each data point exceeds the number of
training data samples, the SVM will underperform.
4)As the support vector classifier works by putting data points, above and below the
classifying hyperplane there is no probabilistic explanation for the classification
12
CHAPTER - 4
PROPOSED SYSTEM
Feed Forward neural network and Designed mostly for Image classification
Consists of an Input layer , multiple hidden layers , output layers In deep learning, a
convolutional neural network (CNN/ConvNet) is a class of deep neural networks, most
commonly applied to analyze visual imagery. Now when thinking of a neural network
think about matrix multiplications but that is not the case with ConvNet. It uses a
special technique called Convolution. Now in mathematics convolution is a
mathematical operation on two functions that produces a third function that expresses
how the shape of one is modified by the other. The role of the ConvNet is to reduce the
images into a form that is easier to process, without losing features that are critical for
getting a good prediction.
13
A Convolutional Neural Network (ConvNet/CNN) is a Deep Learning algorithm
which can take in an input image, assign importance (learnable weights and biases) to
various aspects/objects in the image and be able to differentiate one from the other. The
benefit of using CNNs is their ability to develop an internal representation of a
two-dimensional image. This allows the model to learn position and scale invariant
structures in the data, which is important when working with images CNN is mainly used
in image analysis tasks like Image recognition, Object detection & Segmentation CNNs
are powerful image processing, artificial intelligence (AI) that use deep learning to
perform both generative and descriptive tasks, often using machine vision that includes
image and video recognition, along with recommender systems and natural language
processing (NLP) Faster R-CNN is a single-stage model that is trained end-to-end. It
uses a novel region proposal network (RPN) for generating region proposals, which
save time compared to traditional algorithms like Selective Search. It uses the ROI
Pooling layer to extract a fixed-length feature vector from each region
proposal.convolutional neural network (CNN/ConvNet) is a class of deep neural
networks, most commonly applied to analyze visual imagery. Now when thinking of a
neural network think about matrix multiplications but that is not the case with ConvNet.
It uses a special technique called Convolution.In Convolutional neural network, the
kernel is nothing but a filter that is used to extract the features from the images. The
kernel is a matrix that moves over the input data, performs the dot product with the
sub-region of input data, and gets the output as the matrix of dot products.
CNNs are a class of Deep Neural Networks that can recognize and classify
particular features from images and are widely used for analyzing visual images. Their
applications range from image and video recognition, image classification, medical
image analysis, computer vision and natural language processing.Neurons in a
convolutional layer that cover the entire input and look for one feature are called filters.
These filters are 2 dimensional (they cover the entire image). However, having the
whole convolutional layer looking for just one feature (such as a corner) would
massively limit the capacity of your network. The main special technique in CNNs is
14
convolution, where a filter slides over the input and merges the input value + the filter
value on the feature map. In the end, our goal is to feed new images to our CNN so it
can give a probability for the object it thinks it sees or describe an image with text.The
output of the CNN is also a 4D array. Where batch size would be the same as input
batch size but the other 3 dimensions of the image might change depending upon the
values of filter, kernel size, and padding use.2D CNNs use 2D convolutional kernels to
predict the segmentation map for a single slice. Segmentation maps are predicted for a
full volume by taking predictions one slice at a time. The 2D convolutional kernels are
able to leverage context across the height and width of the slice to make predictions.
In any neural network, a dense layer is a layer that is deeply connected with its
preceding layer which means the neurons of the layer are connected to every neuron of
its preceding layer. This layer is the most commonly used layer in artificial neural
network networks.
4.2 ADVANTAGES
1)Images(100x100x3 images)
2)Convolution Layer
3)ReLU(Normalization)
4)Max pooling
15
5)Fully connected Output
16
Fig 4.2 shows CNN Block Diagram.From 28 x 28 pixel Image using convolution and
max pooling and relu techniques images are predicted and classified.
Fig 4.3 depicts layers in CNN.From input image with 28x28x1 pixel modified into
different layers and channels as shown in the above figure.
17
Fig 4.4 : Digit in pixel view
Fig 4.4 indicates Digit in pixel view.It is showing pixel values in black region and zeroes
in white region.Based on this images are identified.
4.5 NORMALIZATION
18
4.6 POOLING
Fig 4.5 shows pooling.From convolution matrix it converts and takes as 5x5 matrix and
calculates its values of that particular matrix and then it forms a 3x3 new matrix.Similarly
for all matrices as shown in the above figure.
19
Max Pooling also performs as a Noise Suppressant. It discards the noisy
activations altogether and also performs de-noising along with dimensionality reduction.
On the other hand, Average Pooling simply performs dimensionality reduction as a
noise suppressing mechanism. Hence Max Pooling performs a lot better than Average
Pooling. The Convolutional Layer and the Pooling Layer, together form the i-th layer of
a Convolutional Neural Network. Depending on the complexities in the images, the
number of such layers may be increased for capturing low-level details even further, but
at the cost of more computational power.
Fig 4.6 explains about max & Average pooling.In max pooling it will take max number in
every matrix.In Average pooling it will take Average number in every matrix.
20
4.7 FULLY CONNECTED LAYER
Fig 4.7 represents Fully Connected Layer Block Diagram.In this layer from input volume
32x32x1 converts into convolution layer stride 1 and then converts into max pooling
layer stride 2.Using flatten layer and fully connected layer with relu activation function
converts into soft-max layer.
21
4.8 CNN WORKING
An RGB image is nothing but a matrix of pixel values having three planes
whereas a grayscale image is the same but it has a single plane. Take a look at this
image to understand more. For simplicity, let’s stick with grayscale images to
understand CNNs working.
Fig 4.8 indicates Three Colour Channels.Three colours are red,green,blue with width 4
units pixels and height 4 units pixels with different matrices.
22
Fig 4.9 : Kernel View
Fig 4.9 shows a convolution. Take a filter/kernel(3×3 matrix) and apply it to the input
image to get the convolved feature. This convolved feature is passed on to the next
layer.
23
Fig 4.10 : Convolved Feature
Fig 4.10 indicates convolved features.From Image matrix converted into convolved
feature.It converts and takes as 5x5 matrix and calculates its values of that particular
matrix and then it forms a 3x3 new matrix.Similarly for all matrices as shown in the
above figure.
In the case of RGB colour, channels take a look at this animation to understand
its working.Convolutional neural networks are composed of multiple layers of artificial
neurons. Artificial neurons, a rough imitation of their biological counterparts, are
mathematical functions that calculate the weighted sum of multiple inputs and output an
activation value.
When given an input image in a ConvNet, each layer generates several activation
functions that are passed onto the next layer. The first layer usually extracts basic
features such as horizontal or diagonal edges. This output is passed on to the next layer
which detects more complex features such as corners or combinational edges. As it
24
moves deeper into the network it can identify even more complex features such as
objects, faces, etc….
Fig 4.11 shows the Kernel Channel of CNN.Considering three colour channels as input
channel and converting into kernel channel as 3x3 matrix and predicting the output.
25
CHAPTER - 5
26
Fig 5.1 indicates Captured Images.Images captured using pyscreenshot package are
shown in the above figure.
Fig 5.2 shows captured Image Function Code.To collect images, a pyscreenshot
package can be used. This package can be downloaded using pip which is a package
management tool that is written in python and used to install python packages. This pip
can be automatically installed during installation of Python.To install pyscreenshot,open
any terminal and type command is pip install pyscreenshot importing time because to
stop my execution for some second of time so that next image (digit) can be drawn.This
coordinate value indicates which part of your screen to be captured. Inorder to want our
drawn region to be captured,So use trial and error methods to find this coordinate. This
can also try using this same coordinate for the first run. But it might be different as our
laptop size may not be the same. So,use trial and error methods here.
27
5.2 CREATE DATA
Fig 5.3 represents Create Data Code.Creating data using numpy alias name as np
,array.If the condition satisfies then that particular block will execute if it does not
satisfies then it will exit.
28
Fig 5.4 : Create Function
Fig 5.4 indicates Create function.In this data is created and loaded.Once created,it will
shuffle the data randomly.
Fig 5.5 shows Data Dividing Code.Data divided into training and testing part.800 images
for training part and 200 images for testing part.
29
5.4 BUILDING THE MODEL
Fig 5.6 indicates Importing Necessary Python Libraries.Here importing libraries such as
warnings,tensorflow,tflearn,conv_2d,max_pool_2d,input_data,dropout,fully_connected,r
egression.
30
Fig 5.7 : Executing Epoch
Fig 5.7 represents Executing Epoch.Epoch is the number of times that the learning
algorithm will work through the entire training dataset.
31
5.5 PREVIEW OF IMAGE
32
5.6 PREDICT AND DISPLAY
Fig 5.9 represents Creating Test Data.Using dataset 20% of data used for testing
purpose and created test data.
33
Fig 5.10 indicates Classification of Handwritten Digits.From Digits 0 to 9 it is classified
and predicted correctly as shown in the figure.
34
Fig 5.11 Image Prediction Code.Using cv2 and numpy images were predicted.
35
Fig 5.13 : Prediction of Digit 1
36
Fig 5.15 : Prediction of Digit 3
37
Fig 5.17 : Prediction of Digit 5
38
Fig 5.19 : Prediction of Digit 7
39
Fig 5.21 : Prediction of Digit 9
5.8 ACCURACY
Figure 5.22 shows the 92.5 % accuracy of the Handwritten Digits Classification using
Convolutional Neural Network.
40
CHAPTER - 6
In this discussion about the Convolutional Neural Network and its importance. It
also covered how a dataset is divided into training and test dataset.Here considered
80% data for training and 20% data for testing. It means that over all 1000 Images from
that took 800 for training and 200 images for testing. A dataset was taken to make
predictions of handwritten digits from 0 to 9. The dataset was cleaned, scaled, and
shaped. Using TensorFlow, a CNN model was created and was eventually trained on
the training dataset. Finally, predictions were made using the trained model with an
accuracy 92.5%.In this successfully predicted all digits from 0 to 9.
Plan to achieve better accuracy results on the coloured images also as there can
be various boundary conditions that may exist in coloured images. Also try to implement
our models on letters and a double-digit(s) database so that can extend our
implementation and can diversify our model’s application.In future look forward to
working with Double Digit and Triple Digit Numbers and also will plan to predict
characters also.
41
REFERENCES
42
7. Fabien Lauer, Ching Y. Suen, and Gerard Bloch “A trainable feature extractor for
handwritten digit recognition”, Journal Pattern Recognition, Elsevier, 40 (6),
pp.1816-1824, 2007.
8. Gil Levi and Tal Hassner, "OFFLINE HANDWRITTEN DIGIT RECOGNITION
USING NEURAL NETWORK", International Journal of Advanced Research in
Electrical, Electronics and Instrumentation Engineering, vol. 2, no. 9, pp. 4373
-4377, 2013
12. Ishani Patel, Viraj Jagtap and Ompriya Kale. "A Survey on Feature Extraction
Methods for Handwritten Digits Recognition", International Journal of Computer
Applications, vol. 107, no. 12, pp. 11-17, 2014.
13. Jain A.K and D. Zongker, "Representation and recognition of handwritten digits
using deformable templates," in IEEE Transactions on Pattern Analysis and
Machine Intelligence, vol. 19, no. 12, pp. 1386-1390, Dec. 1997.
43
Benign and Malignant Melanomas'', Springer Science and Business Media LLC,
2019
15. Kussul E and T. Baidik, "Improved method of handwritten digit recognition tested
on MNIST database," Image and Vision Computing, vol. 22, no. 12, pp. 971-981,
2004.
16. Manoj Kumar Mahto, Karamjeet Bhatia, R.K.Sharma, “Combined Horizontal and
Vertical Projection feature Extraction Technique for Gurmukhi Handwritten
Character Recognition”, 2015, International conference on Advances in
Computer Engineering and Applications (ICACEA).
17. Neha Sahu, Nitin Kali Raman,”An Efficient handwritten Digit Recognition System
Using Artificial Neural Network”, 978-1-4673-5090-7/13/$31.00 ©2013 IEEE.
18. Neves, R. F., Alberto Filho, N. G., Mello, C. A., & Zanchettin, C. A SVM based
off-line handwritten digit recognizer. In System, IEEE International Conference on
Man, and Cybernetics (SMC) (pp. 510-515), 2011
19. Nimisha Jain, Kumar Rahul, Ipshita Khamaru. AnishKumar Jha, Anupam Ghosh
(2017). “HandWritten Digit Recognition using Convolutional Neural Network
(CNN)”, International Journal of Innovations & Advancement in Computer
Science, IJIACS,ISSN 2347 – 8616,Volume 6, Issue 5.
44
21. Plamondon, R., & Srihari, S. N. Handwritten digits recognition IEEE Transactions
on Pattern Analysis and Machine Intelligence, 22(1), 63-84
22. Saeed AL-Mansoori, "Intelligent Handwritten Digit Recognition using MLP and
Artificial Neural Network", Int. Journal of Engineering Research and Applications,
vol. 5, no. 5, pp. 46-51, 2015.
23. Vinjit B.M, M. K. Bhojak, S. Kumar and G. Chalak, "A Review on Handwritten
Character Recognition Methods and Techniques," 2020 International Conference
on Communication and Signal Processing (ICCSP), Chennai, India, 2020, pp.
1224-1228, DOI: 10.1109/ICCSP48568.2020.9182129.
25. Xiao-Xiao Niu n , Ching Y. Suen “A novel hybrid CNN–SVM classifier for
recognizing handwritten digits” Pattern Recognition 45 (2012) 1318–1325, 2011
26. Youssouf Chherawala, Partha Pratim Roy and Mohamed Cheriet, “Feature Set
Evaluation for Offline Handwriting Recognition Systems: Application to the
Recurrent Neural Network,” IEEE TRANSACTIONS ON CYBERNETICS, VOL.
46, NO. 12, DECEMBER 2016.
45