- Introduction
- Dataset
- Dependencies
- Installation
- Usage
- Model Architecture and Optimization
- Model Training and Evaluation
- Results
- Saving the Model
- Contributing
- License
- Acknowledgements
This project focuses on detecting diseases in cotton plants using machine learning techniques. Early detection of diseases in cotton plants can help farmers take preventive measures and ensure better crop yields. The project uses a Convolutional Neural Network (CNN) based on ResNet152 architecture for image classification.
The dataset used for this project consists of images of cotton plants with different diseases. It includes labels for various diseases such as leaf blight, bacterial blight, and healthy plants.
You can download the dataset from this link.
The project requires the following Python libraries:
- numpy
- pandas
- matplotlib
- seaborn
- scikit-learn
- OpenCV
- torch
- torchvision
- PIL
- jax
You can install these dependencies using pip
:
pip install numpy pandas matplotlib seaborn scikit-learn tensorflow opencv-python torch torchvision pillow jax
To get started with this project, follow these steps:
- Clone the repository:
git clone https://github.com/mcPython95/cotton-plant-disease-detection.git cd cotton-plant-disease-detection
-
Open the Google Colab notebook:
-
Set the data directory in the notebook:
DataDir = '/content/drive/MyDrive/cotton plant disease detection/dataset/Cotton Disease/'
-
Follow the steps in the notebook to preprocess the data, train the model, and evaluate its performance.
- ResNet152: ResNet, short for Residual Network, is a type of deep neural network that uses residual learning to ease the training of networks that are substantially deeper than those used previously. ResNet152 is a variant with 152 layers, known for its ability to handle the vanishing gradient problem through the use of skip connections or shortcuts, allowing gradients to pass through layers directly, bypassing certain blocks. This architecture improves the training of very deep networks and has proven to be highly effective in image recognition tasks.
- Loss Function: CrossEntropyLoss was used as the loss function to measure the performance of the classification model.
- Optimizer: Stochastic Gradient Descent (SGD) with a learning rate of 0.001 and momentum of 0.9 was employed to update the weights of the network.
- Learning Rate Scheduler: ReduceLROnPlateau was used to adjust the learning rate when the validation loss plateaued, ensuring efficient training.
The model is built using a ResNet152 architecture. The training and evaluation process includes data loading and preprocessing, image augmentation, building and compiling the CNN model, training the model, evaluating the model's performance, and visualizing the results.
The model performed exceptionally well in detecting diseases in cotton plants. It achieved an overall accuracy of approximately 97%. Precision and recall were both high, indicating that the model is effective at identifying both diseased and healthy plants accurately. The F1-Score, which balances precision and recall, was also high. The model demonstrated a low error rate and high specificity, meaning it correctly identified the majority of healthy plants without falsely marking them as diseased. The ROC-AUC score was also high, indicating excellent performance in distinguishing between different classes of plant health.
- Diseased Cotton Leaf: The model perfectly identified diseased cotton leaves with high precision, recall, and F1-score.
- Diseased Cotton Plant: The model showed high precision and recall for detecting diseased cotton plants, ensuring minimal misclassification.
- Fresh Cotton Leaf: Fresh cotton leaves were accurately identified, maintaining a high F1-score.
- Fresh Cotton Plant: The model also accurately detected fresh cotton plants, with high precision and recall.
- Accuracy: 96.84%
- Precision: 97.10%
- Recall: 96.74%
- F1-Score: 96.92%
- Specificity: 97.10%
- ROC-AUC: 97.83%
- Error Rate: 3.16%
After training, the model can be saved to your Google Drive for future use:
torch.save(model, '/content/drive/MyDrive/cotton plant disease detection/cotton_plant_dis_det_model.pt')
We welcome contributions to improve this project. To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.