Mnist-Digits / app.py
cisemh's picture
Update app.py
64c61da verified
raw
history blame
732 Bytes
import cv2
import gradio as gr
import tensorflow as tf
import numpy as np
# Model yükleniyor
model = tf.keras.models.load_model("number_recognition_model_colab.keras")
def predict(img):
# Preprocess the input image
img = img.reshape(1, 28, 28) / 255.0
# Make the prediction
prediction = model.predict(img)
predicted_digit = np.argmax(prediction[0])
return predicted_digit
# Create the Gradio interface
with gr.Blocks() as demo:
gr.Markdown("Welcome on your first sketch recognition app!")
with gr.Row():
sketchpad = gr.Sketchpad(shape=(28, 28))
output = gr.Text()
btn = gr.Button("Submit")
btn.click(predict, inputs=sketchpad, outputs=output)
demo.launch()