Implementation of a Convolutional Neural Network (CNN) to classify handwritten digits using the MNIST dataset.
.
├── digit.png
├── LICENSE
├── model.keras
├── predict.py
├── README.md
├── requirements.txt
├── statistics
│ ├── diagnostics.png
│ └── summary.png
└── train.py
- Clone the repository and
cdinto it
git clone https://github.com/eko-071/digit-recognition.git
cd digit-recognition/- Save the image being classified in the folder as
digit.png.
Note: Input images should be grayscale with a black background and a white digit, similar to MNIST
- Install required packages
pip install -r requirements.txt
- Run the script
python predict.py
To train the model from scratch and generate evaluation plots:
python train.py
The script:
- Trains a CNN on the MNIST dataset
- Uses 5-fold cross-validation
- Saves training statistics in
statistics/ - Saves the trained model as
model.keras
- Achieves ~99% accuracy on the MNIST dataset.
diagnostics.pngshows two plots: cross-entropy loss vs. epochs (top) and classification accuracy vs. epochs (bottom), with training and validation curves for each cross-validation fold.summary.pngshows a box plot of classification accuracy values obtained from all cross-validation folds.
Note: Training data is blue, and testing data is orange.
numpymatplotlibtensorflowscikit-learn