Instructions to use Madras1/plantdoc-rtdetrv2-leaf-disease-detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Madras1/plantdoc-rtdetrv2-leaf-disease-detector with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("object-detection", model="Madras1/plantdoc-rtdetrv2-leaf-disease-detector")# Load model directly from transformers import AutoTokenizer, AutoModelForObjectDetection tokenizer = AutoTokenizer.from_pretrained("Madras1/plantdoc-rtdetrv2-leaf-disease-detector") model = AutoModelForObjectDetection.from_pretrained("Madras1/plantdoc-rtdetrv2-leaf-disease-detector", device_map="auto") - Notebooks
- Google Colab
- Kaggle
PlantDoc RT-DETRv2 Leaf Disease Detector
RT-DETRv2-R18 fine-tuned for object detection on an audited and cleaned version of the PlantDoc dataset.
The model detects leaf regions and assigns one of 27 plant or disease categories. It does not segment individual lesions and should not be interpreted as a clinically or agronomically validated diagnostic system.
Model details
- Architecture: RT-DETRv2 with an R18 backbone
- Base model:
PekingU/rtdetr_v2_r18vd - Framework: Hugging Face Transformers and PyTorch
- Input resolution: 640 x 640
- Number of classes: 27
- Total parameters: 20,106,556
- Best checkpoint: epoch 28
- Default inference threshold: 0.075
Dataset preparation
The source dataset was agyaatcoder/PlantDoc, originally containing
2,578 images in its train and test splits.
Before training, the dataset was audited for invalid boxes, incorrect image dimensions, exact duplicates, perceptual duplicates, conflicting labels and extremely rare classes.
Final frozen splits:
| Split | Images | Boxes |
|---|---|---|
| Train | 2,009 | 6,863 |
| Validation | 245 | 853 |
| Test | 247 | 966 |
All 27 retained classes occur in every split. Known exact and perceptual duplicate pairs between splits were removed.
The final split manifest and cleaning summary are included in this repository.
Results
The test split was evaluated once after model selection using only the validation split.
| Metric | Validation | Test |
|---|---|---|
| mAP@[0.50:0.95] | 0.279448 | 0.239394 |
| mAP@0.50 | — | 0.336945 |
| mAP@0.75 | — | 0.267526 |
| mAP small | — | 0.000000 |
| mAP medium | — | 0.140294 |
| mAP large | — | 0.260317 |
| mAR@100 | — | 0.662587 |
Strongest test classes included:
| Class | AP |
|---|---|
| Corn rust leaf | 0.756111 |
| grape leaf | 0.565980 |
| Apple leaf | 0.468707 |
| Strawberry leaf | 0.406445 |
| Squash Powdery mildew leaf | 0.388265 |
Several tomato and potato disease classes obtained substantially lower
AP. Complete per-class results are available in
test_per_class_metrics.csv.
Training curves
Per-class test AP
Inference threshold
A global confidence threshold of 0.075 was selected exclusively on the validation split by maximizing detection F1 at IoU 0.50:
- Precision: 0.3299
- Recall: 0.4443
- F1: 0.3786
The threshold is intentionally permissive. For a cleaner visualization
with fewer predictions, try values between 0.10 and 0.15.
Application-specific threshold calibration is recommended.
Usage with Transformers pipeline
from PIL import Image
from transformers import pipeline
detector = pipeline(
task="object-detection",
model="Madras1/plantdoc-rtdetrv2-leaf-disease-detector",
)
image = Image.open("plant.jpg").convert("RGB")
predictions = detector(image, threshold=0.075)
for prediction in predictions:
print(prediction)
Local inference script
python inference.py plant.jpg \
--threshold 0.075 \
--output prediction.png
The script automatically uses CUDA when available and otherwise runs on CPU.
Important limitations
- This is an experimental research model, not a production agricultural diagnostic system.
- Predictions must not be used alone to select pesticides, treatments or other crop-management interventions.
- PlantDoc contains watermarks, heterogeneous image sources, background biases and inconsistent annotation styles.
- Some images appear to have incomplete annotations. Plausible model detections may therefore be counted as false positives.
- Several visually similar disease classes remain difficult to distinguish.
- Performance on small objects was not established
(
test mAP small = 0). - The global threshold may not be appropriate for every class or use case.
- Results should not be assumed to generalize to unseen farms, cameras, crop varieties, regions or lighting conditions.
Included files
model.safetensors: trained model weightsconfig.json: model architecture and class mappingpreprocessor_config.json: image preprocessing configurationinference_config.json: recommended inference settingsinference.py: local inference and visualizationcleaning_summary.json: dataset-cleaning summarysplit_manifest.csv: frozen split manifesttraining_history.csv: epoch-level historytest_metrics.json: aggregate test metricstest_per_class_metrics.csv: per-class test metrics- statistical plots and threshold-analysis artifacts
Dataset photographs are not redistributed in this model repository.
Licenses and attribution
The base model PekingU/rtdetr_v2_r18vd is distributed under the
Apache License 2.0.
The Hugging Face dataset agyaatcoder/PlantDoc declares the
CC BY 4.0 license. Users of the source dataset must preserve its
required attribution.
PlantDoc citation
@inproceedings{10.1145/3371158.3371196,
author = {Singh, Davinder and Jain, Naman and Jain, Pranjali and
Kayal, Pratik and Kumawat, Sudhakar and Batra, Nipun},
title = {PlantDoc: A Dataset for Visual Plant Disease Detection},
year = {2020},
publisher = {Association for Computing Machinery},
doi = {10.1145/3371158.3371196},
booktitle = {Proceedings of the 7th ACM IKDD CoDS and
25th COMAD},
pages = {249--253}
}
- Downloads last month
- 18
Model tree for Madras1/plantdoc-rtdetrv2-leaf-disease-detector
Base model
PekingU/rtdetr_v2_r18vdDataset used to train Madras1/plantdoc-rtdetrv2-leaf-disease-detector
Evaluation results
- Test mAP@[0.50:0.95] on Audited and cleaned PlantDoc test splittest set self-reported0.239
- Test mAP@0.50 on Audited and cleaned PlantDoc test splittest set self-reported0.337
- Test mAP@0.75 on Audited and cleaned PlantDoc test splittest set self-reported0.268


