MNIST CNN is an interactive handwritten digit recognition project that demonstrates the power of convolutional neural networks (CNNs) using PyTorch. The system allows users to draw digits, see real-time predictions, and explore the internal workings of the model through visualizations.
Key highlights:
- CNN achieves high accuracy on MNIST (over 98% on test set).
- Interactive Tkinter GUI for drawing digits.
- Visualization of input images, prediction probabilities, and feature maps from the first convolutional layer.
- Graphs show training progress over epochs (accuracy and loss).
Want to see the MNIST digit recognizer in action?
You can draw your own digits or upload an image, and the model will predict what number you wrote in real-time. It even shows:
- The probabilities for each digit
- The processed input image
- The feature maps from the first convolutional layer
Check it out here: https://aitaneuh-mnist-cnn.streamlit.app/
Tip: Use a white brush on a black background for best results, just like MNIST images.
├── model.py # CNN architecture
├── train.py # Training script with graphs
├── draw.py # GUI for drawing digits and visualization
├── graphs/ # Example plots (accuracy, loss, feature maps)
└── README.md
- Draw digits directly on a 280x280 canvas.
- Real-time prediction of digits 0–9.
- Clear the canvas at any time to draw a new digit.
- Input image as seen by the CNN.
- Softmax probabilities for all 10 digits.
- Feature maps from the first convolutional layer (reveals learned patterns).
- Track accuracy and loss during training.
- Graphs illustrate how the CNN improves over epochs.
By exploring this project, you will understand:
- How to implement and train a CNN in PyTorch.
- How to preprocess images for model input.
- How to integrate a PyTorch model with a Tkinter GUI.
- How to visualize CNN internals and prediction probabilities.
- How to interpret training graphs and model performance.
git clone https://github.com/Aitaneuh/mnist-cnn.git
cd mnist-cnn
pip install -r requirements.txt
python train.py # Train the model
python draw.py # Launch the drawing GUI


