Downloads · 30 days
16
24% of all-time downloads
nahuelnb/plant-pathology-efficientnetb2
plant-pathology-efficientnetb2 is a image classification model from nahuelnb. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as apache-2.0.
This model classifies plant diseases using EfficientNet-B2 architecture. It was trained on the Plant Pathology 2020 FGVC7 dataset.
Downloads · 30 days
16
24% of all-time downloads
All-time downloads
67
Public
Repo size
31.2 MB
Likes
0
Public
Click a slice to open those files.
.safetensors31.2 MB · 100%
From the Hugging Face model README
This model classifies plant diseases using EfficientNet-B2 architecture. It was trained on the Plant Pathology 2020 FGVC7 dataset.
pip install torch torchvision Pillow safetensors
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%}")
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}}
}
Apache 2.0