wizzseen/binary_classification
0
1import cv22from tensorflow.keras.models import load_model3import gradio as gr4import tensorflow as tf5import cv26import numpy as np7from tensorflow.keras.models import load_model8from tensorflow.keras.models import load_model9from tensorflow.keras.preprocessing import image10import numpy as np11 12# Load the trained model13model = load_model('cat_classifier_model.h5')14 15def predict_cat(image_pil):16 img_resized = image_pil.resize((224, 224))17 18 img_array = np.array(img_resized)19 img_array = np.expand_dims(img_array, axis=0)20 img_array = img_array / 255.021 prediction = model.predict(img_array)22 if prediction[0][0] > 0.5:23 return "not a tablet"24 else:25 return "is a tablet"26 27# Create a Gradio interface28iface = gr.Interface(29 fn=predict_cat,30 inputs=gr.Image(type='pil', label='Upload an image of a tablet'),31 outputs='text'32)33 34# Launch the interface with share=True to create a public link35iface.launch(share=True)36 37 38 39 40 41 42 43 44 