cnn.py training based on keras mnist_cnn.py
cnnPredict.py inference based on Flask app.py
cnn.h5 pretrained Keras model
TFKeras is based on simplified MNIST For ML Beginners and cnn.py.
TFKeras.py, TFKeras.h5 & TFKpredict only uses Dense and so is less accurate than CNN.
TFKpredict is a slimmed version of cnnPredict.
TFKeras is 92% accurate vs CNN 99.25%
CNN can detect digit 1
better.
Code Documentation:
batch_size
number of images per loop stepepochs
number of train loopsnum_classes
there are 10 digits 0-9x_train.astype('float32')
trains faster than intx_train /= 255
from 0-255 to 0-1verbose=1
1 for progress bar loggingimread('test3.png',mode='L')
‘L’ (8-bit pixels, black and white)
kerasDataset.py equivalent to TFKeras.py using the keras dataset rather than the tensorflow dataset.
KerasTFDataset.py simplified example of TFKeras.py
jupyter.py has matplotlib and colab examples.
Keras Documentation:
- to_categorical aka one_hot
- Dense
- Flatten
Tensorflow:
sudo pip install -U pip
sudo pip install tensorflow
Keras:
sudo apt update
sudo apt install python-dev
sudo pip install keras
Save Model:
sudo pip install h5py
imread:
sudo pip install pillow
disable "cpu_feature_guard":
export TF_CPP_MIN_LOG_LEVEL=2