Cucumber
Cucumber disease classification with EfficientNet-B5
- Type
- Training notebook
- Task
- Image classification, 7 classes
- Model
- EfficientNet-B5
- Built with
- TensorFlow and Keras, on Google Colab
Read it
Prefer the files? Download the EfficientNet-B5 notebook (3.9 MB).
What the notebook does
This notebook trains an image classifier that sorts photos of cucumber plants into seven classes: five diseases (anthracnose, bacterial wilt, downy mildew, gummy stem blight and powdery mildew), plus fresh cucumber and fresh leaf.
There are 8,223 images, split class by class into 5,755 for training, 1,233 for validation and 1,235 for testing (70, 15 and 15 percent). The classes are uneven, from 160 images to 3,086, so the notebook weights the classes, uses a focal loss, and augments the smaller classes more heavily.
The model is EfficientNet-B5 with ImageNet weights, fully fine-tuned at 456 × 456 pixels in mixed precision, with a small head of average pooling, dropout and a softmax layer. It trains with AdamW and a warm-up and cosine-decay learning rate for up to 50 epochs. The best checkpoint by validation accuracy is kept, which is epoch 9 in the saved run, and training stopped early at epoch 19.
In the saved run, accuracy on the 1,235 test images is 97.98% and the macro-F1 is 0.9579. The notebook ends with a classification report, confusion matrices, and a helper that predicts the class of a single image.
Where the images come from
The images were gathered from seven published datasets and mixed together for training. Five are on Mendeley Data, under a CC BY 4.0 licence, and two are on Kaggle. Where the same dataset is posted on both sites, only the Mendeley original is listed here. Some of them cover other crops, such as watermelon, luffa and white cabbage, as their titles show.
- White Cabbage Leaf Damage Dataset. Sökmen, Serkan; Turkan, Musa; Marttin, Vedat, 2025. Mendeley Data, version 1, DOI 10.17632/v4f4mxpy32.1. Licence: CC BY 4.0.
- Watermelon Disease Recognition Dataset. Nakib, Mohammad Imtiaz, 2023. Mendeley Data, version 1, DOI 10.17632/ntzym554jp.1. Licence: CC BY 4.0.
- Image Dataset for Disease Detection in Sponge Gourd (Luffa aegyptiaca) Leaves. Lisan, Zadid Al; Das, Showrav; Badhan, Md Mehrab Hossain; Mojumdar, Mayen Uddin, 2024. Mendeley Data, version 2, DOI 10.17632/rx7mr3r5yg.2. Licence: CC BY 4.0.
- Watermelon Disease Dataset. nirmalsankalana. Kaggle. Licence: see the dataset page.
- Cucumber Leaf Disease Dataset. kaushigihanml. Kaggle. Licence: see the dataset page.
- LuffaFolio: A Multifaceted Luffa Aegyptiaca Image Dataset. Islam, Md Masudul; Sheikh, Md Ripon; Himel, Galib Muhammad Shahriar, 2025. Mendeley Data, version 5, DOI 10.17632/kwj9599z73.5. Licence: CC BY 4.0.
- Cucumber Disease Recognition Dataset. Nusrat Sultana, 2022. Mendeley Data, version 1, DOI 10.17632/y6d3z6f8z9.1. Licence: CC BY 4.0.
Changes made: the images were mixed into one folder, split into training, validation and test sets, resized to 456 × 456 pixels, and augmented while training, more heavily for the smaller classes. The notebook reads one combined folder, so it does not show which image came from which source. The images are not included here.
In the notebook
- Overview cell 0
- Imports and configuration cell 1
- Split the dataset cell 3
- Data pipeline: augmentation and balancing cell 5
- Class distribution and augmentation preview cell 7
- Build the model cell 9
- Focal loss, optimizer and callbacks cell 11
- Training cell 13
- Training history cell 15
- Test-set evaluation cell 17
- Predict a single image cell 19
Files and links
- EfficientNet_B5_Keras_A100GPU.ipynb, the training notebook, 3.9 MB
SHA-256
c28b967df0794746cd8c7ae7a28be75e4c5a504f60e158ceb3fac414bfac58c0
Good to know
- The notebook was run on Google Colab with an A100 GPU, as the file records.
- The images are not included here: the notebook reads them from a folder on Google Drive.
- The notebook is shown as it was saved: cells in file order, with the output stored in the file. Its execution counts are not in sequence, because some cells were run more than once. Nothing is re-run here, so the numbers you see are the ones it saved.