Agricom Ghana Maize Disease Classifier
Accuracy: 91.07% on test set
Production model for detecting 7 maize diseases/pests in Ghana (Ashanti & Brong-Ahafo regions).
Classes
- Common Rust
- Gray Leaf Spot
- Healthy
- Maize Ear Rot
- Fall Armyworm ⚠️ (triggers Emamectin Benzoate alerts)
- Maize Stem Borer
- Northern Leaf Blight
Usage
import torch
import torchvision.models as models
from torchvision import transforms
from PIL import Image
# Load model
checkpoint = torch.load('model.pth')
model = models.resnet18()
model.fc = torch.nn.Linear(512, 7)
model.load_state_dict(checkpoint['state_dict'])
model.eval()
# Preprocess image
transform = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
# Predict
img = Image.open('maize_leaf.jpg').convert('RGB')
img_tensor = transform(img).unsqueeze(0)
with torch.no_grad():
output = model(img_tensor)
probabilities = torch.nn.functional.softmax(output[0], dim=0)
pred_class = output.argmax(1).item()
print(f"Prediction: {checkpoint['class_names'][pred_class]}")
print(f"Confidence: {probabilities[pred_class]:.2%}")
Model Details
- Architecture: ResNet-18 (torchvision)
- Input: 224×224 RGB images
- Training: Transfer learning from ImageNet
- Framework: PyTorch
- Downloads last month
- 1
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support