Update README.md
Browse files
README.md
CHANGED
@@ -17,6 +17,10 @@ tags:
|
|
17 |
|
18 |

|
19 |
|
|
|
|
|
|
|
|
|
20 |
```py
|
21 |
Classification Report:
|
22 |
precision recall f1-score support
|
@@ -33,3 +37,74 @@ Bacterialblight 0.8853 0.9596 0.9210 1585
|
|
33 |
```
|
34 |
|
35 |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |

|
19 |
|
20 |
+
# **Rice-Leaf-Disease** 🌾
|
21 |
+
|
22 |
+
> **Rice-Leaf-Disease** is an image classification model fine-tuned from **google/siglip2-base-patch16-224** for detecting and categorizing diseases in rice leaves. It is built using the **SiglipForImageClassification** architecture and helps in early identification of plant diseases for better crop management.
|
23 |
+
>
|
24 |
```py
|
25 |
Classification Report:
|
26 |
precision recall f1-score support
|
|
|
37 |
```
|
38 |
|
39 |

|
40 |
+
|
41 |
+
### **Disease Categories:**
|
42 |
+
- **Class 0:** Bacterial Blight
|
43 |
+
- **Class 1:** Blast
|
44 |
+
- **Class 2:** Brown Spot
|
45 |
+
- **Class 3:** Healthy
|
46 |
+
- **Class 4:** Tungro
|
47 |
+
|
48 |
+
---
|
49 |
+
|
50 |
+
# **Run with Transformers 🤗**
|
51 |
+
|
52 |
+
```python
|
53 |
+
!pip install -q transformers torch pillow gradio
|
54 |
+
```
|
55 |
+
|
56 |
+
```python
|
57 |
+
import gradio as gr
|
58 |
+
from transformers import AutoImageProcessor, SiglipForImageClassification
|
59 |
+
from transformers.image_utils import load_image
|
60 |
+
from PIL import Image
|
61 |
+
import torch
|
62 |
+
|
63 |
+
# Load model and processor
|
64 |
+
model_name = "prithivMLmods/Rice-Leaf-Disease"
|
65 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
66 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
67 |
+
|
68 |
+
def classify_leaf_disease(image):
|
69 |
+
"""Predicts the disease type in a rice leaf image."""
|
70 |
+
image = Image.fromarray(image).convert("RGB")
|
71 |
+
inputs = processor(images=image, return_tensors="pt")
|
72 |
+
|
73 |
+
with torch.no_grad():
|
74 |
+
outputs = model(**inputs)
|
75 |
+
logits = outputs.logits
|
76 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
77 |
+
|
78 |
+
labels = {
|
79 |
+
"0": "Bacterial Blight",
|
80 |
+
"1": "Blast",
|
81 |
+
"2": "Brown Spot",
|
82 |
+
"3": "Healthy",
|
83 |
+
"4": "Tungro"
|
84 |
+
}
|
85 |
+
predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
|
86 |
+
|
87 |
+
return predictions
|
88 |
+
|
89 |
+
# Create Gradio interface
|
90 |
+
iface = gr.Interface(
|
91 |
+
fn=classify_leaf_disease,
|
92 |
+
inputs=gr.Image(type="numpy"),
|
93 |
+
outputs=gr.Label(label="Prediction Scores"),
|
94 |
+
title="Rice Leaf Disease Classification 🌾",
|
95 |
+
description="Upload an image of a rice leaf to identify if it is healthy or affected by diseases like Bacterial Blight, Blast, Brown Spot, or Tungro."
|
96 |
+
)
|
97 |
+
|
98 |
+
# Launch the app
|
99 |
+
if __name__ == "__main__":
|
100 |
+
iface.launch()
|
101 |
+
```
|
102 |
+
|
103 |
+
---
|
104 |
+
|
105 |
+
# **Intended Use:**
|
106 |
+
|
107 |
+
The **Rice-Leaf-Disease** model helps in detecting and classifying rice leaf diseases early, supporting:
|
108 |
+
✅ **Farmers & Agriculturists:** Quick disease detection for better crop management.
|
109 |
+
✅ **Agricultural Research:** Monitoring and analyzing plant disease patterns.
|
110 |
+
✅ **AI & Machine Learning Projects:** Applying AI to real-world agricultural challenges.
|