Skip to content

Commit

Permalink
Merge pull request #53 from Mayank202004/main
Browse files Browse the repository at this point in the history
Added new project plant disease detection under deep learning
  • Loading branch information
UTSAVS26 authored Oct 3, 2024
2 parents 3ed9a53 + a3977b5 commit a200d95
Show file tree
Hide file tree
Showing 29 changed files with 6,351 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
131 changes: 131 additions & 0 deletions Deep_Learning/Plant Disease Detection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Plant Disease Detection using CNN

This project implements a **Convolutional Neural Network (CNN)** to detect plant diseases using images of plant leaves. The model is built using **TensorFlow** and **Keras**, and the dataset used is sourced from **Kaggle**.

## Table of Contents

- [Introduction](#introduction)
- [Dataset](#dataset)
- [Installation](#installation)
- [Model Architecture](#model-architecture)
- [Training](#training)
- [Results](#results)
- [Usage](#usage)


## Introduction

Plant diseases can have a devastating effect on agricultural productivity. This project aims to detect plant diseases from images of plant leaves using CNNs, which are well-suited for image classification tasks. By identifying diseases early, we can potentially help farmers take corrective action sooner and minimize crop damage.

## Dataset

The dataset used for this project is sourced from **[Kaggle](https://www.kaggle.com/)**. It contains labeled images of healthy and diseased plant leaves from various plant species, such as:

- Apple
- Potato
- Tomato
- Grape
- And more...

Each image is categorized into one of several classes, including both healthy and various diseased categories.

## Installation

To set up the project environment, first clone the repository, then install the required dependencies listed in `requirements.txt`.

### Clone the Repository
```bash
git clone https://github.com/your-username/ML-Nexus/tree/main/Neural%20Networks/Plant%20Disease%20Detection.git
cd plant-disease-detection
```

### Install Dependencies
```bash
pip install -r requirements.txt
```

Dependencies include:
- TensorFlow
- Keras
- Matplotlib


## Model Architecture

We employ a **Convolutional Neural Network (CNN)** to process the images and classify them into their respective categories. The architecture consists of:

- **Input Layer:** Input size matching the image dimensions.
- **Convolutional Layers:** For feature extraction (with filters for edges, textures, etc.).
- **Pooling Layers:** To reduce spatial dimensions.
- **Fully Connected Layers:** For classification.
- **Output Layer:** Softmax for classification into plant disease categories.

### Example CNN Layer Structure:
```text
1. Conv2D(32 filters, kernel_size=3x3, activation='relu')
2. MaxPooling2D(pool_size=2x2)
3. Conv2D(64 filters, kernel_size=3x3, activation='relu')
4. MaxPooling2D(pool_size=2x2)
5. Flatten()
6. Dense(128, activation='relu')
7. Dense(number_of_classes, activation='softmax')
```

## Training

The model is trained on the Kaggle dataset, which is split into training and validation sets. We use **categorical cross-entropy** as the loss function and **Adam** optimizer for the training process.

To train the model, simply run:

```bash
python train_model.py
```

Key training details:
- **Epochs:** 50 (adjust based on performance)
- **Batch Size:** 32
- **Validation Split:** 10% of the dataset
- **test Split:** 10% of the dataset
- **train Split:** 80% of the dataset

## Results

After training, the model achieves good accuracy in classifying the plant leaves as healthy or diseased. Below are some key metrics from the model:

- **Test Accuracy:** X%
- **Validation Accuracy:** Y%
- **Loss:** Z%

You can view the training process with graphs of accuracy and loss:

```python
import matplotlib.pyplot as plt
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('Model Accuracy')
plt.ylabel('Accuracy')
plt.xlabel('Epoch')
plt.legend(['Train', 'Validation'], loc='upper left')
plt.show()
```

## Usage

Once the model is trained, you can use it to predict plant diseases by passing images of leaves to the trained model.

```python
from tensorflow.keras.models import load_model
import numpy as np
from keras.preprocessing import image

# Load model
model = load_model('plant_disease_model.h5')

# Load and preprocess image
img = image.load_img('path_to_image.jpg', target_size=(150, 150))
img = image.img_to_array(img)
img = np.expand_dims(img, axis=0)

# Predict
result = model.predict(img)
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,272 changes: 1,272 additions & 0 deletions Deep_Learning/Plant Disease Detection/ipynb files/Cotton_Classification.ipynb

Large diffs are not rendered by default.

1,224 changes: 1,224 additions & 0 deletions Deep_Learning/Plant Disease Detection/ipynb files/Grapes_Classification.ipynb

Large diffs are not rendered by default.

1,200 changes: 1,200 additions & 0 deletions Deep_Learning/Plant Disease Detection/ipynb files/Guava_Classification.ipynb

Large diffs are not rendered by default.

1,214 changes: 1,214 additions & 0 deletions Deep_Learning/Plant Disease Detection/ipynb files/Potato_Classification.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,101 changes: 1,101 additions & 0 deletions Deep_Learning/Plant Disease Detection/ipynb files/Tomato_Classification.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

tensorflow==2.14.0
matplotlib==3.7.2
141 changes: 141 additions & 0 deletions Deep_Learning/Plant Disease Detection/result.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Plant Disease Detection Results
The project focuses on creating multiple tensorflow models using CNN for disease detection of various plants.

## Table of Contents
- [Potato Image Classification](#potato-image-classification)
- [Tomato Image Classification](#tomato-image-classification)
- [Cotton Image Classification](#cotton-image-classification)
- [Guava Image Classification](#guava-image-classification)
- [Grapes Image Classification](#grapes-image-classification)
- [Sugarcane Image Classification](#sugarcane-image-classification)

## Potato Image Classification

### Model Overview
In this project, we aim to classify potato plant health into three categories:

- **Early Blight**
- **Healthy**
- **Late Blight**

### Results
The classification model achieved an impressive accuracy of **98.02%** on the testing dataset. This high accuracy demonstrates the effectiveness of our model in distinguishing between healthy plants and those affected by early and late blight.


### Performance Chart
![Performance Chart](assets/images/potato_result_graph.png)





---

## Tomato Image Classification

### Model Overview
In this project, we aim to classify tomato plant health into ten categories:

- **Bacterial Spot**
- **Early Blight**
- **Late Blight**
- **Leaf Mold**
- **Septoria Leaf Spot**
- **Target Spot**
- **Tomato Yellow Leaf Curl Virus**
- **Tomato Mosaic Virus**
- **Two-Spotted Spider Mite**
- **Healthy**

### Results
The classification model achieved an impressive accuracy of **98.43%** on the testing dataset. This high accuracy demonstrates the model's effectiveness in identifying various tomato diseases and distinguishing healthy plants.

### Performance Chart
![Performance Chart](assets/images/tomato_result_graph.png)

---

## Cotton Image Classification

### Model Overview
In this project, we aim to classify cotton plant health into four categories:

- **Cotton Bacterial Blight**
- **Cotton Curl Virus**
- **Cotton Fusarium Wilt**
- **Healthy**

### Results
The classification model achieved an accuracy of **97.40%** on the testing dataset, showcasing the model's capacity to effectively classify diseases in cotton plants.

### Result Checking
![Performance Chart](assets/images/cotton_result.png)


### Performance Chart
![Performance Chart](assets/images/cotton_result-graph.png)

---

## Guava Image Classification

### Model Overview
In this project, we aim to classify guava plant health into two categories:

- **Anthracnose**
- **Healthy**

### Results
The classification model achieved an impressive accuracy of **98.43%** on the testing dataset, indicating its proficiency in detecting guava diseases.

### Result Checking
![Performance Chart](assets/images/guava_result.png)

### Performance Chart
![Performance Chart](assets/images/guava_result_graph.png)

---

## Grapes Image Classification

### Model Overview
In this project, we aim to classify grape plant health into three categories:

- **Grape Black Measles**
- **Grape Black Rot**
- **Healthy**

### Results
The classification model achieved an impressive accuracy of **99.37%** on the testing dataset. This high accuracy demonstrates the model's ability to classify grape diseases effectively.

### Result Checking
![Performance Chart](assets/images/grapes_result.png)

### Performance Chart
![Performance Chart](assets/images/grapes_result_graph.png)

---

## Sugarcane Image Classification

### Model Overview
In this project, we aim to classify sugarcane plant health into five categories:

- **Healthy**
- **Mosaic**
- **Red Rot**
- **Rust**
- **Yellow**

### Results
The classification model achieved an accuracy of **95.83%** on the testing dataset. This result reflects the model's effectiveness in detecting sugarcane diseases.

### Performance Chart
![Performance Chart](assets/images/sugarcane_result_graph.png)



### Conclusion
The results indicate that the model performs exceptionally well in identifying and classifying potato plant diseases. Further enhancement can be achieved by adding more data and training on additional plant varieties.
The models can be deployed on web or app platform to help farmers detect crop diseases early and easily.

32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,38 @@ The PyVerse repository is organized as follows:
│ │ │ └── CNN_handwritten_digit_recogniser.ipynb
│ │ ├── pie chart.png
│ │ └── requirement.txt
│ ├── Plant Disease Detection
│ │ ├── Final tensorflow Models
│ │ │ ├── cotton.h5
│ │ │ ├── cucumber.h5
│ │ │ ├── grapes.h5
│ │ │ ├── guava.h5
│ │ │ ├── potato.h5
│ │ │ ├── rice.h5
│ │ │ ├── sugarcane.h5
│ │ │ ├── tomato.h5
│ │ │ └── wheat.h5
│ │ ├── README.md
│ │ ├── assets
│ │ │ └── images
│ │ │ ├── cotton_result-graph.png
│ │ │ ├── cotton_result.png
│ │ │ ├── grapes_result.png
│ │ │ ├── grapes_result_graph.png
│ │ │ ├── guava_result.png
│ │ │ ├── guava_result_graph.png
│ │ │ ├── potato_result_graph.png
│ │ │ ├── sugarcane_result_graph.png
│ │ │ └── tomato_result_graph.png
│ │ ├── ipynb files
│ │ │ ├── Cotton_Classification.ipynb
│ │ │ ├── Grapes_Classification.ipynb
│ │ │ ├── Guava_Classification.ipynb
│ │ │ ├── Potato_Classification.ipynb
│ │ │ ├── Sugarcane_Classification.ipynb
│ │ │ ├── Tomato_Classification.ipynb
│ │ │ └── requirements.txt
│ │ └── result.md
│ └── Spam Vs Ham Mail Classification [With Streamlit GUI]
│ ├── Dataset
│ │ ├── newData.csv
Expand Down
32 changes: 32 additions & 0 deletions repo_structure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,38 @@
│ │ │ └── CNN_handwritten_digit_recogniser.ipynb
│ │ ├── pie chart.png
│ │ └── requirement.txt
│ ├── Plant Disease Detection
│ │ ├── Final tensorflow Models
│ │ │ ├── cotton.h5
│ │ │ ├── cucumber.h5
│ │ │ ├── grapes.h5
│ │ │ ├── guava.h5
│ │ │ ├── potato.h5
│ │ │ ├── rice.h5
│ │ │ ├── sugarcane.h5
│ │ │ ├── tomato.h5
│ │ │ └── wheat.h5
│ │ ├── README.md
│ │ ├── assets
│ │ │ └── images
│ │ │ ├── cotton_result-graph.png
│ │ │ ├── cotton_result.png
│ │ │ ├── grapes_result.png
│ │ │ ├── grapes_result_graph.png
│ │ │ ├── guava_result.png
│ │ │ ├── guava_result_graph.png
│ │ │ ├── potato_result_graph.png
│ │ │ ├── sugarcane_result_graph.png
│ │ │ └── tomato_result_graph.png
│ │ ├── ipynb files
│ │ │ ├── Cotton_Classification.ipynb
│ │ │ ├── Grapes_Classification.ipynb
│ │ │ ├── Guava_Classification.ipynb
│ │ │ ├── Potato_Classification.ipynb
│ │ │ ├── Sugarcane_Classification.ipynb
│ │ │ ├── Tomato_Classification.ipynb
│ │ │ └── requirements.txt
│ │ └── result.md
│ └── Spam Vs Ham Mail Classification [With Streamlit GUI]
│ ├── Dataset
│ │ ├── newData.csv
Expand Down

0 comments on commit a200d95

Please sign in to comment.