Rehman1603's picture
Update app.py
8ee8c0b verified
from keras.models import load_model
import cv2
import gradio as gr
import os
pox_model = load_model('fowl_pox_model.keras', compile=True)
class_name = {0: 'Healthy', 1: 'Chicken have fowl pox', 2: 'Unknown'}
status = {0: 'Non Critical', 1: 'Critical', 2: 'N/A'}
recommend = {0: 'No need medicine', 1: 'Panadol', 2: 'N/A'}
def predict(img):
# Resize the image to the required size for the model
img_resized = cv2.resize(img, (256, 256))
# Make the prediction
pred = pox_model.predict(img_resized.reshape(1, 256, 256, 3)).argmax()
# Get the prediction details
prediction_label = class_name[pred]
prediction_status = status[pred]
recommendation = recommend[pred]
return prediction_label, prediction_status, recommendation
interface = gr.Interface(
fn=predict,
inputs='image',
outputs=[
gr.components.Textbox(label='Disease Name'),
gr.components.Textbox(label='Disease status'),
gr.components.Textbox(label='Disease medicine')
],
examples=[
['download (1).jpeg'], ['download (2).jpeg'], ['download (3).jpeg'],
['images (1).jpeg'], ['images (2).jpeg'], ['images (3).jpeg']
],
description="Upload an image of a chicken to predict if it has fowl pox. You will receive a status report and a recommended treatment."
)
interface.launch(debug=True)