MNIST Pattern Recognition with Convolutional Neural Network (CNN)

This project implements a Convolutional Neural Network (CNN) for recognizing handwritten digits from the MNIST dataset. The model is built using TensorFlow and Keras, and it supports both single-GPU and multi-GPU training. The project includes training, testing, and a user-friendly GUI for inference.

Features

  • Customizable CNN Architecture: Includes convolutional, pooling, normalization, and dense layers.
  • Multi-GPU Support: Leverages TensorFlow's MirroredStrategy for distributed training.
  • Training Visualization: Generates plots for training/validation accuracy and loss.
  • Evaluation Metrics: Outputs confusion matrix, classification report, and precision/recall/F1 scores.
  • Interactive GUI: Built with Streamlit for real-time image recognition.
  • Docker Support: Easily deployable using Docker.

Model Architecture

image
The CNN model consists of:

  1. Two convolutional layers with ReLU activation and max-pooling.
  2. Layer normalization for improved convergence.
  3. Fully connected dense layers with dropout for regularization.
  4. Softmax output layer for classification into 10 digit classes.

Training

The model is trained on the MNIST dataset, which contains 60,000 training images and 10,000 test images of handwritten digits (28x28 grayscale). The training process includes:

  • Data normalization to scale pixel values to the range [0, 1].
  • Categorical cross-entropy loss and accuracy as the evaluation metric.
  • Model checkpointing to save the best-performing model based on validation accuracy.

Final result

Training history image

Confusion matrix image

Classification report image

Test result image

Full code at Github

Downloads last month
1
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train longdnk20/CNN_MNIST