Paushigaa's picture
Update app.py
a9b47ac
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/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 using CNN</h1></center>")
gr.Markdown("<center><h3>This application can classify 10 different diseases caused by pest attack on paddy leaves</h></center>")
with gr.Tabs():
with gr.TabItem("Select your image"):
with gr.Row():
with gr.Column():
img_source = gr.Image(label="Please select source Image", shape=(256, 256))
source_image_loader = gr.Button("Load above Image")
with gr.Column():
output = gr.Textbox(label="Image Info")
source_image_loader.click(predict_image,img_source,output)
my_app.launch(debug=True)