Spaces:
Sleeping
Sleeping
File size: 843 Bytes
8210d01 | 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 | import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
# trained model load
# Purana code: model = tf.keras.models.load_model("model.h5")
# Naya code (Sahi naam ke saath):
model = tf.keras.models.load_model("plant_disease_model.keras")
# 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()
|