This project implements a Convolutional Neural Network (CNN) to classify handwritten digits from the MNIST dataset. The trained model is deployed as a web application using Streamlit, allowing users to interactively upload images of handwritten digits and receive real-time predictions.
The MNIST dataset is a widely used benchmark in the field of machine learning, containing 60,000 training images and 10,000 test images of handwritten digits (0-9). This project demonstrates the following key components:
- Data Preprocessing: Efficient loading and normalization of the MNIST dataset, along with data augmentation techniques to improve the model's generalization ability.
- Model Architecture: Construction of a CNN model incorporating convolutional layers, pooling layers, dropout for regularization, and batch normalization to enhance performance.
- Training and Evaluation: Training the CNN on the MNIST dataset, evaluating its performance on unseen data, and achieving high accuracy.
- Real-time digit classification
- Multiple input methods:
- Sample image selection
- Image upload
- Webcam capture
- Confidence score visualization
- Interactive user interface
- Pre-processed sample images with both black and white backgrounds
- Python 3.8+
- TensorFlow 2.x
- Streamlit
- Pillow (PIL)
- NumPy
- MNIST Dataset
mnist-classifier/
├── app.py # Main Streamlit application
├── generate_samples.py # Script to generate sample images
├── requirements.txt # Project dependencies
├── model/
│ └── best_model_v2.keras # Trained MNIST model
├── samples/ # Sample digit images
│ ├── digit_0_sample_1.png
│ ├── digit_0_sample_2.png
│ └── ...
└── README.md # Project documentation
- Clone the repository:
git clone https://github.com/your-username/mnist-classifier.git
cd mnist-classifier
- Install dependencies:
pip install -r requirements.txt
- Generate sample images:
python generate_samples.py
- Run the application:
streamlit run app.py
- fine-tune to mobile camera dataset
- Add support for multiple digit recognition
- Implement batch processing capability
- Add export functionality for predictions
- Enhance UI with additional visualizations
- Add model performance metrics display
- Test Accuracy: 99.3%
- Deploying machine learning models in a web application
- Building interactive UIs with Streamlit
- Image processing and preprocessing techniques
- Session state management in web applications
- Error handling and user experience design
MIT License - feel free to use this project for learning and development.