classTask / app.py
Abdurrehman999's picture
Update app.py
651b065 verified
Raw History Blame Contribute Delete
538 Bytes
import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
model = tf.keras.models.load_model("cat_dog_model (1).h5")
def predict(image):
img = image.resize((100,100))
img = np.array(img)/255.0
img = np.expand_dims(img, axis=0)
pred = model.predict(img)[0][0]
if pred > 0.5:
return "Dog 🐶"
else:
return "Cat 🐱"
interface = gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs="text",
title="Cat vs Dog Classifier"
)
interface.launch()