A fun personal project that trains a neural network to recognise handwritten digits (0-9) using the MNIST data set.
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtpython train.pyThis creates model.h5 in the project folder.
- Run the drawing tool:
python draw_digit.py- Draw a digit, then click Save.
The app saves digit.png and shows the predicted digit in the window.
If you already have a digit.png (28x28 greyscale), you can run:
python predict.pyRun evaluation on the MNIST test set to get accuracy, macro/weighted F1, per-class F1, and a confusion matrix:
python evaluate.pyThis expects model.h5 to exist in the project folder.
- The drawing tool expects white digits on a black background (MNIST style).
- If you draw a black digit on white, you may get worse results.
- The prediction step recentres the digit inside the 28x28 image so it lines up better with the training data.
