File size: 1,949 Bytes
6209161
 
 
 
 
 
 
 
 
 
 
 
746d998
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: Mnist Comparison
emoji: πŸ“š
colorFrom: purple
colorTo: gray
sdk: streamlit
sdk_version: 1.37.0
app_file: app.py
pinned: false
license: mit
---

# MNIST Streamlit

This is a simple Streamlit app that demonstrates the differences between neural nets trained on the 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

## 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
```