File size: 14,475 Bytes
fe69e84 | 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 | # 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.1` → https://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 → `Anthracnose`→`cashew_anthracnose`, `Gummosis`→`cashew_gumosis`, `Leaf miner`→`cashew_leafminer`, `Healthy`→`cashew_healthy` (`Red rust` has no CropGuard class — skip or add one)
- Cassava → `Mosaic`→`cassava_cmd`, `Bacterial blight`→`cassava_cbb`, `Healthy`→`cassava_healthy` (CCMT `Brown spot` and `Green mite` ≠ our classes — skip; CCMT has **no** brown-streak/CBSD, get that from Cassava-Kaggle below)
- Maize → `Fall armyworm`→`maize_faw`, `Streak virus`→`maize_msv`, `Leaf blight`→`maize_nclb`, `Leaf spot`→`maize_gls`, `Healthy`→`maize_healthy` (CCMT `Grasshopper`, `Leaf beetle` ≠ our classes — skip; **common rust** comes from PlantVillage corn)
- Tomato → `Leaf blight`→`tomato_late` *(approx.)*, `Leaf curl`→`tomato_tylcv`, `Septoria leaf spot`→`tomato_septoria`, `Verticillium wilt`→`tomato_wilt`, `Healthy`→`tomato_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___healthy`→`tomato_healthy`, `Tomato___Early_blight`→`tomato_early`, `Tomato___Late_blight`→`tomato_late`, `Tomato___Septoria_leaf_spot`→`tomato_septoria`, `Tomato___Tomato_Yellow_Leaf_Curl_Virus`→`tomato_tylcv`
- `Pepper,_bell___Bacterial_spot`→`pepper_bacterialspot`, `Pepper,_bell___healthy`→`pepper_healthy`
- `Corn_(maize)___Common_rust_`→`maize_rust`, `Corn_(maize)___Northern_Leaf_Blight`→`maize_nclb`, `Corn_(maize)___Cercospora…Gray_leaf_spot`→`maize_gls`, `Corn_(maize)___healthy`→`maize_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`, `Healthy`→`cassava_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.1` → https://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:** `Healthy`→`mango_healthy`, `Anthracnose`→`mango_anthracnose`, `Bacterial Canker`→`mango_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.1` → https://data.mendeley.com/datasets/fwcj7stb8r/1
- **Size:** 5,932 images. India.
- **Licence:** CC BY 4.0 (verify).
- **Folder → class mapping:** `Blast`→`rice_blast`, `Bacterial blight`→`rice_blb`, `Brown Spot`→`rice_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.2` → https://data.mendeley.com/datasets/x6x5jkk873/2
- **Size:** 1,720 field images. India.
- **Licence:** CC BY 4.0 (verify).
- **Folder → class mapping:** `Healthy`→`groundnut_healthy`, `Leaf spot (early and late)`→`groundnut_leafspot`, `Rust`→`groundnut_rust`, `Rosette`→`groundnut_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:** `Sigatoka`→`plantain_sigatoka` *(approx. black sigatoka)*, `Healthy`→`plantain_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:
- **Cowpea** — `cowpea_healthy` `cowpea_blight` `cowpea_mosaic` `cowpea_cercospora`
- **Yam** — `yam_healthy` `yam_anthracnose` `yam_mosaic`
- **Okra** — `okra_healthy` `okra_yvmv` `okra_leafspot`
- **Garden Egg** — `gardenegg_healthy` `gardenegg_wilt` `gardenegg_leafspot`
- **Pepper** — `pepper_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)
```bash
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):
- CCMT: https://data.mendeley.com/datasets/bwh3zbpkpv/1
- MangoLeafBD: https://data.mendeley.com/datasets/hxsnvwty3r/1
- Rice: https://data.mendeley.com/datasets/fwcj7stb8r/1
- Groundnut: https://data.mendeley.com/datasets/x6x5jkk873/2
### 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>/`.
```bash
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
```bash
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.
|