Spaces:
Sleeping
Sleeping
from keras.models import load_model | |
import cv2 | |
import gradio as gr | |
import numpy as np | |
loaded_model = load_model('model.h5') | |
def predict(img): | |
img = img['composite'][:,:,3]/255.0 | |
img = cv2.resize(img, (28, 28)) | |
prediction = np.argmax(loaded_model.predict(np.array([img]) ,verbose=0)) | |
return prediction | |
input = [gr.Sketchpad(label="Sketchpad", canvas_size= (600,600) , image_mode = "RGBA")] | |
interface = gr.Interface( | |
fn=predict, | |
inputs=input, | |
outputs="textbox", | |
title="MNIST Handwritten Digit Recognition by Johnson Manuel", | |
description="Draw digits from 0 to 9 to see real-time recognition by a neural network trained on the MNIST dataset." ,live=True | |
) | |
interface.launch() |