File size: 1,356 Bytes
8b7cb0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ee8c0b
8b7cb0c
 
 
 
 
 
 
 
8ee8c0b
8b7cb0c
 
 
 
8ee8c0b
 
8b7cb0c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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)