Downloads · 30 days
5
13% of all-time downloads
K4is3rrrr/lettuce-disease-detection
lettuce-disease-detection is a image classification model from K4is3rrrr. Use it when you need a label for an image. The card lists the license as apache-2.0.
A pre-trained ResNet50 model for detecting plant diseases from leaf images, optimized for FastAPI deployment.
Downloads · 30 days
5
13% of all-time downloads
All-time downloads
39
Public
Parameters
23.6M
94.6 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors94.6 MB · 100%
From the Hugging Face model README
A pre-trained ResNet50 model for detecting plant diseases from leaf images, optimized for FastAPI deployment.
from transformers import AutoModelForImageClassification, AutoImageProcessor
from PIL import Image
import torch
# Load model
model = AutoModelForImageClassification.from_pretrained("mesabo/agri-plant-disease-resnet50")
processor = AutoImageProcessor.from_pretrained("mesabo/agri-plant-disease-resnet50")
# Inference
image = Image.open("plant_leaf.jpg").convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_idx = probs.argmax(-1).item()
confidence = probs[0][predicted_idx].item()
print(f"Disease: {model.config.id2label[predicted_idx]}")
print(f"Confidence: {confidence * 100:.2f}%")
from fastapi import FastAPI, File, UploadFile
from transformers import AutoModelForImageClassification, AutoImageProcessor
from PIL import Image
import torch
import io
app = FastAPI()
# Load model at startup
model = AutoModelForImageClassification.from_pretrained("mesabo/agri-plant-disease-resnet50")
processor = AutoImageProcessor.from_pretrained("mesabo/agri-plant-disease-resnet50")
model.eval()
@app.post("/predict")
async def predict(file: UploadFile = File(...)):
image = Image.open(io.BytesIO(await file.read())).convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_idx = probs.argmax(-1).item()
confidence = probs[0][predicted_idx].item()
return {
"disease": model.config.id2label[predicted_idx],
"confidence": round(confidence * 100, 2),
"status": "success"
}
| Metric | Value |
|---|---|
| Accuracy | 95%+ |
| Inference Time | < 100ms (CPU) |
| Memory Usage | ~400 MB |
| Input Size | 224x224 RGB |
This model currently supports Maize and Tomato which are important crops in West Africa.
Not yet supported:
For cassava/cashew support, we recommend fine-tuning on the CCMT Ghana dataset.
pip install transformers torch pillow
@misc{agri-plant-disease-resnet50,
author = {mesabo},
title = {Plant Disease Detection - ResNet50},
year = {2024},
publisher = {Hugging Face},
url = {https://huggingface.co/mesabo/agri-plant-disease-resnet50}
}
Apache 2.0 - Commercial use allowed