Farmacy Plant Disease Detection Model
This repository contains plant disease detection models for multiple crops.
Available Models
Tomato Model
Training Details
- Dataset: 1,000 images (100 per class) from PlantVillage
- Model: EfficientNet-B0 (pretrained on ImageNet)
- Epochs: 10
- Validation Accuracy: 86.5%
- Test Accuracy: 90.0%
Classes (10 Tomato Diseases)
| Class |
Description |
| Tomato_Bacterial_spot |
Bacterial spot disease |
| Tomato_Early_blight |
Early blight disease |
| Tomato_Late_blight |
Late blight disease |
| Tomato_Leaf_Mold |
Leaf mold disease |
| Tomato_Septoria_leaf_spot |
Septoria leaf spot disease |
| Tomato_Spider_mites_Two_spotted_spider_mite |
Spider mite damage |
| Tomato__Target_Spot |
Target spot disease |
| Tomato__Tomato_YellowLeaf__Curl_Virus |
Yellow leaf curl virus |
| Tomato__Tomato_mosaic_virus |
Tomato mosaic virus |
| Tomato_healthy |
Healthy plant |
Potato Model
Training Details
- Dataset: 300 images (100 per class) from PlantVillage
- Model: EfficientNet-B0 (pretrained on ImageNet)
- Epochs: 10
- Validation Accuracy: 98.3%
- Test Accuracy: 100% (10 random images)
Classes (3 Potato Conditions)
| Class |
Description |
| Potato___Early_blight |
Early blight disease |
| Potato___Late_blight |
Late blight disease |
| Potato___healthy |
Healthy plant |
Maize Model
Training Details
- Dataset: 400 images (100 per class) from PlantVillage
- Model: EfficientNet-B0 (pretrained on ImageNet)
- Epochs: 10
- Validation Accuracy: 95.0%
- Test Accuracy: 100% (10 random images)
Classes (4 Maize Conditions)
| Class |
Description |
| Maize_Blight |
Blight disease |
| Maize_Common_Rust |
Common rust |
| Maize_Gray_Leaf_Spot |
Gray leaf spot |
| Maize_Healthy |
Healthy plant |
Usage
Tomato Model
import torch
import torch.nn as nn
from torchvision import transforms, models
from PIL import Image
from huggingface_hub import hf_hub_download
# Download the tomato model
model_path = hf_hub_download(
repo_id="uWandile/farmacy-plant-disease",
filename="tomato/final_model.pth"
)
# Load the model
model = models.efficientnet_b0(pretrained=False)
model.classifier = nn.Sequential(
nn.Dropout(p=0.2),
nn.Linear(model.classifier[1].in_features, 10)
)
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
model.eval()
# Preprocess image
transform = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
# Predict
img = Image.open("tomato_leaf.jpg").convert('RGB')
img_tensor = transform(img).unsqueeze(0)
with torch.no_grad():
outputs = model(img_tensor)
_, predicted = outputs.max(1)
print(f"Prediction: {predicted.item()}")