The Handwritten Digit Recognizer project uses a Convolutional Neural Network (CNN) model to classify handwritten digits (0–9) based on the popular MNIST dataset. With a user-friendly interface, users can draw digits and receive real-time predictions, making it suitable for applications like digitizing notes and automated number plate recognition.
Try out the Handwritten Digit Recognizer! 👉🏻
Below is a preview of the Handwritten Digit Recognizer in action. Draw a digit to see its prediction! 👇🏻
- Features
- Dataset
- Data Preprocessing
- Model Training
- Evaluation
- Installation
- Usage
- Technologies Used
- Results
- Conclusion
- License
- Contact
- Real-time digit recognition on a Streamlit interface with a drawable canvas.
- Provides predictions for handwritten digits (0–9).
- Utilizes a CNN model trained on 70,000 MNIST dataset images, ensuring reliable performance in digit classification.
- MNIST Dataset: Contains 70,000 grayscale images of handwritten digits (0–9), each of size 28x28 pixels.
- Data Splits: The dataset is divided into 60,000 training images and 10,000 testing images.
- Normalization: Pixel values are scaled between 0 and 1 to optimize CNN performance.
- Data Augmentation: Applied random transformations to enhance model generalization.
-
Model Architecture: The model is based on a Convolutional Neural Network (CNN), designed with multiple layers to effectively extract features from handwritten digit images.
-
Training Process: The model is trained using the MNIST dataset, incorporating data augmentation techniques to enhance the diversity of training samples. Early stopping is also utilized to prevent overfitting, ensuring improved generalization to unseen data.
The model is evaluated using the following metrics:
-
Accuracy: Measures the overall performance of the model by calculating the ratio of correct predictions to the total number of predictions. The model achieved a training accuracy of approximately
97.06%
and a validation accuracy of approximately99.30%
, indicating excellent performance on both the training and validation datasets. -
Loss: Tracks the model's error during training and testing, utilizing categorical cross-entropy for this multi-class classification task. The training loss decreased to around
0.0985
, while the validation loss reached about0.0221
, suggesting that the model is effectively learning from the data and generalizing well to unseen examples.
- Epochs:
10
- Final Training Accuracy:
97.06%
- Final Validation Accuracy:
99.30%
- Final Training Loss:
0.0985
- Final Validation Loss:
0.0221
The plots below illustrate the training and validation accuracy and loss over the epochs, demonstrating the model's performance improvement throughout the training process.
- Model Accuracy and Loss:
-
Clone the repository:
https://github.com/hk-kumawat/Handwritten-Digit-Recognizer.git
-
Install dependencies:
pip install -r requirements.txt
-
Train the Model:
- Run the Jupyter Notebook to train the CNN model on the MNIST dataset.
- The initial model is saved as
mnist_model.h5
, which achieved a certain accuracy.
-
Enhanced Model:
- After further enhancements, a refined model is saved as
mnist_model_enhanced.h5
, yielding improved accuracy.
- After further enhancements, a refined model is saved as
-
Model Inference:
- Run the
streamlit.py
file to start the Streamlit app. - Draw a digit on the canvas and click "Predict" to see the model's prediction.
- Run the
- Programming Language: Python
- Libraries:
pandas
numpy
tensorflow
keras
streamlit
streamlit_drawable_canvas
seaborn
opencv-python
matplotlib
- Deployment: Streamlit for a web-based user interface
The model demonstrated impressive accuracy on the MNIST test dataset, achieving approximately 99.30%
validation accuracy. By leveraging a robust Convolutional Neural Network (CNN) architecture, it effectively predicts handwritten digits with minimal error. The model's performance was validated through metrics such as accuracy and loss, showcasing its ability to generalize well to unseen data.
The Handwritten Digit Recognizer demonstrates the effectiveness of CNNs in image recognition tasks. With a simple user interface, the project showcases how AI can transform handwritten input into digital data, supporting applications from education to automated systems.
This project is licensed under the MIT License - see the LICENSE file for details.
I’d love to hear from you! Feel free to reach out:
- 💻 — Explore my projects and contributions.
- 🌐 — Let’s connect professionally.
- 📧 — Send me an email for any in-depth discussions.
"Turning each stroke of creativity into a recognizable digit, one digit at a time." – Anonymous