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("

Paddy Pest Disease Classification App

") 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)