mnist-comparison / README.md
jsulz's picture
jsulz HF staff
updating name of space
f3b9ddb
---
title: Neural Net Comparison on MNIST
emoji: πŸ‘€
colorFrom: yellow
colorTo: red
sdk: streamlit
sdk_version: 1.37.0
app_file: app.py
pinned: false
license: mit
tags: [MNIST, Onnx, Keras]
---
# MNIST Streamlit
This is a simple Streamlit app that demonstrates the differences between neural nets trained on the [MNIST dataset](https://yann.lecun.com/exdb/mnist/).
There are three models saved locally available in the `models` directory:
- `autokeras_model.keras`
- `mnist_12.onnx`
- `mnist_model.keras`
The `mnist_model.keras` is a simple 300x300 neural net trained over 35 epochs.
The `autokeras_model.keras` is a more complex model generated by running the [Autokeras image classifier class](https://autokeras.com/image_classifier/).
Meanwhile, the `mnist_12.onnx` model is a pre-trained model from theOnnx model zoo. Onnx provides detailed information about how the model was created [in the repository on GitHub](https://github.com/onnx/models/blob/main/validated/vision/classification/mnist/README.md).
The application allows you to:
1. Select which model you want to use for predicting a handwritten digit
2. Select your stroke width of the digit you draw
3. Draw a specific digit within a canvas
Once you draw a digit, the model will be loaded, asked to make a prediction on your input, and provide:
- The name of the model used to make the prediction
- A prediction (the top prediction from it's probability distribution)
- The time the model took to predict
- The time it took to load the model
- The probability distribution of predictions as a bar chart and table
If you change your selected model after drawing the digit, that same drawing will be used with the newly selected model.
To clear your "hand" drawn digit, click the trashcan icon under the drawing canvas.
## Usage
To run the Streamlit app locally using Poetry, clone the repository, `cd` into the created directory, and run the following commands:
- `poetry shell`
- `poetry install`
- `streamlit run app.py`
If you don't have Poetry installed, never fear! There is a `requirements.txt` file that you may use to install the necessary packages with Pip. Simply create a new virtual environment and run:
```shell
pip install -r requirements.txt
```