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

  1. Common Rust
  2. Gray Leaf Spot
  3. Healthy
  4. Maize Ear Rot
  5. Fall Armyworm ⚠️ (triggers Emamectin Benzoate alerts)
  6. Maize Stem Borer
  7. 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
Safetensors
Model size
11.2M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support