ak0601's picture
Update app.py
dfb96ee
raw
history blame
666 Bytes
import gradio as gr
import tensorflow as tf
from tensorflow.keras.preprocessing import image
import matplotlib.pyplot as plt
import numpy as np
model = tf.keras.models.load_model('dogcat_model_bak.h5')
def image_classifier(img):
img1 = image.load_img(str(img), target_size=(64, 64))
img1 = image.img_to_array(img1)
img1 = img1/255
img1 = np.expand_dims(img1, axis=0)
res = model.predict(img, batch_size=None,steps=1)
if(res[:,:]>0.5):
value ='Dog :%1.2f'%(prediction[0,0])
else:
value ='Cat :%1.2f'%(1.0-prediction[0,0])
return value
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
demo.launch()