Downloads · 30 days
0
erindKotobelliAISWE26/plant-disease-classifier
plant-disease-classifier is a image classification model from erindKotobelliAISWE26. Use it when you need a label for an image. The card lists the license as mit.
A CNN model trained on the PlantVillage dataset to classify plant leaf diseases.
Downloads · 30 days
0
Access
Public
Updated Mar 25, 2026
Repo size
6.5 MB
Likes
0
Public
Click a slice to open those files.
.pth6.5 MB · 99%
From the Hugging Face model README
A CNN model trained on the PlantVillage dataset to classify plant leaf diseases.
Trained on PlantVillage Dataset containing 54,000+ images of healthy and diseased plant leaves.
import torch
from torchvision import transforms
from PIL import Image
import json
# Load class names
with open("class_names.json") as f:
class_names = json.load(f)
# Load model
checkpoint = torch.load("best_model.pth", map_location="cpu")
# Preprocess image
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
image = Image.open("your_leaf.jpg").convert("RGB")
tensor = transform(image).unsqueeze(0) # add batch dimension
# Predict
with torch.no_grad():
outputs = model(tensor)
_, predicted = outputs.max(1)
print(f"Prediction: {class_names[predicted.item()]}")