Giter Site home page Giter Site logo

anujdutt9 / handwritten-digit-recognition-using-deep-learning Goto Github PK

View Code? Open in Web Editor NEW
206.0 23.0 124.0 13.73 MB

Handwritten Digit Recognition using Machine Learning and Deep Learning

License: MIT License

Python 100.00%
mnist-classification convolutional-neural-networks python-3-5 handwritten-digit-recognition machine-learning deep-learning knn random-forest svm-model tensorflow

handwritten-digit-recognition-using-deep-learning's Introduction

Handwritten Digit Recognition using Machine Learning and Deep Learning

Published Paper

IJARCET-VOL-6-ISSUE-7-990-997

Requirements

  • Python 3.5 +
  • Scikit-Learn (latest version)
  • Numpy (+ mkl for Windows)
  • Matplotlib

Usage

1. Download the four MNIST dataset files from this link:

curl -O http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
curl -O http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
curl -O http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
curl -O http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz

Alternatively, you can download the dataset from here, unzip the files and place them in the respected folders.

2. Unzip and place the files in the dataset folder inside the MNIST_Dataset_Loader folder under each ML Algorithm folder i.e :

KNN
|_ MNIST_Dataset_Loader
   |_ dataset
      |_ train-images-idx3-ubyte
      |_ train-labels-idx1-ubyte
      |_ t10k-images-idx3-ubyte
      |_ t10k-labels-idx1-ubyte

Do this for SVM and RFC folders and you should be good to go.

3. To run the code, navigate to one of the directories for which you want to run the code using command prompt:

cd 1. K Nearest Neighbors/

and then run the file "knn.py" as follows:

python knn.py

or

python3 knn.py

This will run the code and all the print statements will be logged into the "summary.log" file.

NOTE: If you want to see the output to print on the Command prompt, just comment out line 16, 17, 18, 106 and 107 and hence you will get all the prints on the screen.

Alternatively, you can also use PyCharm to run the code and run the ".py" file in there.

Repeat the steps for SVM and RFC code.

4. To run the CNN code, you don't need to provide in the MNIST dataset as it'll be downloaded automatically.

Just run the file as :

python CNN_MNIST.py

or

python3 CNN_MNIST.py

and it should run fine.

5. If you want to save the CNN model weights after training, run the code with the following arguments:

python CNN_MNIST.py --save_model 1 --save_weights cnn_weights.hdf5

or

python3 CNN_MNIST.py --save_model 1 --save_weights cnn_weights.hdf5

and it should save the model weights in the same directory.

6. To load the saved model weights and avoid the training time again, use the following command:

python CNN_MNIST.py --load_model 1 --save_weights cnn_weights.hdf5

or

python3 CNN_MNIST.py --load_model 1 --save_weights cnn_weights.hdf5

and it should load the model and show the Outputs.

Accuracy using Machine Learning Algorithms:

i) K Nearest Neighbors: 96.67%

ii) SVM: 97.91%

iii) Random Forest Classifier: 96.82%

Accuracy using Deep Neural Networks:

i) Three Layer Convolutional Neural Network using Tensorflow: 99.70%

ii) Three Layer Convolutional Neural Network using Keras and Theano: 98.75%

All code written in Python 3.5. Code executed on Intel Xeon Processor / AWS EC2 Server.

Video Link:

https://www.youtube.com/watch?v=7kpYpmw5FfE

Test Images Classification Output:

Output a1

handwritten-digit-recognition-using-deep-learning's People

Contributors

anujdutt9 avatar baneeishaque avatar dependabot[bot] avatar dilshadt101 avatar mend-bolt-for-github[bot] avatar pyup-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

handwritten-digit-recognition-using-deep-learning's Issues

Mismatch error

Hello, when I run the code knn.py I receive a mismatch error. Please see the attached.
MisMatch

Full documentation

Hiii,
can you please share full documentation about this project. please share how to run the scripts step by step.
Thanks.

How to input testImages I have

Hi anujdutt9 thank you for this awesome project,can you please help me on below..As i have converted my sample into MNIST DATASET Image after that i converted to grayscale still i got below error can you please revert on this.

Traceback (most recent call last):
File "svm.py", line 88, in
test_labels_pred = clf.predict(im)
File "/usr/local/lib/python3.5/dist-packages/sklearn/svm/base.py", line 573, in predict
y = super(BaseSVC, self).predict(X)
File "/usr/local/lib/python3.5/dist-packages/sklearn/svm/base.py", line 310, in predict
X = self._validate_for_predict(X)
File "/usr/local/lib/python3.5/dist-packages/sklearn/svm/base.py", line 479, in validate_for_predict
(n_features, self.shape_fit
[1]))
ValueError: X.shape[1] = 800 should be equal to 784, the number of features at training time

accuracies

hi anuj

There is no accuracy in the summary.log file. whats wrong ?

bar plot

do u have the code for that awesome bar plot comparison . if yes , please do share to me.

Convert base64 to MNIST image

How to convert the base64 image which we get from HTML canvas to image compatible with our model i.e. 28*28 grayscale image? I have tried many resources but none of them were able to produce correct results.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.