Downloads · 30 days
9
15% of all-time downloads
joggwr/crop_leaf_diseases_vit
crop_leaf_diseases_vit is a image classification model from joggwr. Use it when you need a label for an image. It is set up for transformers. The card lists the license as mit.
This model is a Vision Transformer (ViT) designed to identify plant diseases in crops as part of a smart agricultural farming system. It has been trained on a diverse dataset of plant images, including different disea…
Downloads · 30 days
9
15% of all-time downloads
All-time downloads
61
Public
Parameters
5.5M
432 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors22.1 MB · 100%
From the Hugging Face model README
This model is a Vision Transformer (ViT) designed to identify plant diseases in crops as part of a smart agricultural farming system. It has been trained on a diverse dataset of plant images, including different disease categories affecting crops such as corn, potato, rice, and wheat. The model aims to provide farmers and agronomists with real-time disease detection for better crop management.
This Vision Transformer model has been fine-tuned to classify various plant diseases commonly found in agricultural settings. The model can classify diseases in crops such as corn, potato, rice, and wheat, identifying diseases like rust, blight, leaf spots, and others. The goal is to enable precision farming by helping farmers detect diseases early and take appropriate actions.
| Crop | Diseases Identified |
|---|---|
| Corn | Common Rust |
| Corn | Gray Leaf Spot |
| Corn | Healthy |
| Corn | Leaf Blight |
| - | Invalid |
| Potato | Early Blight |
| Potato | Healthy |
| Potato | Late Blight |
| Rice | Brown Spot |
| Rice | Healthy |
| Rice | Leaf Blast |
| Wheat | Brown Rust |
| Wheat | Healthy |
| Wheat | Yellow Rust |
This model can be used directly to classify images of crops to detect plant diseases. It is especially useful for precision farming, enabling users to monitor crop health and take early interventions based on the detected disease.
This model can be fine-tuned on other agricultural datasets for specific crops or regions to improve its performance or be integrated into larger precision farming systems that include other features like weather predictions and irrigation control.
Can be quantitized or deployed in full precision on edge devices due to its small parameter size without compromising on precision and accuracy.
This model is not designed for non-agricultural image classification tasks or for environments with insufficient or very noisy data. Misuse includes using the model in areas with vastly different agricultural conditions from those it was trained on.
Users should evaluate the model on their specific crops and farming conditions. Regular updates and retraining with local data are recommended for optimal performance.
from PIL import Image, UnidentifiedImageError
from transformers import ViTFeatureExtractor, ViTForImageClassification
feature_extractor = ViTFeatureExtractor.from_pretrained('wambugu71/crop_leaf_diseases_vit')
model = ViTForImageClassification.from_pretrained(
'wambugu1738/crop_leaf_diseases_vit',
ignore_mismatched_sizes=True
)
image = Image.open('<image_path>')
inputs = feature_extractor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])
The model was trained on a dataset containing images of various crops with labeled diseases, including the following categories:
The dataset also includes images captured under various lighting conditions, from both controlled and uncontrolled environments and angles, to simulate real-world farming scenarios. We made use of public available datasets, and our own private data.
The model was fine-tuned using a vision transformer architecture pre-trained on the ImageNet dataset. The dataset was preprocessed by resizing the images and normalizing the pixel values.

The model was evaluated using a validation set consisting of 20% of the original dataset, with the following metrics:
Carbon emissions during model training can be estimated using the Machine Learning Impact calculator.
The model uses a Vision Transformer architecture to learn image representations and classify them into disease categories. Its self-attention mechanism enables it to capture global contextual information in the images, making it suitable for agricultural disease detection.
If you use this model in your research or applications, please cite it as:
BibTeX:
@misc{kinyua2024smartfarming,
title={Smart Farming Disease Detection Transformer},
author={Wambugu Kinyua},
year={2024},
publisher={Hugging Face},
}
APA:
Kinyua, W. (2024). Smart Farming Disease Detection Transformer. Hugging Face.
For further inquiries, contact: [email protected]