AI-Lab-Makerere/beans
Viewer • Updated • 1.3k • 7.4k • 46
How to use ayoubkirouane/VIT_Beans_Leaf_Disease_Classifier with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-classification", model="ayoubkirouane/VIT_Beans_Leaf_Disease_Classifier")
pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png") # Load model directly
from transformers import AutoImageProcessor, AutoModelForImageClassification
processor = AutoImageProcessor.from_pretrained("ayoubkirouane/VIT_Beans_Leaf_Disease_Classifier")
model = AutoModelForImageClassification.from_pretrained("ayoubkirouane/VIT_Beans_Leaf_Disease_Classifier")The goal of this model is to classify leaf images into three categories:
{
"angular_leaf_spot": 0,
"bean_rust": 1,
"healthy": 2,
}
| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|---|---|---|---|---|
| 0.1495 | 1.54 | 100 | 0.0910 | 0.9774 |
| 0.0121 | 3.08 | 200 | 0.0155 | 1.0 |
! pip -q install datasets transformers[torch]
from transformers import pipeline
from PIL import Image
# Use a pipeline as a high-level helper
pipe = pipeline("image-classification", model="ayoubkirouane/VIT_Beans_Leaf_Disease_Classifier")
# Load the image
image_path = "Your image_path "
image = Image.open(image_path)
# Run inference using the pipeline
result = pipe(image)
# The result contains the predicted label and the corresponding score
predicted_label = result[0]['label']
confidence_score = result[0]['score']
print(f"Predicted Label: {predicted_label}")
print(f"Confidence Score: {confidence_score}")
Base model
google/vit-base-patch16-224-in21k