cropguard-dataset-kit / DATASET_GUIDE.md
The-Bricklayer7's picture
Upload 7 files
fe69e84 verified
|
Raw
History Blame Contribute Delete
14.5 kB

CropGuard GH — Dataset Guide

How to assemble the training dataset for the crop disease detection model. Final Year Project · Oppong David · BTech Computer Technology, Kumasi Technical University


Read this first (important and honest)

There is no single "CropGuard dataset" file to download. The model is trained on a combination of public, peer-reviewed image datasets, plus any images you collect yourself. This guide tells you exactly which datasets to download, where, under what licence, and how to arrange them into the folder layout the training script expects.

Two reasons it works this way:

  1. The images are large and third-party. The datasets below total tens of gigabytes and are published by other researchers under their own licences. They cannot be repackaged here — but every one is free to download from its official repository, linked below.
  2. "All crops" means "all crops we have data for." A model can only learn a disease it has seen. The 14 crops / 55 classes are the crops Ghanaian smallholders grow and for which labelled images exist. Coverage is uneven (see the Coverage tier column) — be honest about this in your report and viva.

The single most field-realistic source is the CCMT dataset, which was collected on farms in Ghana and covers cashew, cassava, maize and tomato. It is the backbone of this project. Everything else fills gaps.


1. Folder layout the training script expects

backend/train.py loads images with Keras image_dataset_from_directory, i.e. one folder per class, split into train / val / test:

data/
├── train/
│   ├── maize_healthy/      *.jpg
│   ├── maize_gls/          *.jpg
│   ├── cassava_cmd/        *.jpg
│   └── ... (one folder per class)
├── val/
│   └── ... (same class folders)
└── test/
    └── ... (same class folders)
  • Folder names must exactly match the 55 class keys (see class_names.txt) — these are the same keys as in backend/recommendations.json, so the API can look up treatment advice by predicted class.
  • A 70 / 15 / 15 train/val/test split is assumed (§3.4.3 of the report). scripts/prepare_dataset.py does the splitting for you.

The 55 classes, by crop:

Crop Classes
Maize maize_healthy maize_gls maize_nclb maize_rust maize_msv maize_faw
Cassava cassava_healthy cassava_cmd cassava_cbsd cassava_cbb
Tomato tomato_healthy tomato_early tomato_late tomato_wilt tomato_septoria tomato_tylcv
Cocoa cocoa_healthy cocoa_blackpod cocoa_cssvd cocoa_capsid
Cashew cashew_healthy cashew_anthracnose cashew_gumosis cashew_leafminer
Plantain plantain_healthy plantain_sigatoka plantain_bbtv plantain_panama
Yam yam_healthy yam_anthracnose yam_mosaic
Pepper pepper_healthy pepper_bacterialspot pepper_anthracnose
Cowpea cowpea_healthy cowpea_blight cowpea_mosaic cowpea_cercospora
Groundnut groundnut_healthy groundnut_leafspot groundnut_rosette groundnut_rust
Rice rice_healthy rice_blast rice_blb rice_brownspot
Okra okra_healthy okra_yvmv okra_leafspot
Garden Egg gardenegg_healthy gardenegg_wilt gardenegg_leafspot
Mango mango_healthy mango_anthracnose mango_bacterialspot

2. The datasets (verified sources)

⚠️ Always confirm the licence on each page before any non-research use. Mendeley Data sets are usually CC BY 4.0; Kaggle competition data is governed by its competition rules. The notes below were accurate at the time of writing — verify on the page.

A. CCMT — Cashew, Cassava, Maize, Tomato (collected in Ghana) ★ primary

  • Source: Mendeley Data — Dataset for Crop Pest and Disease Detection (Mensah, Akoto-Adjepong, Adu et al., Data in Brief 49, 2023, art. 109306).
  • DOI: 10.17632/bwh3zbpkpv.1https://data.mendeley.com/datasets/bwh3zbpkpv/1 (also mirrored on Kaggle)
  • Size: 24,881 raw images (Raw Data.zip, ~1.22 GB) and 102,976 augmented images (CCMT Dataset.zip, ~6.81 GB). 22 classes across the four crops.
  • Collected: University of Energy & Natural Resources, Sunyani, Ghana, Oct–Dec 2022. Field, white, dark and illuminated backgrounds.
  • Licence: Mendeley Data (typically CC BY 4.0 — verify).
  • Folder → class mapping:
    • Cashew → Anthracnosecashew_anthracnose, Gummosiscashew_gumosis, Leaf minercashew_leafminer, Healthycashew_healthy (Red rust has no CropGuard class — skip or add one)
    • Cassava → Mosaiccassava_cmd, Bacterial blightcassava_cbb, Healthycassava_healthy (CCMT Brown spot and Green mite ≠ our classes — skip; CCMT has no brown-streak/CBSD, get that from Cassava-Kaggle below)
    • Maize → Fall armywormmaize_faw, Streak virusmaize_msv, Leaf blightmaize_nclb, Leaf spotmaize_gls, Healthymaize_healthy (CCMT Grasshopper, Leaf beetle ≠ our classes — skip; common rust comes from PlantVillage corn)
    • Tomato → Leaf blighttomato_late (approx.), Leaf curltomato_tylcv, Septoria leaf spottomato_septoria, Verticillium wilttomato_wilt, Healthytomato_healthy

