Plant Pathology EfficientNet-B2

This model classifies plant diseases using EfficientNet-B2 architecture. It was trained on the Plant Pathology 2020 FGVC7 dataset.

Model Description

  • Architecture: EfficientNet-B2 (pretrained on ImageNet)
  • Task: Multi-class image classification (4 classes)
  • Input Size: 260x260 RGB images
  • Classes:
    • healthy
    • multiple_diseases
    • rust
    • scab

Performance

  • Validation Accuracy: 96.04%
  • Test Accuracy: 97.00%

Requirements

pip install torch torchvision Pillow safetensors

Inference Code

import torch
import torch.nn as nn
from torchvision import transforms
from torchvision.models import efficientnet_b2
from PIL import Image
from safetensors.torch import load_file

# Define the model architecture
class PlantPathologyModel(nn.Module):
    def __init__(self, num_classes=4):
        super(PlantPathologyModel, self).__init__()
        self.backbone = efficientnet_b2(pretrained=False)
        in_features = self.backbone.classifier[1].in_features
        self.backbone.classifier = nn.Sequential(
            nn.Dropout(p=0.3, inplace=True),
            nn.Linear(in_features, num_classes)
        )

    def forward(self, x):
        return self.backbone(x)

# Load model
model = PlantPathologyModel(num_classes=4)
state_dict = load_file("plant-pathology-efficientnetb2.safetensors")
model.load_state_dict(state_dict)
model.eval()

# Define preprocessing
transform = transforms.Compose([
    transforms.Resize((260, 260)),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])

# Inference
image = Image.open("your_plant_image.jpg").convert("RGB")
input_tensor = transform(image).unsqueeze(0)

with torch.no_grad():
    output = model(input_tensor)
    probabilities = torch.nn.functional.softmax(output[0], dim=0)
    predicted_class = torch.argmax(probabilities).item()

# Class names
class_names = ["healthy", "multiple_diseases", "rust", "scab"]
print(f"Predicted: {class_names[predicted_class]}")
print(f"Confidence: {probabilities[predicted_class]:.2%}")

Training Details

Training Data

  • Dataset: Plant Pathology 2020 FGVC7
  • Training samples: 1,310
  • Validation samples: 328
  • Test samples: 181

Training Configuration

  • Optimizer: Adam (lr=0.001)
  • Loss Function: CrossEntropyLoss
  • Batch Size: 32
  • Epochs: 15
  • Learning Rate Scheduler: ReduceLROnPlateau
  • Data Augmentation:
    • Random horizontal flip
    • Random vertical flip
    • Random rotation (+/- 20 degrees)
    • Color jitter (brightness=0.2, contrast=0.2)

Hardware

  • GPU training on CUDA-enabled device

Limitations

  • Model is trained specifically on apple leaf diseases from the Plant Pathology 2020 dataset
  • Performance may vary on other plant species or different imaging conditions
  • Requires consistent image preprocessing (resize to 260x260, normalize with ImageNet stats)

Citation

If you use this model, please cite:

@misc{plant-pathology-efficientnetb2,
  author = {Nahuel},
  title = {Plant Pathology EfficientNet-B2},
  year = {2026},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/nahuelnb/plant-pathology-efficientnetb2}}
}

License

Apache 2.0

Downloads last month
6
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support