dogandcat / app.py
chun
Update app.py
b509c08
raw
history blame
943 Bytes
from keras.models import load_model
import numpy as np
from keras.preprocessing import image
import gradio as gr
from PIL import Image
def a(img):
img = img.reshape( 64,64,3)
model=load_model('./cats&dog.h5')
test_image=np.expand_dims(img, axis=0)
result=model.predict(test_image)
if result[0][0]==1:
prediction='Dog'
print(prediction)
return prediction
else:
prediction='Cat'
print(prediction)
return prediction
input = gr.inputs.Image(type='pil', label="Original Image", source="upload", optional=True)
inputs = [input]
outputs = gr.outputs.Image(type="pil", label="Output Image")
title = "Dog and Cat Object detection"
image = gr.inputs.Image(shape=(64,64))
demo=gr.Interface(fn=a, inputs=image,examples=["photo/a01.jpg", "photo/a02.jpg","photo/a03.jpg","photo/a04.jpg"],outputs="text").launch(debug='True')
if __name__ == "__main__":
demo.launch()