Spaces:
Sleeping
Sleeping
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() | |