# Importing Necessary Libraries import tensorflow as tf import cv2 import numpy as np import gradio as gr # Importing the Model def model(up_img): cnn = tf.keras.models.load_model("Handwritten_Digit_Recognition_Model.h5") #import image gray_image = cv2.cvtColor(up_img, cv2.COLOR_BGR2GRAY) #preprocess gray_image = np.expand_dims(gray_image, axis = -1) gray_image = gray_image.reshape((-1, 28, 28, 1)) #predict prediction = cnn.predict(gray_image) #converting the float values to int values for y_test prediction = np.argmax(prediction, axis = 1) return "The input digit is: {}".format(int(prediction)) # Running the Model on Gradio demo = gr.Interface(fn = model, inputs = 'image', outputs = 'text') demo.launch()