This project implements a Convolutional Neural Network (CNN) for recognizing handwritten digits using the MNIST dataset. The model can classify digits from 0 to 9 with high accuracy.
- MNIST dataset loading and preprocessing
- CNN model implementation using TensorFlow
- Model training and evaluation
- Visualization of results and predictions
- Interactive digit recognition demo
- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run the model:
python digit_recognition.pydigit_recognition.py: Main script containing the CNN model implementationrequirements.txt: Project dependenciesREADME.md: Project documentation
- Input layer: 28x28 pixels (grayscale images)
- Convolutional layers with ReLU activation
- MaxPooling layers
- Dense layers
- Output layer: 10 neurons (digits 0-9)
The model typically achieves:
- Training accuracy: >99%
- Test accuracy: >98%
The script generates three visualization files:
confusion_matrix.png: Shows the model's prediction accuracy for each digittraining_history.png: Displays the training and validation accuracy/loss over timesample_predictions.png: Shows random test images with their true and predicted labels
- numpy==1.24.3
- tensorflow==2.15.0
- matplotlib==3.7.2
- seaborn==0.12.2
- scikit-learn==1.3.0