File size: 607 Bytes
fd05b1c
3c42fee
 
 
 
 
 
 
 
2238089
3c42fee
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)