handwritten digit recognition using mnist data base for training.
- Handwritten digit recognition project work done on Ubuntu 18.04 with anaconda package installed.
- 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.
- To install pytorch:
conda install pytorch torchvision -c pytorch
- To install cv2:
conda install -c conda-forge opencv conda install -c conda-forge/label/broken opencv
- 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
To install dependencies in anaconda envirnment, please use below command: conda create --name --file requirments.txt
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
python predict.py --input=image= --checkpoint=<checkpoint_file_name.pth>
Example:
python predict_UserImages.py --input-image=./test_fonts.png --checkpoint=./sample_checkpoint_model_epoch1.pth
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
Here 7 is predicted as 7.