Spaces:
Runtime error
Runtime error
ibrahim yıldız commited on
Upload 2 files
Browse filesFiles changed (2)
- app.pyAdded+40
- digit_model.h5Added+3
12345678910111213141516171819202122232425262728293031323334353637383940import streamlit as stfrom streamlit_drawable_canvas import st_canvasimport numpy as npfrom PIL import Imageimport tensorflow as tffrom tensorflow.keras.models import load_model
# pip install streamlit-drawable-canvas
model = load_model("digit_model.h5")
st.title("Digit Recognition :writing_hand:")st.write("Write a number between 0-9 on the board and let's see if the model can identify it!")st.write('(it lives some hard time predicting 1. try to fill the whole space equaly.)')
numbers=[":zero:", ":one:", ":two:", ":three:", ":four:", ":five:", ":six:", ":seven:", ":eight:", ":nine:"]
canvas_result = st_canvas( stroke_width=20, stroke_color="rgb(255, 255, 255)", background_color="rgb(33, 62, 40)", update_streamlit=True, width=200, height=200, drawing_mode="freedraw", key="canvas",)if st.button("Predict"): image_data = np.array(canvas_result.image_data) image_data = image_data.astype(np.uint8) image = Image.fromarray(image_data) image = image.resize((28, 28)).convert("L") image = np.array(image).reshape((1, 28, 28, 1)) / 255.0
prediction = model.predict(image) predicted_class = np.argmax(prediction) st.write(f"Your number is {numbers[predicted_class]} If this was wrong, your handwriting sucks!")
st.image("https://i.ytimg.com/vi/NlUVkNJ3Rcw/maxresdefault.jpg")123version https://git-lfs.github.com/spec/v1oid sha256:442fec1bc3a965146a4ce13413f210a8f433014f7c324fffee4b6557b2f63edasize 7150272app.pyAdded+40
digit_model.h5Added+3