File size: 1,248 Bytes
1f4c82b
 
 
 
 
 
 
e92e7cd
1f4c82b
 
 
 
 
 
 
 
 
 
 
 
 
e92e7cd
1f4c82b
 
 
 
 
 
 
 
 
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
import gradio as gr
import tensorflow as tf
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.image import load_img, img_to_array
import numpy as np
from PIL import Image

model = load_model('model_extended.h5')

def predict_image(image):
    img_array = img_to_array(image)
    img_array = img_array.reshape((1, 256, 256, 3))
    img_array = img_array / 255.0
    predictions = model.predict(img_array)
    predicted_class_index = predictions.argmax()
    class_labels = ['bacterial_leaf_blight', 'bacterial_leaf_streak', 'bacterial_panicle_blight','blast','brown_spot','dead_heart','downy_mildew','hispa','normal','tungro' ]  # Replace with your actual class labels
    predicted_class_label = class_labels[predicted_class_index]
    return predicted_class_label

my_app = gr.Blocks()
with my_app:
  gr.Markdown("<center><h1>Paddy Pest Disease Classification App</h1></center>")
  with gr.Row():
    with gr.Column():
        img_source = gr.Image(label="Please select source Image", shape=(256, 256))
        source_image_loader = gr.Button("Load Image")
    with gr.Column():
        output = gr.Textbox(label="Image Info")
  source_image_loader.click(predict_image,img_source,output)

my_app.launch(debug=True)