Instructions to use akinoshi/mnist-framework-backoff with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use akinoshi/mnist-framework-backoff with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://akinoshi/mnist-framework-backoff") - Notebooks
- Google Colab
- Kaggle
Upload Model Card
Browse files
README.md
CHANGED
|
@@ -1,3 +1,68 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language: en
|
| 3 |
+
tags:
|
| 4 |
+
- image-classification
|
| 5 |
+
- pytorch
|
| 6 |
+
- tensorflow
|
| 7 |
+
- scikit-learn
|
| 8 |
+
- mnist
|
| 9 |
+
- computer-vision
|
| 10 |
+
datasets:
|
| 11 |
+
- mnist
|
| 12 |
+
metrics:
|
| 13 |
+
- accuracy
|
| 14 |
---
|
| 15 |
+
|
| 16 |
+
# MNIST Framework Bake-off Models
|
| 17 |
+
|
| 18 |
+
## Model Details
|
| 19 |
+
This repository contains pre-trained model weights for handwritten digit classification (0-9) trained on the MNIST dataset.
|
| 20 |
+
It was developed as part of an end-to-end MLOps and framework benchmarking portfolio project.
|
| 21 |
+
|
| 22 |
+
Three distinct architectures are hosted here to demonstrate the trade-offs between deep learning and classical machine learning on spatial data:
|
| 23 |
+
|
| 24 |
+
1. **CNN (PyTorch & TensorFlow) (`pytorch_cnn_weights.pth`, `tf_cnn_model.keras`):** A Convolutional Neural Network designed for high accuracy and $O(1)$ inference latency.
|
| 25 |
+
2. **Random Forest Classifier (Scikit-Learn) (`sklearn_rf.joblib`):** A baseline classical Machine Learning architecture to establish performance bounds before applying deep learning.
|
| 26 |
+
3. **Soft-Voting Ensemble (Scikit-Learn) (`sklearn_ensemble.joblib`):** An ensemble combining a Multi-Layer Perceptron (MLP) and a K-Nearest Neighbors (K-NN) classifier.
|
| 27 |
+
|
| 28 |
+
* **Developed by:** AKinoshi
|
| 29 |
+
* **Model Date:** July 2026
|
| 30 |
+
* **Model Type:** Image Classification
|
| 31 |
+
* **License:** MIT
|
| 32 |
+
|
| 33 |
+
## Intended Use
|
| 34 |
+
* **Primary Use Case:** Educational benchmarking and portfolio demonstration of framework agility and model deployment.
|
| 35 |
+
* **Out-of-Scope:** This model is trained exclusively on cleanly centered, 28x28 grayscale digits. It is not intended for general-purpose Optical Character Recognition (OCR) on real-world, noisy documents or alphabetic text.
|
| 36 |
+
|
| 37 |
+
## Training Data
|
| 38 |
+
The models were trained on the **MNIST dataset**, which consists of 70,000 images of handwritten digits normalized to fit into a 28x28 pixel bounding box and anti-aliased.
|
| 39 |
+
* **Preprocessing (PyTorch / TensorFlow):** Pixel values normalized to a range of [-1, 1] or [0, 1] with an explicit channel dimension added.
|
| 40 |
+
* **Preprocessing (Scikit-Learn):** MinMax scaling applied to flatten 1D arrays, scaling intensities from [0, 255] down to [0, 1].
|
| 41 |
+
|
| 42 |
+
## Evaluation Metrics
|
| 43 |
+
Models were evaluated using **Accuracy** and a detailed classification report (Precision, Recall, F1-Score) on a 20% holdout test set.
|
| 44 |
+
|
| 45 |
+
* **CNN:** ~99.08% Test Accuracy. Demonstrates excellent spatial feature extraction through convolutional filters.
|
| 46 |
+
* **Random Forest Classifier:** ~96.75% Test Accuracy. Fast CPU training, but loses spatial hierarchy due to image flattening.
|
| 47 |
+
* **Scikit-Learn Ensemble:** ~98.33% Test Accuracy. While highly accurate, the K-NN component introduces significant inference latency $O(N \times D)$, making it less suitable for real-time production endpoints compared to the compiled CNN.
|
| 48 |
+
|
| 49 |
+
## How to Get Started with the Model
|
| 50 |
+
|
| 51 |
+
You can dynamically download these weights directly into your Python scripts using the `huggingface_hub` library.
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
# pip install huggingface_hub torch
|
| 55 |
+
|
| 56 |
+
import torch
|
| 57 |
+
from huggingface_hub import hf_hub_download
|
| 58 |
+
|
| 59 |
+
# 1. Download the PyTorch weights (caches automatically)
|
| 60 |
+
model_path = hf_hub_download(
|
| 61 |
+
repo_id="AKinoshi/mnist-framework-bakeoff",
|
| 62 |
+
filename="pytorch_cnn_weights.pth"
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
# 2. Load into your PyTorch architecture
|
| 66 |
+
# model = DigitClassifierCNN()
|
| 67 |
+
# model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
|
| 68 |
+
# model.eval()
|