Giter Site home page Giter Site logo

abhinema / handwritten_digit_recognition_mnist Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 3.0 8.92 MB

Handwritten Digit Recognition using MNIST data base

License: MIT License

Python 100.00%
handwritten-digit-recognition mnist-handwriting-recognition pytorch-cnn mnist pytorch pytorch-tutorial ocr-recognition cnn

handwritten_digit_recognition_mnist's Introduction

Handwritten Digit Recognition using PyTorch & MNIST database

handwritten digit recognition using mnist data base for training.

Prerequisites

  1. Handwritten digit recognition project work done on Ubuntu 18.04 with anaconda package installed.
  2. Images used for prediction are generated with white background and black font, refer test_fonts.png. In program images converted to inverted colour for further processing.

Installing

Install components

  1. To install pytorch:

conda install pytorch torchvision -c pytorch

  1. To install cv2:

conda install -c conda-forge opencv conda install -c conda-forge/label/broken opencv

  1. To install matplotlib

conda install -c conda-forge matplotlib conda install -c conda-forge/label/broken matplotlib conda install -c conda-forge/label/testing matplotlib conda install -c conda-forge/label/rc matplotlib

OR use below:

To install dependencies in anaconda envirnment, please use below command: conda create --name --file requirments.txt

Running the tests

1. How to use train.py (This will generate checkpoint model file)

python train.py --no-cuda (use CPU) --epochs= --checkpoint=<checkpoint_file_name.pth>

Example: To use GPU:

python train.py --epochs=10 --checkpoint=./sample_checkpoint_model_epoch10.pth

To use CPU:

python train.py --epochs=10 --checkpoint=./sample_checkpoint_model_epoch10.pth --no-cuda

2. predict.py

python predict.py --input=image= --checkpoint=<checkpoint_file_name.pth>

Input Image File

alt text

Example:

Output with model file with 1 epochs

python predict_UserImages.py --input-image=./test_fonts.png --checkpoint=./sample_checkpoint_model_epoch1.pth

Output File

alt text

Output with model file with 10 epochs

in above output 7 is predicted as 3. lets try with higher epochs model file.

python predict_UserImages.py --input-image=./test_fonts.png --checkpoint=./sample_checkpoint_model_epoch10.pth

Output File

alt text

Here 7 is predicted as 7.

handwritten_digit_recognition_mnist's People

Contributors

abhinema avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

handwritten_digit_recognition_mnist's Issues

Error when running train.py

I met "RuntimeError: output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28]" when running with code
"python train.py --epochs=5 --checkpoint=./checkpoint_model_epoch5.pth" in a Colab environment.
I found train.py can be worked if I change the transform code to "transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize([0.5], [0.5])])", but the "predict_UserImages.py" have an error like:
image

Could you please kindly help me with this?

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.