Instructions to use Madhav073/mnist-digit-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Madhav073/mnist-digit-classifier with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://Madhav073/mnist-digit-classifier") - Notebooks
- Google Colab
- Kaggle
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