Skip to content

JordanTwz/handwriting-recogniser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Handwriting Recogniser (Numbers)

A fun personal project that trains a neural network to recognise handwritten digits (0-9) using the MNIST data set.

alt text

Setup

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt

Train the model

python train.py

This creates model.h5 in the project folder.

Draw and predict

  1. Run the drawing tool:
python draw_digit.py
  1. Draw a digit, then click Save.

The app saves digit.png and shows the predicted digit in the window.

Predict from an existing image

If you already have a digit.png (28x28 greyscale), you can run:

python predict.py

Evaluate the model

Run evaluation on the MNIST test set to get accuracy, macro/weighted F1, per-class F1, and a confusion matrix:

python evaluate.py

This expects model.h5 to exist in the project folder.

Notes

  • 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.

About

A fun personal project that trains a neural network to recognise handwritten digits (0-9) using the MNIST data set.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages