This project implements a Handwritten Digit Recognition system using a Convolutional Neural Network (CNN). The system consists of two main parts:
- Model Training (program.py) - A CNN model is trained on the MNIST dataset.
- Digit Recognition GUI (practiceground.py) - A graphical interface allows users to draw digits, which are then classified using the trained model.
- CNN-based Model for digit classification.
- Tkinter GUI for drawing and recognizing digits.
- Uses OpenCV for image processing.
- Model is saved in mnist.h5 for later use.
- Python
- TensorFlow/Keras
- OpenCV
- Tkinter
- NumPy
- MNIST Dataset: A collection of 60,000 training and 10,000 testing images of handwritten digits (0-9).
This script trains a CNN on the MNIST dataset and saves the model (mnist.h5).
- Loads MNIST dataset.
- Preprocesses the images (resizing, normalizing, reshaping).
- Builds a CNN with:
- Convolutional layers for feature extraction.
- MaxPooling layers for dimensionality reduction.
- Dense layers for classification.
- Trains the model and evaluates performance.
- Saves the trained model for later use.
python train_model.pyThis script provides a graphical interface where users can draw a digit, and the model predicts the digit.
- Tkinter Canvas: Users can draw digits.
- Clear Button: Reset the canvas.
- Predict Button: Processes the image and predicts the digit.
- Uses OpenCV to process the drawn image before passing it to the model.
python main.py- Train the model using
program.py. This saves the trained model asmnist.h5. - Run the GUI using
practiceground.py. - Draw a digit in the Tkinter window.
- Click the "Predict" button to classify the digit.
- The predicted digit is displayed in a new window.
Install dependencies using:
pip install numpy opencv-python tensorflow keras- Improve model accuracy with more training.
- Add support for different handwriting styles.
- Deploy as a web-based application.
- Dataset: MNIST (by Yann LeCun)
- Libraries: TensorFlow, OpenCV, Tkinter