Skip to content

Aitaneuh/mnist-cnn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MNIST CNN

Python PyTorch Mnist Accuracy Epochs Epochs

mnist

Overview

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).

The MNIST CNN Online

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.


Project Structure

├── 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

Features

Interactive Drawing & Prediction

  • 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.

Model Visualizations (Debug Mode)

  • Input image as seen by the CNN.
  • Softmax probabilities for all 10 digits.
  • Feature maps from the first convolutional layer (reveals learned patterns).

Training Progress

  • Track accuracy and loss during training.
  • Graphs illustrate how the CNN improves over epochs.

Results & Visualizations

Loss and Accuracy over 50 Epochs

Accuracy Graph

Debug Window (with number 1)

Debug Window

Tkinter GUI Screenshot

GUI Screenshot


Learning Outcomes

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.

Installation

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

About

An interactive handwritten digit recognition project powered by CNN

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages