Peanut leaf disease classifiers (leakage-controlled cross-validation)

Trained models from the study "Deep learning-based peanut leaf disease classification using transfer learning under leakage-controlled cross-validation" (manuscript under review; citation below will be updated).

The models classify a close-up photograph of a peanut (groundnut, Arachis hypogaea) leaf into five classes: Alternaria leaf spot, Healthy, Leaf spot (early and late), Rosette, Rust.

What is in this repository

Each configuration was trained with stratified group 5-fold cross-validation: near-identical photographs of the dataset were grouped, and a group never appears in more than one of the training, validation and test sets of a fold. For every configuration there are five models, one per fold (fold0–fold4). Each was selected on its own validation set (highest validation macro-F1) and tested once on its own test fold.

Folder Backbone Recipe Folds Input (px) Test accuracy (%), mean ± SD over folds Macro-F1 (%), mean ± SD Correct / test images (pooled)
convnext_base__B/ † ConvNeXt-Base B 5 224 99.31 ± 0.42 99.16 ± 0.52 1708 / 1720
convnext_base__P/ ConvNeXt-Base P 5 224 98.11 ± 0.99 98.10 ± 0.59 1688 / 1720
efficientnet_b0__P/ EfficientNet-B0 P 5 224 97.45 ± 0.72 97.72 ± 0.89 1676 / 1720
efficientnet_b4__P/ EfficientNet-B4 P 5 380 98.67 ± 0.50 98.57 ± 0.97 1697 / 1720
resnet50__P/ ResNet-50 P 5 224 97.90 ± 0.65 97.83 ± 0.62 1684 / 1720

Recipe P: last stage and a new two-layer head trained (rest frozen); balanced sampling, class-weighted cross-entropy, Adam with OneCycle learning rate, flip/rotation/colour/translation/random-erasing augmentation. Recipe B: all layers trained; linear head; label smoothing 0.2; AdamW with cosine warm restarts; flip/rotation/ random-resized-crop/colour/translation/greyscale augmentation. 25 epochs in both cases. Full settings are in each config.json (training).

Weights were not kept for: efficientnet_b0__B, efficientnet_b4__B, resnet50__B. Their results are reported in the paper and can be reproduced with the code.

† convnext_base__B: the weights of the run reported in the paper were not saved, so this configuration was trained again with the same code, settings, folds and random seeds (Notebook 05). GPU training is not bit-for-bit repeatable: the published run reached 99.31 ± 0.42% (1708 / 1720 correct); the run reported in the paper reached 99.31 ± 0.42% (1708 / 1720). The two runs gave the same prediction for 1720 of 1720 test images (McNemar exact test, p = 1).

Before upload, every fold model was re-tested on its own test fold: 8599 of 8600 predictions were identical to the predictions recorded when the models were trained.

Other files:

  • cv_splits.csv — for every image (image_id) and fold: its role (train, val or test).
  • images.csv — image_id, class, file name in the Mendeley archive, SHA-256 and duplicate group.
  • cv_splits_meta.json — the duplicate-grouping rules and split settings.
  • inference.py — loading and prediction code (below).

Usage

pip install torch torchvision safetensors huggingface_hub pillow
from huggingface_hub import snapshot_download
import sys
root = snapshot_download("Kashif-Mahmood007/peanut-leaf-disease-classifiers")          # downloads this repository
sys.path.insert(0, root)
from inference import load_model, predict_proba, CLASSES

net, cfg = load_model("resnet50__P", fold=0, root=root)
prob = predict_proba(net, cfg, ["leaf.jpg"])
print(CLASSES[int(prob[0].argmax())], float(prob[0].max()))

or from the command line: python inference.py --model resnet50__P --fold all leaf.jpg (averages the five fold models).

Pre-processing (done by inference.py): camera orientation from EXIF, RGB, resize to 448 × 448 (bicubic), resize to the network input size, ImageNet normalisation. Weights are stored in float16 (.safetensors) and loaded as float32.

To reproduce the paper's numbers, evaluate a fold model only on the images whose role is test in that fold (cv_splits.csv); all other images were used to train or select that model.

Limitations

  • All images come from one public dataset, taken with one smartphone model in one region of India, under natural light. Accuracy on images from other regions, cultivars, devices or growing conditions is unknown and is expected to be lower; the reported accuracies are an upper bound for field use.
  • Each image has one label. The models cannot detect several diseases on one leaf, separate early from late leaf spot, or grade severity. Images of other crops, other diseases or non-leaf images will still be assigned one of the five classes.
  • These are research models. They are not validated for diagnostic or management decisions.

Citation

