Update README.md
Browse files
README.md
CHANGED
@@ -1,28 +1,69 @@
|
|
1 |
---
|
2 |
language: en
|
|
|
3 |
tags:
|
4 |
- pytorch
|
5 |
- plant-disease
|
6 |
- image-classification
|
|
|
|
|
7 |
datasets:
|
8 |
-
- plant-village
|
9 |
---
|
10 |
|
11 |
# Plant Disease Classification Model
|
12 |
|
13 |
-
|
14 |
-
- Apple
|
15 |
-
- Tomato
|
16 |
-
- Corn (Maize)
|
17 |
|
18 |
## Model Details
|
19 |
-
|
20 |
-
|
21 |
-
-
|
22 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
## How to Use
|
|
|
|
|
25 |
```python
|
26 |
from transformers import AutoModelForImageClassification
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
|
|
|
1 |
---
|
2 |
language: en
|
3 |
+
license: mit
|
4 |
tags:
|
5 |
- pytorch
|
6 |
- plant-disease
|
7 |
- image-classification
|
8 |
+
- agriculture
|
9 |
+
- computer-vision
|
10 |
datasets:
|
11 |
+
- plant-village
|
12 |
---
|
13 |
|
14 |
# Plant Disease Classification Model
|
15 |
|
16 |
+
🌱 EfficientNet-B2 based model for classifying plant diseases in apples, tomatoes, and corn (maize).
|
|
|
|
|
|
|
17 |
|
18 |
## Model Details
|
19 |
+
|
20 |
+
### Architecture
|
21 |
+
- **Backbone**: EfficientNet-B2 (pretrained)
|
22 |
+
- **Custom Head**:
|
23 |
+
- Attention mechanism
|
24 |
+
- 3 dense layers (512, 256, num_classes)
|
25 |
+
- Dropout regularization (0.3)
|
26 |
+
|
27 |
+
### Training Data
|
28 |
+
- **Dataset**: PlantVillage Dataset
|
29 |
+
- **Classes**: 14 total (4 Apple, 6 Tomato, 4 Corn diseases + healthy)
|
30 |
+
- **Train/Val/Test Split**: 80%/10%/10%
|
31 |
+
- **Image Size**: 224x224
|
32 |
+
|
33 |
+
### Performance Metrics
|
34 |
+
| Metric | Value |
|
35 |
+
|--------------|---------|
|
36 |
+
| Train Accuracy | 98.66% |
|
37 |
+
| Val Accuracy | 99.24% |
|
38 |
+
| Test Accuracy | 98.91% |
|
39 |
|
40 |
## How to Use
|
41 |
+
|
42 |
+
### Inference
|
43 |
```python
|
44 |
from transformers import AutoModelForImageClassification
|
45 |
+
from PIL import Image
|
46 |
+
import torch
|
47 |
+
import torchvision.transforms as transforms
|
48 |
+
|
49 |
+
# Load model
|
50 |
+
model = AutoModelForImageClassification.from_pretrained("Abuzaid01/plant-disease-classifier")
|
51 |
+
|
52 |
+
# Preprocess image
|
53 |
+
transform = transforms.Compose([
|
54 |
+
transforms.Resize(256),
|
55 |
+
transforms.CenterCrop(224),
|
56 |
+
transforms.ToTensor(),
|
57 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
|
58 |
+
])
|
59 |
+
|
60 |
+
# Load and transform image
|
61 |
+
image = Image.open("plant.jpg")
|
62 |
+
inputs = transform(image).unsqueeze(0)
|
63 |
+
|
64 |
+
# Predict
|
65 |
+
with torch.no_grad():
|
66 |
+
outputs = model(inputs)
|
67 |
+
prediction = torch.argmax(outputs.logits, dim=1).item()
|
68 |
|
69 |
+
print(f"Predicted class: {model.config.id2label[prediction]}")
|