Upload 3 files
Browse files- .gitattributes +1 -0
- MNISTapp.py +67 -0
- MNISTmodel.keras +3 -0
- requirements.txt +1 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
MNISTmodel.keras filter=lfs diff=lfs merge=lfs -text
|
MNISTapp.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
import streamlit as st
|
| 5 |
+
from tensorflow.keras.models import load_model
|
| 6 |
+
from streamlit_drawable_canvas import st_canvas
|
| 7 |
+
|
| 8 |
+
model = load_model('MNISTmodel.keras')
|
| 9 |
+
|
| 10 |
+
st.title('Hand Written Digit Classification')
|
| 11 |
+
st.header('Liam Frank')
|
| 12 |
+
st.write('Shallow Convolutional Neural Network trained on MNIST dataset')
|
| 13 |
+
st.write("\n" * 4)
|
| 14 |
+
|
| 15 |
+
col1, col2 = st.columns(2)
|
| 16 |
+
SIZE=200
|
| 17 |
+
|
| 18 |
+
with col1:
|
| 19 |
+
st.subheader('Draw a Digit 0-9:')
|
| 20 |
+
canvas_result = st_canvas(
|
| 21 |
+
fill_color='#000000',
|
| 22 |
+
stroke_width=20,
|
| 23 |
+
stroke_color='#FFFFFF',
|
| 24 |
+
background_color='#000000',
|
| 25 |
+
width=SIZE,
|
| 26 |
+
height=SIZE,
|
| 27 |
+
drawing_mode="freedraw",
|
| 28 |
+
key='canvas'
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
if canvas_result.image_data is not None:
|
| 32 |
+
img = cv2.resize(canvas_result.image_data.astype('uint8'), (28, 28))
|
| 33 |
+
rescaled = cv2.resize(img, (SIZE, SIZE), interpolation=cv2.INTER_NEAREST)
|
| 34 |
+
|
| 35 |
+
with col2:
|
| 36 |
+
st.subheader('Pixelated Model Input:')
|
| 37 |
+
st.image(rescaled)
|
| 38 |
+
|
| 39 |
+
st.markdown("""
|
| 40 |
+
<style>
|
| 41 |
+
div.stButton > button {
|
| 42 |
+
width: 200px;
|
| 43 |
+
height: 50px;
|
| 44 |
+
font-size: 20px;
|
| 45 |
+
font-weight: bold;
|
| 46 |
+
color: white;
|
| 47 |
+
border: none;
|
| 48 |
+
border-radius: 8px;
|
| 49 |
+
cursor: pointer;
|
| 50 |
+
transition: color 0.3s ease; background-color 0.3s ease;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
div.stButton > button:hover {
|
| 54 |
+
background-color: white;
|
| 55 |
+
color: black;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
</style>
|
| 59 |
+
""", unsafe_allow_html=True)
|
| 60 |
+
|
| 61 |
+
if st.button('Predict'):
|
| 62 |
+
with st.spinner("Making prediction..."):
|
| 63 |
+
test_x = img[:, :, 0]
|
| 64 |
+
test_x = test_x / 255.0
|
| 65 |
+
val = model.predict(test_x.reshape(1, 28, 28))
|
| 66 |
+
st.metric("Result:", np.argmax(val[0]))
|
| 67 |
+
|
MNISTmodel.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28eab509dc91143c9da8e334fad514b3d2ae2db8f63fe911d09aeb85a60710ef
|
| 3 |
+
size 1368302
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
cv2==4.10.0
|