This project uses the notMNIST tutorial from the TensorFlow website. The tutorial uses a deep learning model.
This projects consists of two scripts:
- createModel.py – creates a model model.ckpt file based on the tutorial.
- predict.py – uses the model.ckpt (beginners tutorial) file to predict the correct integer form a handwritten letter in a .png file.
The following Python libraries are required.
- tensorflow - TensorFlow
Of course TensorFlow needs to be installed. The TensorFlow website has a good manual .
The easiest way the use the scripts is to put all four scripts in the same folder. If TensorFlow is installed correctly and the images to train the model are present in that folder with the name notMNIST_large, you are good to go.
Running is based on the steps:
- create the model file
- create an image file containing a handwritten letter
- predict the character
The easiest way is to cd to the directory where the python files are located. Then run:
python createModel.py
to create the model based on the notMNIST beginners tutorial.
You have to create a PNG file that contains a handwritten character. The background has to be white and the letter has to be black. Any paint program should be able to do this. Also the image has to be auto cropped so that there is no border around the letter.
The easiest way again is to put the image file from the previous step (step 2) in the same directory as the python scripts and cd to the directory where the python files are located.
The predict scripts require one argument: the file location of the image file containing the handwritten letter. For example when the image file is letter.png’ and is in the same location as the script, run:
python predict.py letter.png’
The script, predict.py, uses the model.ckpt file created by the createModel.py script.