Madhav073/mnist-digit-classifier
๐ง 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
๐๏ธ 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
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.
