Fowl-Faeces / app.py
abdulsamod's picture
Update app.py
cc2ee79
Raw
History Blame Contribute Delete
1.12 kB
# -*- coding: utf-8 -*-
"""app
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/17bhnzAMKk6EBY64ESpv0omIba_RfKJfn
"""
import gradio as gr
import numpy as np
from keras.preprocessing import image
#loading the saved model
from keras.models import load_model
model = load_model('project_model.h5')
labels = ['Healthy','Unhealthy'] #classes
def classify_image(inp):
img = inp.reshape((25,25,3)) #reshape input image
#img=image.img_to_array(img)
x=np.expand_dims(img, axis=0)
images = np.vstack([x])
if model.predict(images)[0][0] ==1:
return "Healthy"
elif model.predict(images)[0][1] ==1:
return "Unhealthy"
else:
return "Error"
#prediction = model.predict(img).tolist()[2] #prediction
#return {labels[i]: prediction[i] for i in range(2)} #return classes
title = "Coccidiosis Detection"
image = gr.inputs.Image(shape=(25, 25))
label = gr.outputs.Label(num_top_classes=1)
gr.Interface(fn=classify_image, inputs=image, outputs=label,title=title, capture_session=True).launch(debug=True)
#end