CabbageGuard EfficientNetV2S

Eight-class cabbage disease image classifier

This repository contains the selected CabbageGuard EfficientNetV2S transfer-learning model for classifying cabbage and brassica leaf or plant-disease images into eight classes. The model was trained on the CabbageGuard final merged dataset and selected using validation macro-F1 only. The held-out test set was kept untouched for model selection.

Important: The model is intended for research and assisted agricultural screening. It is not a substitute for an agronomist, plant pathologist, or diagnostic laboratory. A high softmax confidence is not proof of a correct diagnosis, especially for visually similar diseases or images outside the training distribution.

Model summary

Property Value
Architecture tf.keras.applications.EfficientNetV2S
Pretraining ImageNet weights
Framework TensorFlow / Keras
Input size 384 × 384 RGB
Output 8-class softmax
Training hardware NVIDIA Tesla P100-PCIE-16GB on Kaggle
Training seed 42
Total images 1,272
Split 891 train / 192 validation / 189 test
Best validation epoch 7
Best validation macro-F1 95.85%
Test-time augmentation None
Validation/test augmentation None
Train augmentation Random flip, rotation, zoom, translation, and contrast
Test used for model selection No

Labels and class order

The output index order is fixed and must not be changed when decoding predictions:

0  alternaria_leaf_spot
1  bacterial_leaf_spot
2  black_rot
3  clubroot
4  downy_mildew
5  grey_mould
6  healthy
7  ringspot

The same order is stored in classes.json. The model artifact is provided as final.keras.

Held-out test performance

The following metrics were calculated on the untouched 189-image test set after restoring the best validation-macro-F1 weights. No validation or test augmentation and no test-time augmentation were used.

Metric Score
Accuracy 96.83%
Balanced accuracy 98.08%
Macro-F1 97.23%
Macro precision 96.69%
Macro recall 98.08%
Weighted-F1 96.83%

Per-class test metrics

Class Support Precision Recall F1
Alternaria leaf spot 39 97.14% 87.18% 91.89%
Bacterial leaf spot 25 100.00% 100.00% 100.00%
Black rot 13 81.25% 100.00% 89.66%
Clubroot 18 100.00% 100.00% 100.00%
Downy mildew 28 100.00% 100.00% 100.00%
Grey mould 9 100.00% 100.00% 100.00%
Healthy 40 95.12% 97.50% 96.30%
Ringspot 17 100.00% 100.00% 100.00%

Test performance by source dataset

These source-stratified figures describe the held-out test images and should not be interpreted as independent external validation because the sources contributed to the merged dataset.

Source Test images Accuracy Mean confidence
CabbageGuard canonical 30 80.00% 85.93%
Kaggle PEST_AI 135 100.00% 99.43%
Mendeley Comprehensive Vegetable Leaf Disease 24 100.00% 100.00%

External real-world sanity check

A separate set of internet-sourced images was assembled after visual screening and checking the associated university, extension, or plant-pathology source pages. Search filenames and captions were not treated as sufficient evidence. Ambiguous candidates were excluded from the strict score rather than relabeled after observing the model output.

On the strict eight-image source-verified sanity set, the model achieved:

Metric Result
Top-1 accuracy 6/8 = 75.00%
Mean confidence, all eight 92.64%
Mean confidence, correct predictions 99.97%
Mean confidence, incorrect predictions 70.63%

External-image outcomes

Reference label Correct / total Observed result
Alternaria leaf spot 1 / 2 One image was predicted as Alternaria; one was predicted as Downy mildew at 84.45% confidence.
Black rot 0 / 1 Predicted as Ringspot at 56.80% confidence.
Clubroot 2 / 2 Both root-gall images were correctly predicted as Clubroot.
Downy mildew 2 / 2 Both source-verified examples were correctly predicted.
Ringspot 1 / 1 Correctly predicted as Ringspot.

This external check is small and source-labelled rather than laboratory-confirmed. It is reported to demonstrate domain shift, not to replace a prospective field study. The 75.00% result is materially below the held-out test accuracy and shows that the model should be used as an assisted-screening component with expert confirmation, particularly for black rot and visually similar leaf-spot diseases.

Training protocol and integrity statement

The final dataset contained 1,272 validated images across eight classes with 891 training, 192 validation, and 189 test images. The data audit reported zero corrupt images and zero cross-split exact duplicate groups. Augmentation was applied only to training data. The targeted-improvement run used canonical-source oversampling, targeted oversampling for Alternaria leaf spot, black rot, and downy mildew, and inverse-square-root frequency weighting with documented modifiers. The test set was not used for model selection. No test-time augmentation was used for the reported test metrics or external sanity check.

Intended use and limitations

The model may be useful for a prototype, research comparison, or assisted screening workflow in which the image, predicted class, confidence, and uncertainty are reviewed by a qualified person. It should not be used alone to make treatment, quarantine, crop-destruction, or other high-consequence decisions. The external check exposed a confident Alternaria-to-downy-mildew error, demonstrating that softmax confidence is not a guarantee of correctness.

The model does not provide a calibrated probability of disease presence, does not detect diseases outside the eight labels, and may fail on different cultivars, lighting, backgrounds, growth stages, camera devices, symptom severity, mixed infections, or non-cabbage plants. Images showing roots, whole plants, storage rot, or atypical views may not match the leaf-focused training distribution even when the model outputs a class.

Reproducible inference

import json
import numpy as np
import tensorflow as tf
from PIL import Image

classes = json.load(open("classes.json"))["classes"]
model = tf.keras.models.load_model("final.keras", compile=False)

image = Image.open("your_cabbage_image.jpg").convert("RGB")
image = image.resize((384, 384), Image.Resampling.LANCZOS)
batch = np.expand_dims(np.asarray(image, dtype=np.float32), axis=0)
probabilities = model.predict(batch, verbose=0)[0]
index = int(np.argmax(probabilities))
print({
    "label": classes[index],
    "confidence": float(probabilities[index]),
    "class_probabilities": dict(zip(classes, probabilities.astype(float))),
})

The published model should be treated as an image-classification artifact. Production deployment additionally requires a compatible backend response schema and disease-knowledge base containing the same eight labels. The previously deployed CabbageGuard application was still on a four-class contract at the time of publication of this card and must be updated before this artifact is connected to it.

Files in this repository

File Description
final.keras Selected TensorFlow/Keras model artifact.
classes.json Exact output class order.
config.json Machine-readable model and evaluation metadata.
metrics.json Held-out test metrics and per-class report.
external_validation.json External-image sanity-check metrics and per-image results.
README.md This model card and usage guidance.

Citation and provenance

The model was trained for the CabbageGuard project using the private CabbageGuard final merged dataset published under the Arko007 Hugging Face account. The dataset combines cabbage-disease images from the canonical Mendeley source, the Mendeley Comprehensive Vegetable Leaf Disease source, and Kaggle PEST_AI after validation, deduplication, and split auditing. Please consult the dataset card for source-level licensing and provenance details.

The external sanity-check images were reviewed against source pages from Cornell Vegetables, Washington State University, UW–Madison Vegetable Pathology, Pacific Northwest Pest Management Handbooks, NC State Extension, University of Minnesota Extension, and University of Maryland Extension. Their results are included for transparency and should not be interpreted as a formal benchmark.

Downloads last month
4
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Evaluation results