import gradio as gr from tensorflow import keras import numpy as np from PIL import Image model = keras.models.load_model('dog_cat.keras') def classify_image(image): image = image.resize((255, 255)) img_array = np.array(image) / 255.0 img_array = np.expand_dims(img_array, axis=0) print(img_array.shape) # Predict using the model prediction = model.predict(img_array)[0][0] # Interpret the prediction if prediction > 0.50: result = "Dog" else: result = "Cat" return result # Gradio Interface demo = gr.Interface( fn=classify_image, inputs=gr.Image(type='pil'), outputs="text", title="Dog vs Cat Classifier", description="Upload an image to classify it as a Dog or Cat." ) # Launch the app demo.launch()