The citation will be added after publication. Until then, please cite the code repository and the dataset: Sasmal, B. et al. A novel groundnut leaf dataset for detection and classification of groundnut leaf diseases. Mendeley Data, v2 (2024). https://doi.org/10.17632/x6x5jkk873.2

Licence

Weights: CC-BY-4.0. The models were initialised from torchvision ImageNet weights (BSD-3-Clause) and fine-tuned on the dataset above (CC BY 4.0).

Files and checksums (SHA-256)

File SHA-256
convnext_base__B/fold0.safetensors 58c41aec4e1ecbccf5e7385672c2127d4bd1377c1f2978ea992fb2e16db132a2
convnext_base__B/fold1.safetensors a388651578b10d442eb696235cf91aba21f64a3bc563d5711fa3e2264decace9
convnext_base__B/fold2.safetensors d3913555cfb485cc4bc5b6423bedf23e88cf40911ec461dff3217ffd50086442
convnext_base__B/fold3.safetensors ab1902b29afed2ec32556d194dcee081370ef32e65669a42fdea0371d5a1fd1d
convnext_base__B/fold4.safetensors 56cf6074a1444dccfa9600f019ef8e30ae379c7773f05249f9fde3149671597c
convnext_base__P/fold0.safetensors afec9110ecffd76636bed2d745e2a546241f3cf63ec07ed58d9372fae2a27121
convnext_base__P/fold1.safetensors 0de5246353fe5d13faa2c46e9f03086d52cfc90903e3522a75dbaedeec0c13e1
convnext_base__P/fold2.safetensors 9d1c0016f27bc40ffef1d3f140c19bec529b847fcf9ed2396519e967d4772b14
convnext_base__P/fold3.safetensors 3ee1d6a15cd7d987fe32c5731adb4311725f75b5c20730b8fed46f121a3f0ad0
convnext_base__P/fold4.safetensors e9731ffea2245309e496015b96150364d5e79bb99efe692e626d290e2498f74f
cv_splits.csv afa55b3cdf88fc66bb4d9f75b8d38523e5b3f4557e9493aff6d607559eefec09
cv_splits_meta.json de1caee11db11cb13b79c1925f56f57f4e6aa0bd03735ee8f44dea0465a0c54d
efficientnet_b0__P/fold0.safetensors c93b35c7752172d32a13d087227b94533bf4e2af6a19949c0c6a9934877b2ff4
efficientnet_b0__P/fold1.safetensors f54ff6737a1200705372c75cde10a00244b286214bacadc96a8ca3d8badb4d1e
efficientnet_b0__P/fold2.safetensors b8548babd27d6f8aa46477c495b46c08b535d0e4f9e5cbcd797a927aa76f3b62
efficientnet_b0__P/fold3.safetensors 88b055891f6591086af61de4b78ec41d2c420ebe3302e73edfcda44df8e3cc4e
efficientnet_b0__P/fold4.safetensors 57ce5048868bb65dc40c352a227ea27b67ed820b843a2059e45e3c62aa785a93
efficientnet_b4__P/fold0.safetensors e803371cbabe2b3f267cb49c39e8c4635fd0676f04bc1d32f2b0f49ef8ec3bff
efficientnet_b4__P/fold1.safetensors ce286876bfaf45661114e49b6d53f06dbae66a3700add6b496dfecfdd5c54b0f
efficientnet_b4__P/fold2.safetensors d9b84814b00ee07204aa9efa68a1468f106482a8057c9290a86adba91d663c20
efficientnet_b4__P/fold3.safetensors 993d77c21b81f62fe591625104d231af665f4e473e3dddb71068efdee6db68d2
efficientnet_b4__P/fold4.safetensors 2c93c6057a0af9b20c441db0b68d3e2e9fc5519a37073448f764afc7a389f36b
images.csv 21a2debe1492c24eed9fc44626753cb3ef5e2cac1f48a003a22437959c58f052
inference.py f0fa3ca1fa58dc3d24845307f5eb60f7bf8ad0197dc191430eddbfddb8c043fb
resnet50__P/fold0.safetensors ff4ab98b621d737bcd6192d08d867b5446c459b47e00ff2076922c73b213a93e
resnet50__P/fold1.safetensors 14f542ea5037d45a0291abe2e08a70132ea35441699e0abe63120ef8d5500fc0
resnet50__P/fold2.safetensors ddb859fc6685e2448357c3c9256f2ee4a3ead4263d021fb55e981081b0a30458
resnet50__P/fold3.safetensors b5056ba938b3b5f9c5e340f6fb47b3f97c2b06985e8b00699463188ffafb6870
resnet50__P/fold4.safetensors 601f9869b003b026401850ce2c1facce6d68884b225634197c02b4aca4ed1ebf
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support