import gradio as gr | |
import numpy as np | |
import tensorflow as tf | |
import tensorflow_hub as hub | |
loaded_model = tf.keras.models.load_model( | |
('CatDogmodel.h5'), | |
custom_objects={'KerasLayer':hub.KerasLayer} | |
) | |
def model(image): | |
im_scaled = image/255 | |
im_reshape = np.reshape(im_scaled,[1,224,224,3]) | |
pred = loaded_model.predict(im_reshape) | |
if (pred == 0): | |
return "The Image is of a Dog." | |
if (pred == 1): | |
return "The Image is of a Cat." | |
image = gr.inputs.Image(shape=(224,224)) | |
iface = gr.Interface(fn=model, inputs=image, outputs='text') | |
iface.launch(debug=True) |