File size: 10,371 Bytes
4824bd5
3fbbbc1
 
4824bd5
3fbbbc1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4824bd5
3fbbbc1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
---
language:
- en
license: other
library_name: tensorflow
pipeline_tag: image-classification
tags:
- image-classification
- image-classification-multiclass
- tensorflow
- keras
- efficientnetv2
- cabbage
- plant-disease-classification
- agricultural-ai
- computer-vision
- transfer-learning
- leaf-disease
datasets:
- Arko007/cabbage-disease-classification-final
metrics:
- accuracy
- balanced_accuracy
- f1
- precision
- recall
model-index:
- name: CabbageGuard EfficientNetV2S Cabbage Disease Classifier
  results:
  - task:
      type: image-classification
      name: Image Classification
    dataset:
      name: CabbageGuard Cabbage Disease Classification Final
      type: image-classification
      config: default
      split: test
    metrics:
    - type: accuracy
      value: 0.9682539682539683
      name: Test accuracy
      verified: true
    - type: balanced_accuracy
      value: 0.980849358974359
      name: Test balanced accuracy
      verified: true
    - type: f1
      value: 0.9723042007524766
      name: Test macro-F1
      verified: true
    - type: precision
      value: 0.9668935104529617
      name: Test macro precision
      verified: true
    - type: recall
      value: 0.980849358974359
      name: Test macro recall
      verified: true
    - type: f1
      value: 0.9683149670378279
      name: Test weighted-F1
      verified: true
    - type: accuracy
      value: 0.75
      name: External source-verified sanity accuracy
      verified: true
      caveat: Small eight-image external sanity set; not a formal benchmark.
---

# 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:

```text
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`](./classes.json). The model artifact is provided as [`final.keras`](./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

```python
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.