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
File size: 3,288 Bytes
abed3f0 0d8a1ba abed3f0 0d8a1ba | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | ---
language: en
tags:
- image-classification
- pytorch
- tensorflow
- scikit-learn
- mnist
- computer-vision
datasets:
- mnist
metrics:
- accuracy
---
# MNIST Framework Bake-off Models
## Model Details
This repository contains pre-trained model weights for handwritten digit classification (0-9) trained on the MNIST dataset.
It was developed as part of an end-to-end MLOps and framework benchmarking portfolio project.
Three distinct architectures are hosted here to demonstrate the trade-offs between deep learning and classical machine learning on spatial data:
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.
2. **Random Forest Classifier (Scikit-Learn) (`sklearn_rf.joblib`):** A baseline classical Machine Learning architecture to establish performance bounds before applying deep learning.
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.
* **Developed by:** AKinoshi
* **Model Date:** July 2026
* **Model Type:** Image Classification
* **License:** MIT
## Intended Use
* **Primary Use Case:** Educational benchmarking and portfolio demonstration of framework agility and model deployment.
* **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.
## Training Data
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.
* **Preprocessing (PyTorch / TensorFlow):** Pixel values normalized to a range of [-1, 1] or [0, 1] with an explicit channel dimension added.
* **Preprocessing (Scikit-Learn):** MinMax scaling applied to flatten 1D arrays, scaling intensities from [0, 255] down to [0, 1].
## Evaluation Metrics
Models were evaluated using **Accuracy** and a detailed classification report (Precision, Recall, F1-Score) on a 20% holdout test set.
* **CNN:** ~99.08% Test Accuracy. Demonstrates excellent spatial feature extraction through convolutional filters.
* **Random Forest Classifier:** ~96.75% Test Accuracy. Fast CPU training, but loses spatial hierarchy due to image flattening.
* **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.
## How to Get Started with the Model
You can dynamically download these weights directly into your Python scripts using the `huggingface_hub` library.
```python
# pip install huggingface_hub torch
import torch
from huggingface_hub import hf_hub_download
# 1. Download the PyTorch weights (caches automatically)
model_path = hf_hub_download(
repo_id="AKinoshi/mnist-framework-bakeoff",
filename="pytorch_cnn_weights.pth"
)
# 2. Load into your PyTorch architecture
# model = DigitClassifierCNN()
# model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
# model.eval() |