This project uses a neural network in order to recognise handwritten digits (from 0 - 9)
The MNIST dataset is used for training and testing the model. It consists of a large number of handwritten digits from 0 to 9, along with their corresponding labels. The dataset is automatically downloaded and split into training and test data when running the code.
- Clone the repository:
git clone https://github.com/kmousaa/Digit-Recogniser-Neural-Network.git
- Install the required dependencies:
pip install tensorflow opencv-python numpy matplotlib
- Run the python script
main.py
- A window will be displayed showing the handwritten digit from the "handwriten_numbers" folder.
- The neural network's prediction for the digit will be printed in the terminal.
- Create a PNG file of size 28x28 pixels representing the handwritten digit you want to add. You can do this by scanning a paper or using microsoft paint, and then using an online tool such as 28x28 resizer to make sure the image is the correct size. Ensure that the image format is PNG and follow the guidelines mentioned below.
- Save the PNG file with the filename format "digit[num].png", where [num] is the next number after the existing digits. For example, if the last digit file is "digit9.png", name your file "digit10.png" for the next digit.
- Copy the PNG file into the "handwriten_numbers" folder in the project directory.
- Run the
main.py
script
The model has already been trained, and is now commented out to prevent re training it every time the code is run. To modify the model architecture, follow these steps:
- Open the
main.py
file - Uncomment the code section that creates the model.
- Customize the model architecture by adding or removing layers and adjusting the number of neurons, or the number of times to train the model (documented by the comments)
- Run the
main.py
script to train the model with the new architecture. - Comment out the code in order to not re-train the model every time
- You can now use the new model!
The current neural network model for handwritten digit recognition faces the following challenges:
- Accuracy: The model is not very accurate (70% accurate), leading to occasional mistakes.
- Overfitting: The model tends to overfit the training data, resulting in poor performance on new, unseen images.
- Confusion between 1 and 7: The model struggles to differentiate between the digits 1 and 7, which have similar shapes.
- Optimal architecture: Determining the ideal number of layers and neurons for the model is difficult.
I will try on improving the model to improve its accurary. Feel free to expriment and change the model and let me know if you were able to improve it!