Skip to content

This repository demonstrates a simple and effective implementation of a Convolutional Neural Network (CNN) using PyTorch to classify handwritten digits from the MNIST dataset. The project is beginner-friendly and serves as a great introduction to deep learning and image classification using CNNs.

License

Notifications You must be signed in to change notification settings

BhargavBJ/MNIST

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ§ πŸ”’ MNIST CNN Digit Classifier

This project implements a Convolutional Neural Network (CNN) using PyTorch to classify handwritten digits from the MNIST dataset. It is designed to be simple yet powerful, and supports both training and inference, including prediction on custom user-uploaded images.


πŸš€ Features

  • βœ… CNN architecture built from scratch using PyTorch
  • πŸ“ˆ Achieves ~98% test accuracy on MNIST
  • πŸ–ΌοΈ Upload and classify your own digit images (e.g., .png, .jpg)
  • πŸ” Includes visualization of preprocessing steps and predictions
  • πŸ“‰ Evaluation with loss and accuracy tracking
  • ⚑ GPU acceleration with CUDA support (via Google Colab)

πŸ“š Dataset

  • MNIST: A standard benchmark dataset of 28x28 grayscale images of handwritten digits (0–9).
  • Automatically loaded via torchvision.datasets.MNIST.

πŸ§ͺ How to Use (Google Colab)

This project is developed and runs entirely in Google Colab, so no local setup is required.

  1. πŸ“‚ Clone or download the repository.
  2. 🧭 Open mnist_cnn_digit_classifier.ipynb in Google Colab.
  3. ▢️ Run each code cell in order:
    • Trains the CNN model from scratch
    • Evaluates performance on the test set
    • Accepts custom digit images for prediction
  4. πŸ“€ Upload a test image (28x28 or will be resized).
    • Make sure it's a black digit on a white background.
    • Inversion is handled automatically if needed.
  5. πŸ” View the predicted result with visual feedback.

🧱 Project Structure

MNIST-CNN-Digit-Classifier/ β”œβ”€β”€ mnist_cnn_digit_classifier.ipynb # Main Colab notebook β”œβ”€β”€ README.md

Project overview and instructions

└── images/ (Optional) Folder for custom test images └── 1.jpg


πŸ›  Requirements (For Local Use)

If you want to run it locally instead of Colab, install the following(only if your device has a GPU):

pip install torch torchvision matplotlib pillow

πŸ“¬ Author

Built with ❀️ using PyTorch & Google Colab by Bhargav.

About

This repository demonstrates a simple and effective implementation of a Convolutional Neural Network (CNN) using PyTorch to classify handwritten digits from the MNIST dataset. The project is beginner-friendly and serves as a great introduction to deep learning and image classification using CNNs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published