This Git repository contains a simple handwritten digit recognition application built using Python and TensorFlow. It allows you to draw a digit on the canvas, and it will predict the digit using a neural network model trained on a dataset of handwritten digits.
Before running the application, make sure you have the following dependencies installed:
image
(version 1.5.20)numpy
(version 1.24.1)tensorflow
tensorflow-datasets
matplotlib
You can install these dependencies using pip with the following command:
pip install -r requirements.txt
To run the Handwritten Digit Recognizer application, execute the following command:
python app.py
- Launch the application using
python app.py
. - A canvas will appear where you can draw a digit using your mouse.
- Click the "Predict" button to make a prediction of the drawn digit.
- The predicted digit will be displayed in the console.
You can also click the "Erase All" button to clear the canvas and start over.
-
app.py
: This file contains the main application code, including the GUI using Tkinter, drawing on the canvas, and making predictions using the neural network model. -
model.py
: This file defines functions for loading data, preprocessing images, training the neural network model, making predictions, and displaying errors. -
data
: This folder containsX.npy
andy.npy
which are the datasets used by the Model.
The neural network model used for digit recognition consists of three layers:
- Input Layer: 400 units
- Hidden Layer 1: 25 units with ReLU activation
- Hidden Layer 2: 15 units with ReLU activation
- Output Layer: 10 units with linear activation
The model is trained on a dataset of handwritten digits and compiled with the Adam optimizer and sparse categorical cross-entropy loss.
The application can also display errors by comparing the predicted digits to the actual labels for a subset of the dataset. The errors are displayed in a grid, showing the misclassified digits and their predicted labels.
This application was created as a learning project and uses the MNIST dataset for training the neural network model.