B. PlantVillage — tomato, pepper (and cross-checks)

  • Source: Hughes & Salathé (2015). Mendeley Data DOI 10.17632/tywbtsjrjv.1; GitHub spMohanty/PlantVillage-Dataset; several Kaggle mirrors (e.g. abdallahalidev/plantvillage-dataset).
  • Size: ~54,000 lab images, white backgrounds, 14 crops / 26+ classes.
  • Licence: free for research (verify the specific mirror).
  • Folder → class mapping (the crops we keep):
    • Tomato___healthytomato_healthy, Tomato___Early_blighttomato_early, Tomato___Late_blighttomato_late, Tomato___Septoria_leaf_spottomato_septoria, Tomato___Tomato_Yellow_Leaf_Curl_Virustomato_tylcv
    • Pepper,_bell___Bacterial_spotpepper_bacterialspot, Pepper,_bell___healthypepper_healthy
    • Corn_(maize)___Common_rust_maize_rust, Corn_(maize)___Northern_Leaf_Blightmaize_nclb, Corn_(maize)___Cercospora…Gray_leaf_spotmaize_gls, Corn_(maize)___healthymaize_healthy
    • (ignore PlantVillage's apple/grape/cherry/etc. — not Ghanaian crops)

C. Cassava Leaf Disease (Makerere University / Kaggle)

  • Source: Kaggle competition cassava-leaf-disease-classification (2020).
  • Size: ~21,400 labelled field images from Uganda.
  • Licence: Kaggle competition rules (research/educational).
  • Folder → class mapping: Cassava Mosaic Disease (CMD)cassava_cmd, Cassava Brown Streak Disease (CBSD)cassava_cbsd, Cassava Bacterial Blight (CBB)cassava_cbb, Healthycassava_healthy. This is your source for cassava_cbsd, which CCMT lacks.

D. MangoLeafBD — mango

  • Source: Ahmed et al. (2023), Mendeley Data DOI 10.17632/hxsnvwty3r.1https://data.mendeley.com/datasets/hxsnvwty3r/1
  • Size: 4,000 images, 8 classes, 500 per class. Bangladesh.
  • Licence: CC BY 4.0 (verify).
  • Folder → class mapping: Healthymango_healthy, Anthracnosemango_anthracnose, Bacterial Cankermango_bacterialspot (approx. — bacterial black spot). (Other classes unused.)

E. Rice Leaf Disease Image Samples (Sethy) — rice

  • Source: Sethy et al. (2020), Mendeley Data DOI 10.17632/fwcj7stb8r.1https://data.mendeley.com/datasets/fwcj7stb8r/1
  • Size: 5,932 images. India.
  • Licence: CC BY 4.0 (verify).
  • Folder → class mapping: Blastrice_blast, Bacterial blightrice_blb, Brown Spotrice_brownspot. (Tungro unused.) For rice_healthy, add healthy-rice images (e.g. from the Dhan-Shomadhan or RiceLeafs datasets, or your own).

F. Groundnut Leaf Dataset (Sasmal) — groundnut

  • Source: Sasmal, Das, Dhal et al. (2024), Mendeley Data DOI 10.17632/x6x5jkk873.2https://data.mendeley.com/datasets/x6x5jkk873/2
  • Size: 1,720 field images. India.
  • Licence: CC BY 4.0 (verify).
  • Folder → class mapping: Healthygroundnut_healthy, Leaf spot (early and late)groundnut_leafspot, Rustgroundnut_rust, Rosettegroundnut_rosette. (Alternaria leaf spot unused.)

G. Cocoa (KaraAgroAI + Kaggle) — cocoa

  • CSSVD + healthy + anthracnose: KaraAgroAI Cocoa Dataset (Atuhurra et al., 2024, arXiv:2405.04535) — classes Healthy / CSSVD / Anthracnose → cocoa_healthy, cocoa_cssvd.
  • Black pod: Kaggle Cocoa Diseases (YOLOv4) (serranosebas/enfermedades-cacao-yolov4) and/or GitHub Br-Al/Cocoa-diseases (black pod rot, healthy) → cocoa_blackpod.
  • cocoa_capsid: no good public image set — collect locally (COCOBOD/CRIG can advise) or drop the class.
  • Licence: verify each (research/educational).

H. BananaLSD — plantain/banana

  • Source: Ahmed et al. (2023), Data in Brief — BananaLSD (ScienceDirect S2352340923006959; Kaggle mirrors exist).
  • Size: 937 images + ~1,600 augmented, classes Sigatoka / Cordana / Pestalotiopsis / Healthy. Bangladesh.
  • Folder → class mapping: Sigatokaplantain_sigatoka (approx. black sigatoka), Healthyplantain_healthy.
  • plantain_bbtv (bunchy top) and plantain_panama (Fusarium wilt): not in BananaLSD — collect locally or source separately.

I. Crops with little/no dedicated public dataset — collect locally

These Ghanaian crops/classes have weak public coverage. Plan to photograph them in the field (extension officers, research stations, and the crops themselves are the source). Until then, the model will be unreliable on them and you should say so:

  • Cowpeacowpea_healthy cowpea_blight cowpea_mosaic cowpea_cercospora
  • Yamyam_healthy yam_anthracnose yam_mosaic
  • Okraokra_healthy okra_yvmv okra_leafspot
  • Garden Egggardenegg_healthy gardenegg_wilt gardenegg_leafspot
  • Pepperpepper_anthracnose (chili-anthracnose sets exist on Kaggle; pepper bacterial spot + healthy come from PlantVillage)

3. Coverage tiers (put this in your report)

Tier Meaning Crops / classes
Strong (Ghana field data) Collected in Ghana, field-realistic cashew, cassava, maize, tomato (via CCMT + Cassava-Kaggle)
Good (non-Ghana public data) Solid labelled images, but a domain/region gap mango, rice, groundnut, cocoa (CSSVD/black pod), plantain (sigatoka), pepper (bacterial spot)
Weak (little/no public data) Needs locally collected images to be usable cowpea, yam, okra, garden egg, plantain bbtv/panama, cocoa capsid, pepper anthracnose

This is why train.py reports the real held-out test accuracy at the end of training rather than assuming the ~98% target: accuracy will be high on the well-covered crops and lower on the weak ones until you add local images. The ~98% figure is consistent with the literature on this kind of benchmark (Mohanty et al. 2016 = 99.35%; Ferentinos 2018 = 99.53%) but must be earned on your test set, not declared.


4. How to download

Option 1 — Kaggle CLI (fastest for the Kaggle-hosted sets)

pip install kaggle                      # then put kaggle.json in ~/.kaggle/
kaggle competitions download -c cassava-leaf-disease-classification
kaggle datasets download -d abdallahalidev/plantvillage-dataset
kaggle datasets download -d serranosebas/enfermedades-cacao-yolov4

Option 2 — Mendeley Data (CCMT, MangoLeafBD, Rice, Groundnut)

Open the DOI link in a browser and click Download (Mendeley serves a redirect to the file; scripted download is unreliable, so do these by hand):

Option 3 — helper script

scripts/download_dataset.py lists every dataset, attempts the Kaggle downloads automatically (if the Kaggle CLI is configured) and prints the manual links for the Mendeley/GitHub sets. See scripts/ for usage.

Unzip everything into a single working folder, e.g. raw_downloads/.


5. How to turn the downloads into data/

scripts/prepare_dataset.py:

  1. reads a MAPPING (source dataset + subfolder → CropGuard class key — pre-filled from the tables above),
  2. copies images into a flat data_flat/<class>/ tree,
  3. splits each class 70/15/15 into data/train|val|test/<class>/.
python scripts/prepare_dataset.py --raw ./raw_downloads --out ./data

Open the script and adjust the source paths to match where you unzipped each dataset (folder names differ slightly between mirrors). It prints a per-class image count at the end so you can see which classes are thin and need local images.


6. Then train

cd backend
pip install -r requirements.txt
python train.py --data ../data --arch efficientnet --epochs-head 20 --epochs-fine 30

train.py will print the class list it found, train in two phases, and report the held-out test accuracy vs the ~0.98 target. If you are below target, the script tells you what to do (use EfficientNetB0, add field data, or train longer).


7. Citations (add these to your references)

  • Mensah, P.K., Akoto-Adjepong, V., Adu, K., et al. (2023). CCMT: Dataset for crop pest and disease detection. Data in Brief, 49, 109306.
  • Hughes, D.P. & Salathé, M. (2015). An open access repository of images on plant health… (PlantVillage). arXiv:1511.08060.
  • Makerere University AI Lab (2020). Cassava Leaf Disease Classification. Kaggle.
  • Ahmed, S.I., Ibrahim, M., Nadim, M., et al. (2023). MangoLeafBD: A comprehensive image dataset… Data in Brief, 47, 108941.
  • Sethy, P.K., Barpanda, N.K., Rath, A.K. & Behera, S.K. (2020). Rice Leaf Disease Image Samples. Mendeley Data.
  • Sasmal, B., Das, A., Dhal, K.G., et al. (2024). A novel groundnut leaf dataset… Data in Brief, 55, 110763.
  • Atuhurra, J., Douha, N.Y.-R., Lenka, P. (2024). Image Classification for CSSVD Detection in Cacao Plants (KaraAgroAI Cocoa Dataset). arXiv:2405.04535.
  • Ahmed, S.I., et al. (2023). BananaLSD: A banana leaf images dataset… Data in Brief.