# AI-Driven Crop Disease Detection for Nigerian Agriculture
## Project Overview
This project implements a comparative analysis of Artificial Intelligence models to detect diseases in staple Nigerian crops, specifically **Cassava** and **Maize**. By automating disease identification, we aim to bridge the gap between smallholder farmers and expert diagnostic services.
## Key Features
- **Dataset**: 12,866 images sourced from the Mendeley Data Repository.
- **Comparison**: Evaluated a Deep Learning CNN (MobileNetV2) against a classical Random Forest model.
- **Dynamic Preprocessing**: Implemented robust image loaders that handle truncated data streams and complex directory structures.
## Results
The Convolutional Neural Network (CNN) significantly outperformed the classical model:
* **CNN (MobileNetV2) Accuracy**: 84.53%
* **Random Forest Accuracy**: 65.58%
The CNN showed exceptional performance in identifying **Cassava Mosaic** and **Maize Grasshopper** damage (F1-Scores > 0.90).
## Technical Stack
- **Languages**: Python
- **Frameworks**: TensorFlow, Keras, Scikit-learn
- **Tools**: Google Colab (Tesla T4 GPU), OpenCV, Pandas, Matplotlib
## File Structure
- `src/data_loader.py`: Handles data augmentation and directory mapping.
- `src/model_cnn.py`: Implementation of the Transfer Learning architecture.
- `src/model_rf.py`: Classical machine learning implementation using deep feature extraction.
## How to Use / Quick Start
1. Clone the repository.
2. Install dependencies: `pip install -r requirements.txt`.
3. Ensure your dataset is structured into `train`, `validation`, and `test` folders.
*(Note: The full dataset must be downloaded from the Mendeley link [Insert Mendeley Link Here].)*
4. Run `python main.py` to train the model.
5. **Quick Start**: To test the model, place an image in the project root and run: `python predict.py --image your_image.jpg`
*(Note: The pre-trained model `cnn_mobilenetv2_trained_model.h5` is included, so you can run inference immediat …