minima / app.py
M. Saad Munawar
https://huggingface.co/spaces/Saad123/minima
7874eca
raw
history blame
821 Bytes
import gradio as gr
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
loaded_model = tf.keras.models.load_model(
('CatDogmodel2.h5'),
custom_objects={'KerasLayer':hub.KerasLayer}
)
def model(image):
im_scaled = image/255
im_reshape = np.reshape(im_scaled,[1,160,160,3])
pred = loaded_model.predict(im_reshape)
pred_label = np.argmax(pred)
if (pred_label == 0):
return "The Image is of a Dog."
if (pred_label == 1):
return "The Image is of a Cat."
image = gr.inputs.Image(shape=(160,160))
css_code='body{background-image:url("https://cdn.shopify.com/s/files/1/0017/4024/2996/articles/the-magic-of-black-cats-dogs-188729.png?v=1606316714");}'
iface = gr.Interface(fn=model, inputs=image, outputs='text', css=css_code)
iface.launch(debug=True)