# -*- coding: utf-8 -*- """interface.ipynb Automatically generated by Colab. Original file is located at https://colab.research.google.com/drive/1GvHbtJDns2rWyk-OdqSP-90yAbWY4ctR """ import gradio as gr import tensorflow as tf import numpy as np from tensorflow.keras.preprocessing import image # Load your trained model model = tf.keras.models.load_model('cat_dog_classifier.h5') # Define prediction functiond def predict(img): img = img.resize((160, 160)) img_array = image.img_to_array(img) / 255.0 img_array = np.expand_dims(img_array, axis=0) prediction = model.predict(img_array)[0][0] return "🐶 It's a Dog!" if prediction > 0.5 else "🐱 It's a Cat!" # Create Gradio interface interface = gr.Interface( fn=predict, inputs=gr.Image(type="pil", label="Upload an Image"), outputs=gr.Textbox(label="Prediction"), title="Cat vs Dog Classifier 🐾", description="Upload an image to find out if it's a cat or a dog!" ) # Launch interface interface.launch()