Spaces:
Sleeping
Sleeping
from PIL import Image | |
import numpy as np | |
import gradio as gr | |
import keras | |
model = keras.models.load_model('CATvsDOG.keras') | |
def classify_image(image): | |
img = Image.open(image) | |
# Preprocess the image | |
img = img.resize((100, 100)) | |
img_array = np.array(img) | |
img_array = np.expand_dims(img_array, axis=0) | |
# Make predictions | |
predictions = model.predict(img_array) | |
if predictions[0][0] > 0.5: | |
return "Dog" | |
else: | |
return "Cat" | |
interface = gr.Interface(fn=classify_image, inputs="file", outputs="label", title="Cat or Dog Classifier") | |
interface.launch(share=True) |