Downloads · 30 days
10
21% of all-time downloads
uWandile/farmacy-plant-disease
farmacy-plant-disease is a machine learning model from uWandile. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository contains plant disease detection models for multiple crops.
Downloads · 30 days
10
21% of all-time downloads
All-time downloads
48
Public
Repo size
49.1 MB
Likes
0
Public
Click a slice to open those files.
.pth49.1 MB · 100%
From the Hugging Face model README
This repository contains plant disease detection models for multiple crops.
| Crop | Model | Accuracy | File |
|---|---|---|---|
| Tomato | EfficientNet-B0 | 90% | tomato/final_model.pth |
| Potato | EfficientNet-B0 | 98% | potato/final_model.pth |
| Maize | EfficientNet-B0 | 95% | maize/final_model.pth |
| Class | Description |
|---|---|
| Tomato_Bacterial_spot | Bacterial spot disease |
| Tomato_Early_blight | Early blight disease |
| Tomato_Late_blight | Late blight disease |
| Tomato_Leaf_Mold | Leaf mold disease |
| Tomato_Septoria_leaf_spot | Septoria leaf spot disease |
| Tomato_Spider_mites_Two_spotted_spider_mite | Spider mite damage |
| Tomato__Target_Spot | Target spot disease |
| Tomato__Tomato_YellowLeaf__Curl_Virus | Yellow leaf curl virus |
| Tomato__Tomato_mosaic_virus | Tomato mosaic virus |
| Tomato_healthy | Healthy plant |
| Class | Description |
|---|---|
| Potato___Early_blight | Early blight disease |
| Potato___Late_blight | Late blight disease |
| Potato___healthy | Healthy plant |
| Class | Description |
|---|---|
| Maize_Blight | Blight disease |
| Maize_Common_Rust | Common rust |
| Maize_Gray_Leaf_Spot | Gray leaf spot |
| Maize_Healthy | Healthy plant |
import torch
import torch.nn as nn
from torchvision import transforms, models
from PIL import Image
from huggingface_hub import hf_hub_download
# Download the tomato model
model_path = hf_hub_download(
repo_id="uWandile/farmacy-plant-disease",
filename="tomato/final_model.pth"
)
# Load the model
model = models.efficientnet_b0(pretrained=False)
model.classifier = nn.Sequential(
nn.Dropout(p=0.2),
nn.Linear(model.classifier[1].in_features, 10)
)
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
model.eval()
# Preprocess image
transform = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
# Predict
img = Image.open("tomato_leaf.jpg").convert('RGB')
img_tensor = transform(img).unsqueeze(0)
with torch.no_grad():
outputs = model(img_tensor)
_, predicted = outputs.max(1)
print(f"Prediction: {predicted.item()}")