With the advancement of technology, agriculture has seen significant improvements, especially with the integration of machine learning techniques. One of the pressing challenges faced by farmers is the early detection of plant diseases. This project focuses on building a Convolutional Neural Network (CNN) to classify plant diseases from images, specifically targeting diseases in corn, potato, and tomato plants.
Dataset
The dataset used in this project consists of images of plant leaves affected by three common diseases:
- Corn – Common Rust
- Potato – Early Blight
- Tomato – Bacterial Spot
The images were stored on Google Drive and loaded into the Colab environment for preprocessing and training.
Data Preprocessing
The preprocessing steps involved:
- Reading images from directories and assigning binary labels (0 for corn, 1 for potato, 2 for tomato).
- Normalizing the image pixel values by dividing by 225.
- Resizing images to a uniform size of 256x256x3.
- Converting image data to arrays.
- One-hot encoding the labels for multi-class classification.
- Splitting the dataset into training, validation, and test sets.
Model Architecture
The CNN model was built using Keras with the following structure:
- Two convolutional layers with ReLU activation and MaxPooling.
- A flatten layer to convert multi-dimensional input into a 1D array.
- Dense layers for classification with softmax activation to output class probabilities.
The model was compiled using the Adam optimizer with a learning rate of 0.0001 and categorical crossentropy as the loss function.
Model Training
The model was trained for 50 epochs with a batch size of 128. Training and validation accuracy were monitored throughout the process. The model achieved a satisfactory accuracy, as indicated by the plotted training history.
Model Evaluation
After training, the model was tested on unseen data to evaluate its performance. The results showed a high accuracy rate, indicating the model’s effectiveness in identifying plant diseases.
Results and Analysis
The classification report and confusion matrix revealed that the model performed well across all three classes. Additionally, the ROC AUC score demonstrated the robustness of the model.
Conclusion
This project successfully developed a CNN model to classify plant diseases with high accuracy. Early detection can help farmers take preventive measures, minimizing crop loss and ensuring better yield. Further improvements could involve using a more diverse dataset and fine-tuning hyperparameters for enhanced accuracy.