This repository contains code for a deep learning model that classifies plant diseases based on the images of plant leaves. The model is built using TensorFlow and Keras, and it is trained and evaluated on a dataset containing 501 images belonging to 5 classes.
The dataset consists of images of plant leaves which are categorized into five classes:
- Grass Shoots
- Healthy
- Mites
- Ring Spot
- YLD
The dataset is loaded, shuffled, and partitioned into training, validation, and testing datasets.
The model uses a sequential architecture including:
- Resizing and rescaling layers
- Data augmentation layers for better generalization
- Four Convolutional layers followed by MaxPooling layers for feature extraction
- Flatten layer to transform the 2D matrix data to a vector
- Dense layers for classification
The model is compiled with the Adam optimizer and Sparse Categorical Crossentropy loss function, and it is evaluated based on its accuracy.
- TensorFlow
- Keras
- Matplotlib
- NumPy
- Load the dataset from the specified directory using TensorFlow’s image_dataset_from_directory method.
- Visualize the dataset and understand the distribution of classes.
- Partition the dataset into training, validation, and testing datasets.
- Define the model architecture, compile, and train it using the training dataset.
- Evaluate the model’s performance with the testing dataset.
- Save the trained model for future use.
The model's performance is visualized using Matplotlib to plot graphs of accuracy and loss over epochs for both training and validation datasets.
The trained model is saved as a .h5 file which can be loaded later for predictions.
A function predict
is defined to predict the class of a given image along with the confidence of prediction.
Predictions on the testing dataset are visualized, showing the actual and predicted classes along with the confidence of prediction.