import scipy import gradio as gr import numpy as np import tensorflow as tf from tensorflow import keras from keras.models import load_model def cnn_model_binary(image): loaded_cnn_model = load_model("cnn_model_binary.h5") prediction = loaded_cnn_model.predict(np.asarray([image])) return "NO" if prediction[0][0] != 1 else "YES" input_image = gr.inputs.Image(shape=(28, 28), image_mode='L') output_label = gr.outputs.Textbox(label="Is the digit 1?") gr.Interface(fn=cnn_model_binary, inputs = input_image, outputs = output_label, title = "Predict whether the digit is 1 or not").launch(debug=True)