Welcome to the Potato Disease Classification project! This repository contains a deep learning model designed to identify diseases in potato crops using image classification. Built with TensorFlow and Keras, the model classifies potato leaf images into three categories: Early Blight, Late Blight, and Healthy. The goal is to support farmers and agricultural researchers in early disease detection for healthier crops and sustainable farming.
The model is trained on the PlantVillage dataset, featuring images of potato leaves affected by Early Blight, Late Blight, or no disease (Healthy). Using a Convolutional Neural Network (CNN), the model achieves high accuracy in classifying these images and provides confidence scores for predictions.
- Deep Learning Model: Built with TensorFlow and Keras for robust image classification.
- Dataset: Utilizes the PlantVillage dataset with 2,152 images across three classes.
- Visualization: Displays sample predictions with actual and predicted labels.
- Model Saving: Automatically saves trained models with version control.
To set up the project locally, follow these steps:
-
Clone the Repository:
git clone https://github.com/your-username/potato_disease_classification.git cd potato-disease_classification -
Install Dependencies: Ensure Python 3.11+ is installed, then install the required packages:
pip install tensorflow matplotlib numpy
-
Download the Dataset:
- Download the PlantVillage dataset (Potato subset) from Kaggle or the PlantVillage website.
- Place the dataset in the
PlantVillagedirectory.
-
Jupyter Notebook: Install Jupyter Notebook to run the
model.ipynbfile:pip install jupyter jupyter notebook
The dataset is sourced from the PlantVillage dataset, available on Kaggle or the PlantVillage website. It contains 2,152 images of potato leaves across three classes:
- Potato___Early_blight
- Potato___Late_blight
- Potato___healthy
- Image Size: 256x256 pixels
- Batch Size: 32
- Color Channels: 3 (RGB)
- Training Epochs: 10
The dataset is loaded using TensorFlow's image_dataset_from_directory function with shuffling enabled for randomization.
To train and evaluate the model:
-
Open the Notebook: Launch
model.ipynbin Jupyter Notebook. -
Run the Cells:
- Import libraries and define hyperparameters.
- Load and preprocess the dataset.
- Train the CNN model.
- Visualize predictions on a sample batch.
- Save the trained model to the
modelsdirectory.
-
Example Output: The notebook displays a 3x3 grid of test images, showing:
- Actual class (e.g., Potato___Early_blight)
- Predicted class
- Confidence score (in percentage)
-
Model Saving: Models are saved as
models/{version}.keras, with versioning for easy tracking.
The model is a Convolutional Neural Network (CNN) built using TensorFlow and Keras. Key hyperparameters:
- Image Size: 256x256 pixels
- Batch Size: 32
- Channels: 3 (RGB)
- Epochs: 10
The model architecture is defined in model.ipynb and trained on the PlantVillage dataset. It outputs probabilities for each class, selecting the one with the highest confidence.
The predict function:
- Takes an input image.
- Returns the predicted class and confidence score.
The model achieves an accuracy of 85.86% and a loss of 0.3378 on the test set, evaluated over 8 batches. The notebook visualizes predictions in a 3x3 grid, comparing actual vs. predicted labels with confidence scores.
Note: Accuracy varies based on training runs and dataset splits. Check the notebook for detailed metrics.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make changes and commit (
git commit -m "Add feature"). - Push to the branch (
git push origin feature-branch). - Open a Pull Request.
Ensure your code adheres to the project's coding standards and includes documentation.
- PlantVillage Dataset: For providing the potato leaf images.
- TensorFlow & Keras: For the robust deep learning framework.
- Matplotlib: For visualization capabilities.
Happy farming and coding! πΏ