An AI Model That Spots Onion Disease 123 Times a Second
Researchers at ICAR's onion research institute in Pune trained a customized YOLOv8 detector on 1,000 field photos of diseased onion plants — and found that one architectural upgrade helped a lot, while a second, stacked on top of it, actually made things slightly worse.
A team at ICAR-DOGR Pune and IIT Bombay built a customized YOLOv8 object-detection model to spot four major onion foliar diseases — Anthracnose, Stemphylium blight, Purple Blotch, and Twister disease — directly from field photographs. Swapping in a Dynamic Task-Aligned detection Head lifted accuracy from a 72.9% baseline to 77.3%, while running at 123 frames per second on just 11.1 million parameters — faster and dramatically smaller than older two-stage detectors like Faster R-CNN. Stacking a second attention module on top, somewhat surprisingly, didn't help further.
The problem
A visual inspection job for a computer
Onion is a high-stakes crop to get disease detection wrong on: pests and diseases together can cut yields by 30-50%, and specific diseases like the twister-anthracnose complex can destroy 80-100% of a nursery crop if caught late. Right now, diagnosis mostly happens the way it always has — a grower or extension worker looks at the leaves and makes a call, and the accuracy of that call depends entirely on their experience. A team based at ICAR's Directorate of Onion and Garlic Research (DOGR) in Pune, working with IIT Bombay's Technology Innovation Hub for IoT, set out to replace that judgment call with an object-detection model that runs directly on a farmer's phone.
The dataset
Building a dataset that doesn't exist anywhere else
Generic plant-disease datasets like PlantVillage barely cover onions at all — most existing image-based disease detection research focuses on tomato, rice, or apple. So the team built their own from scratch: 1,000 photographs taken at the DOGR research farm in Pune over four months (September to December 2023), using both a Nikon D7500 DSLR and a Moto g72 smartphone, camera positioned 30-50 cm from the plant. The set was split evenly — 800 diseased images spread across Anthracnose, Stemphylium blight, Purple Blotch, and Twister disease, plus 200 healthy plants — and every disease region was hand-annotated with a bounding box using Roboflow. After augmentation (random horizontal flips and light image noise, to help the model generalize), the final working set was 1,391 training images, 189 for validation, and 100 held out for testing.
The upgrades
Two upgrades to a fast, small detector
YOLO (You Only Look Once) models are built for speed — they scan a whole image in a single pass rather than proposing and re-checking regions the way older two-stage detectors do, which makes them a natural fit for a phone app that needs an answer in real time. Starting from YOLOv8s, the team tested two specific upgrades, alone and combined. The first, CBAM (Convolutional Block Attention Module), teaches the network to weight which channels and which spatial regions of an image matter most before making a prediction. The second, DTAH (Dynamic Task-Aligned Head), replaces the standard detection head with one built to keep a bounding box's classification and its localization in sync — useful when a lesion's shape and its species are hard to pull apart, which is often the case with plant disease.
The winner
DTAH alone beat everything else tested
Across five model variants — baseline YOLOv5s, baseline YOLOv8s, YOLOv8+CBAM, YOLOv8+DTAH, and YOLOv8+CBAM combined with DTAH — the DTAH-only version came out on top: 77.3% mAP50 (a standard object-detection accuracy measure), 81.5% precision, and 72.1% recall, run at 8.1 milliseconds per image (about 123 frames per second). That beat the YOLOv8s baseline (72.9% mAP50) by 4.4 points and the older YOLOv5s baseline (65.4% mAP50) by nearly 12 points.
The model also held up well against much heavier, older-generation detectors. RetinaNet-R50 (36 million parameters) scored 70.34% mAP50 at 65 FPS; Faster R-CNN-R101 (44 million parameters) scored 72.05% mAP50 at 44 FPS. YOLOv8+DTAH beat both on accuracy while using a quarter to a third of the parameters and running 1.9 to 2.8 times faster — the kind of efficiency gap that decides whether a model can actually run on a mid-range phone in a farmer's hand versus needing a server.
The surprise
More attention isn't automatically better
The genuinely interesting result is what happened when the team combined both upgrades. YOLOv8+CBAM alone reached 74.0% mAP50 — a smaller gain than DTAH alone. And stacking CBAM on top of DTAH (the fully combined model) landed at 75.0% mAP50, actually below DTAH by itself. Class-by-class, DTAH alone led on Anthracnose (78.6% vs 74.8% for the combined model) and Purple Blotch (79.2% vs 70.9%), while the combined model edged ahead only on the Healthy class. The paper doesn't fully explain the gap, but the pattern suggests DTAH's task-aligned, deformable head was already handling the irregular shapes of disease lesions well on its own — and adding CBAM's extra attention layer on top may have introduced redundancy rather than new information.
The hard cases
The easy disease and the hard one
Not every disease was equally detectable. Twister disease was the best-performing class across nearly every model variant, topping out at 85.5% mAP50 under DTAH — likely because its symptoms (a distinctively twisted, malformed leaf) look visually distinct from anything else in the dataset. Stemphylium blight was the opposite story: it scored lowest across most models (as low as 57.3% mAP50 for the YOLOv5s baseline) and, per the paper's confusion-matrix analysis, was most often mistaken for Purple Blotch or misclassified as background — a mix-up the authors attribute to genuine visual similarity between the two diseases on an actual leaf.
What's next
Headed for a phone in a farmer's pocket
This isn't a purely academic exercise — DOGR already runs a mobile app called iSARATHI that gives farmers disease guidance, currently built on an older YOLOv5 model. The DTAH-upgraded YOLOv8 model described here is intended as its replacement, and the paper frames real-time, on-device performance as a design requirement from the start, not an afterthought. The team notes the same approach could extend to other onion diseases, or be adapted for entirely different crops, given a comparable annotated image dataset.
Onion pests and diseases cause 30-50% yield losses in India, one of the world's largest onion producers, and expert diagnosis doesn't scale to every smallholder farm. A disease-detection model light and fast enough to run inside a phone app — rather than needing a lab, a specialist, or a cloud server — is a genuinely deployable step toward catching foliar disease early enough to actually save a crop, and the underlying approach (YOLOv8 plus a task-aligned detection head) generalizes to other crops given enough labeled field images.
What is mAP50, and why does the paper use it?
Mean Average Precision at an IoU (overlap) threshold of 0.5 — a standard accuracy measure for object detection that checks whether a predicted disease-region box sufficiently overlaps the true, hand-labeled region. It's the field's standard single-number benchmark for comparing detection models.
Why did adding CBAM on top of DTAH make results worse rather than better?
The paper doesn't give a definitive mechanism, but the pattern suggests DTAH's deformable, task-aligned head already handled the irregular shapes of disease lesions well on its own, and the extra CBAM attention layer added complexity without adding new useful information on a dataset of this size (1,000 images).
Which onion disease was hardest for the model to detect?
Stemphylium blight was consistently the weakest-performing class, most often confused with Purple Blotch or misclassified as background, which the authors attribute to genuine visual similarity between the two diseases on an actual leaf.
Will this model be available to farmers directly?
The paper positions it as an upgrade to iSARATHI, a mobile app already used for onion disease guidance in India, currently built on an older YOLOv5 model — the DTAH-based YOLOv8 model is intended to replace that underlying detector.
Based on the peer-reviewed paper “YOLO-ODD: An Improved YOLOv8s Model for Onion Foliar Disease Detection”. Read the full abstract, key findings, and download the PDF on the paper's own page.