AreehaNasir's picture
Upload 3 files
8f6cde3 verified
Raw
History Blame Contribute Delete
740 Bytes
import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
# trained model load
model = tf.keras.models.load_model("plant_disease_model.h5")
# prediction function
def predict_plant(img):
# resize same as training
img = img.resize((150,150))
img_array = np.array(img)/255.0
# batch dimension add
img_array = np.expand_dims(img_array, axis=0)
prediction = model.predict(img_array)[0][0]
if prediction > 0.5:
return "Diseased Plant"
else:
return "Healthy Plant"
# interface
demo = gr.Interface(
fn=predict_plant,
inputs=gr.Image(type="pil"),
outputs="text",
title="Plant Disease Classifier"
)
demo.launch()