11

Six public datasets, one duplicate trap, and a sugarcane leaf classifier that reads phone photos

AgricultureVision

Leaf disease classifiers are well studied; the hard part in practice is the data. Public sugarcane datasets are scattered across platforms, labelled with different class names, and, as it turned out, partially copies of each other.

At a glance
Client
Turing Agro product line - requested by a sugarcane mill group and an agriscience R&D team
Industry
Agriculture · Sugar & ethanol
Problem
A scout in the field has a phone, not a lab. The question "is this leaf sick, and with what?" needed an answer at the point of capture
Solution
A two-stage image classifier: healthy versus unhealthy first, then disease type (red rot, rust, bacterial spots, dry leaves, yellow leaf syndrome, among others), trained on a curated merge of six public datasets after duplicate removal
Stack
Six public sugarcane leaf datasets (Roboflow, Kaggle/Mendeley, GitHub) · MD5 duplicate detection · class-balance analysis · CNN image classification · top-1 / top-5 accuracy tracking · held-out test set
Result
Top-1 accuracy 0.991 on training; normalized test confusion matrix with 0.96–0.98 diagonal on healthy vs unhealthy
The challenge

Leaf disease classifiers are well studied; the hard part in practice is the data. Public sugarcane datasets are scattered across platforms, labelled with different class names, and, as it turned out, partially copies of each other. Train on the naive union and you test on your training images without knowing it.

What they needed
  • A model that works on ordinary smartphone photos of leaves
  • A first, reliable healthy/unhealthy decision
  • A second decision naming the disease
  • A dataset assembled with enough care that the reported accuracy means something
Goals & success metrics
  • Deduplicated, merged training set with documented provenance
  • Class distribution analysed before training
  • Healthy vs. unhealthy classifier with a clean held-out test
  • Disease-type classifier as the second stage
How we did it
  1. 01

    Assembling the data

    Six sources were collected: a Roboflow augmented set with 200+ classes, a Mendeley set of ~20,000 images via Kaggle, a 2025 Mendeley article dataset, a Roboflow sugarcane disease detection set, a GitHub sugarcane leaf disease set, and a Mendeley sugarcane leaf image dataset.

    Directory listing of the six downloaded datasets.
    Fig. 01. Six datasets, six folder conventions, six label vocabularies.
  2. 02

    The duplicate trap

    Every image was hashed with MD5: identical content produces an identical 32-character signature. The check found that dataset 3 and dataset 6, published under different links, contained the same images. Dataset 6 was dropped.

    Terminal output listing MD5 hashes with duplicate matches highlighted.
    Fig. 02. Hashing every file. Matching hashes across folders are the leak.
    Side-by-side of duplicate image pairs found across datasets.
    Fig. 03. The same photos under two different dataset names. Without this step the test set would have overlapped the training set.
  3. 03

    Class balance

    Distributions were plotted per dataset and after merging. The merged set is heavily skewed toward unhealthy leaves, which shapes how the two-stage design and the evaluation were set up.

    Histograms of healthy versus unhealthy image counts per dataset with sample thumbnails.
    Fig. 04. Per dataset: healthy in blue, unhealthy in red, with sample images. Some sources have almost no healthy leaves.
    Histogram of the merged dataset by source and class.
    Fig. 05. Merged: the imbalance is explicit before the first epoch.
  4. 04

    Training

    Stage one, healthy versus unhealthy, was trained to completion with top-1 and top-5 accuracy tracked per epoch.

    Training log line showing top-1 accuracy 0.991.
    Fig. 06. Final training epoch: top-1 accuracy 0.991.
    Batch of healthy leaf images with predicted labels.
    Fig. 07. A healthy batch as the model saw it: field backgrounds, varied lighting, phone framing.
    Batch of unhealthy leaf images with predicted labels.
    Fig. 08. An unhealthy batch. Lesions, rust and drying at the resolution a phone provides.
    Training and validation loss and accuracy curves.
    Fig. 09. Train and validation loss, top-1 and top-5 accuracy. Converged without the validation curve diverging.
  5. 05

    Test

    Held-out test, normalized: 0.98 of healthy leaves and 0.96 of unhealthy leaves classified correctly. The second stage then names the disease: red rot, rust, bacterial spots, dry leaves, yellow leaf syndrome, and others.

    Normalized confusion matrix on the test set, healthy vs unhealthy.
    Fig. 10. Held-out test, normalized: 0.98 of healthy leaves and 0.96 of unhealthy leaves classified correctly. The second stage then names the disease: red rot, rust, bacterial spots, dry leaves, yellow leaf syndrome, and others.
What made it work
  • Hashing before training, which removed a cross-dataset leak that would have inflated every number
  • Plotting class balance before choosing a design
  • A two-stage decision, so the frequent question (sick or not?) gets the most data
  • Keeping a held-out test whose images were verified not to appear in training
FAQ

Still have a question?

Ask us directly. A person reads it and gets back to you quickly.

Contact us