Spaces:
Sleeping
Sleeping
Upload 6 files
Browse files- .gitattributes +2 -0
- 0021_0060.JPG +3 -0
- README.md +23 -12
- app.py +47 -0
- efficientnet_model.keras +3 -0
- examples.zip +3 -0
- requirements.txt +4 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ 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 |
+
0021_0060.JPG filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
efficientnet_model.keras filter=lfs diff=lfs merge=lfs -text
|
0021_0060.JPG
ADDED
|
|
Git LFS Details
|
README.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Plant Disease Detector
|
| 2 |
+
|
| 3 |
+
This is a Gradio demo of a fruit and leaf disease classification model trained using EfficientNetB0.
|
| 4 |
+
|
| 5 |
+
## π§ Model
|
| 6 |
+
- Architecture: EfficientNetB0
|
| 7 |
+
- Input Size: 160x160
|
| 8 |
+
- Classes: 21 different fruit and leaf disease types
|
| 9 |
+
- Trained using TensorFlow / Keras
|
| 10 |
+
- Accuracy: ~99.5% (train), ~98.5% (val)
|
| 11 |
+
|
| 12 |
+
## πΌοΈ Usage
|
| 13 |
+
Upload an image of a fruit or leaf, and the model will predict its disease type.
|
| 14 |
+
|
| 15 |
+
## π§ͺ Example Images
|
| 16 |
+
You can use sample images provided in the `examples/` folder.
|
| 17 |
+
|
| 18 |
+
## π§ Requirements
|
| 19 |
+
All dependencies are listed in `requirements.txt`.
|
| 20 |
+
|
| 21 |
+
## πββοΈ Author
|
| 22 |
+
**Aarzoo Singh**, Research Intern
|
| 23 |
+
B.Tech CSE, NIT Patna
|
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
from tensorflow.keras.applications.efficientnet import preprocess_input
|
| 4 |
+
from tensorflow.keras.preprocessing import image
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
model = tf.keras.models.load_model("efficientnet_final_model.keras")
|
| 8 |
+
|
| 9 |
+
CLASS_NAMES = [
|
| 10 |
+
"Pomegranate__diseased", "mango_Sooty Mould", "mango_Powdery Mildew",
|
| 11 |
+
"mango_Healthy", "mango_Gall Midge", "mango_Die Back",
|
| 12 |
+
"mango_Cutting Weevil", "mango_Bacterial Canker", "mango_Anthracnose",
|
| 13 |
+
"guava_Healthy", "guava_Red Rust", "guava_Sooty Mould",
|
| 14 |
+
"guava_Algal Leaf Spot", "guava_Rust", "lime_Greening",
|
| 15 |
+
"lime_Canker", "lime_Healthy", "lime_Die Back",
|
| 16 |
+
"lime_Scab", "lime_Anthracnose", "lime_Sooty Mould"
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
def predict_disease(img):
|
| 20 |
+
img = img.resize((160, 160))
|
| 21 |
+
img_array = image.img_to_array(img)
|
| 22 |
+
img_array = preprocess_input(img_array)
|
| 23 |
+
img_array = np.expand_dims(img_array, axis=0)
|
| 24 |
+
|
| 25 |
+
prediction = model.predict(img_array)[0]
|
| 26 |
+
top_idx = np.argmax(prediction)
|
| 27 |
+
confidence = prediction[top_idx] * 100
|
| 28 |
+
label = CLASS_NAMES[top_idx]
|
| 29 |
+
|
| 30 |
+
return f"{label} ({confidence:.2f}%)"
|
| 31 |
+
|
| 32 |
+
interface = gr.Interface(
|
| 33 |
+
fn=predict_disease,
|
| 34 |
+
inputs=gr.Image(type="pil"),
|
| 35 |
+
outputs="text",
|
| 36 |
+
title="Fruit Leaf Disease Classifier πΏ",
|
| 37 |
+
description="Upload an image of a fruit/leaf and the model will classify the disease type.",
|
| 38 |
+
examples=[
|
| 39 |
+
["examples/Phytopthora.jpg"],
|
| 40 |
+
["examples/RedRust.jpg"],
|
| 41 |
+
["examples/HealthyMangoLeaf.jpg"],
|
| 42 |
+
["examples/LimeLeafSpotted.jpg"]
|
| 43 |
+
]
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
if __name__ == "__main__":
|
| 47 |
+
interface.launch()
|
efficientnet_model.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b2d5c4af1e257e80878b77f89b5f1d3c4f392701af69c3205e2f55884bc13e85
|
| 3 |
+
size 28183873
|
examples.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4b0871b2f0d7040dc6f139362f5cc6fded0771c34da386a4208705d5ca1a06d3
|
| 3 |
+
size 1567599
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
tensorflow
|
| 3 |
+
numpy
|
| 4 |
+
pillow
|