YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

🧠 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

Property Value
Framework TensorFlow / Keras
Model Type Feedforward Neural Network (Fully Connected)
Dataset MNIST
Input Shape (784,)
Output Classes 10 (Digits 0–9)
Training Accuracy 98.24%
Test Accuracy 96.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

Metric Score
Training Accuracy 98.24%
Test Accuracy 96.86%

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


πŸš€ Loading the Model

import tensorflow as tf

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

πŸ” Making Predictions

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:

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.

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