CoolFace
Modelpublic

Madhav073/mnist-digit-classifier

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes1downloads
Model Card

๐Ÿง  MNIST Handwritten Digit Classifier

A simple yet effective neural network built using TensorFlow and Keras to classify handwritten digits (0โ€“9) from the MNIST dataset.

This project serves as a beginner-friendly example of training, evaluating, and publishing a machine learning model on the Hugging Face Model Hub.


๐Ÿ“Œ Model Information

PropertyValue
FrameworkTensorFlow / Keras
Model TypeFeedforward Neural Network (Fully Connected)
DatasetMNIST
Input Shape(784,)
Output Classes10 (Digits 0โ€“9)
Training Accuracy98.24%
Test Accuracy96.86%

๐Ÿ—๏ธ Model Architecture

Input Layer (784)

        โ”‚

        โ–ผ

Dense (128 neurons, ReLU)

        โ”‚

        โ–ผ

Dense (64 neurons, ReLU)

        โ”‚

        โ–ผ

Dense (10 neurons, Softmax)

๐Ÿ“š Dataset

The model was trained on the MNIST Handwritten Digits Dataset, containing:

  • โ€”60,000 training images
  • โ€”10,000 testing images
  • โ€”Image Size: 28 ร— 28 pixels
  • โ€”Classes: 0โ€“9

Each image is flattened into a 784-dimensional vector before being passed into the neural network.


โš™๏ธ Preprocessing

The following preprocessing steps were applied:

  • โ€”Pixel values normalized to [0, 1]
  • โ€”Images flattened from 28ร—28 โ†’ 784
  • โ€”Labels encoded as integer class IDs

๐Ÿ“ˆ Performance

MetricScore
Training Accuracy98.24%
Test Accuracy96.86%

The small gap between training and test accuracy indicates that the model generalizes reasonably well on unseen data.


๐Ÿš€ Loading the Model

python
import tensorflow as tf

model = tf.keras.models.load_model("mnist_classifier.keras")

๐Ÿ” Making Predictions

python
import numpy as np
import tensorflow as tf

model = tf.keras.models.load_model("mnist_classifier.keras")

# image should be normalized and reshaped
image = image.reshape(1, 784)

prediction = model.predict(image)

predicted_digit = np.argmax(prediction)

print(predicted_digit)

๐Ÿ“ฆ Requirements

  • โ€”Python 3.10+
  • โ€”TensorFlow
  • โ€”NumPy

Install dependencies:

bash
pip install tensorflow numpy

๐Ÿ“ Repository Contents

.
โ”œโ”€โ”€ mnist_classifier.keras
โ”œโ”€โ”€ README.md

๐ŸŽฏ Intended Use

This model is intended for:

  • โ€”Learning TensorFlow and Keras
  • โ€”Educational purposes
  • โ€”MNIST handwritten digit classification
  • โ€”Demonstrating model deployment on Hugging Face

โš ๏ธ Limitations

  • โ€”Designed only for MNIST-style handwritten digits.
  • โ€”Expects grayscale images of handwritten digits.
  • โ€”Images should be preprocessed in the same way as the training data.

๐Ÿ“„ License

This project is released under the MIT License, allowing free use, modification, and distribution.


๐Ÿ‘จโ€๐Ÿ’ป Author

Madhav Maheshwari

If you find this project useful, consider giving it a โญ on Hugging Face.