Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- .gitattributes +1 -0
- app.py +39 -0
- plant_disease_model.keras +3 -0
- requirements.txt +5 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
plant_disease_model.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
# trained model load
|
| 7 |
+
# Purana code: model = tf.keras.models.load_model("model.h5")
|
| 8 |
+
# Naya code (Sahi naam ke saath):
|
| 9 |
+
model = tf.keras.models.load_model("plant_disease_model.keras")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# prediction function
|
| 13 |
+
def predict_plant(img):
|
| 14 |
+
|
| 15 |
+
# resize same as training
|
| 16 |
+
img = img.resize((150,150))
|
| 17 |
+
|
| 18 |
+
img_array = np.array(img)/255.0
|
| 19 |
+
|
| 20 |
+
# batch dimension add
|
| 21 |
+
img_array = np.expand_dims(img_array, axis=0)
|
| 22 |
+
|
| 23 |
+
prediction = model.predict(img_array)[0][0]
|
| 24 |
+
|
| 25 |
+
if prediction > 0.5:
|
| 26 |
+
return "Diseased Plant"
|
| 27 |
+
else:
|
| 28 |
+
return "Healthy Plant"
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# interface
|
| 32 |
+
demo = gr.Interface(
|
| 33 |
+
fn=predict_plant,
|
| 34 |
+
inputs=gr.Image(type="pil"),
|
| 35 |
+
outputs="text",
|
| 36 |
+
title="Plant Disease Classifier"
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
demo.launch()
|
plant_disease_model.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:894352ae3fd774bd2fbd1db40492caea584c4cc91297b64dedbfb41def94cf35
|
| 3 |
+
size 57989321
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
tensorflow
|
| 2 |
+
gradio
|
| 3 |
+
numpy
|
| 4 |
+
pillow
|
| 5 |
+
tensorflow-datasets
|