100% found this document useful (1 vote)
68 views27 pages

Plant Disease Detection with CNN

Uploaded by

nadah4197
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
68 views27 pages

Plant Disease Detection with CNN

Uploaded by

nadah4197
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

October 6 UNIVERSITY

DEPARTMENT OF COMPUTER SCIENCE & Artificial intelligence


Faculty of computer science and information systems

MAJOR PROJECT DOCUMENTAION


ON
“PLANT DISEASE DETECTION USING CNN”

SUBMITTED TO THE 8TH SEMESTER


MAJOR PROJECT (16CS481) COURSE

BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE & ENGINEERING

Submitted by

B G RAHUL KARRTHIK-(ENG17CS0044)
B M MADHURYA-( ENG17CS0046)
BHAVYA M-( ENG17CS0052)
DARSHAN A-(ENG17CS0060)

Under the guidance of


Professor Lavanya B Koppal
ACKNOWLEDGEMENT
Both scientifically and practically, we have put a lot of effort into our project. All of this
wouldn't have been possible without Allah, Doctors, Assistants, and team members. We all
would like to extend our gratitude to the Dean of the Faculty of Information Systems and
Computer Science Prof. Dr. Nabila Mohamed Hassan for her efforts and encouragement to
us.
We all have special thanks to Assoc. Prof. Hussam ElBehiery Head of Projects Department
& Dr. Ahmed Emad for her efforts and her guidance and constant supervision as well as for
providing necessary information regarding the project and for her support in completing the
project.
We all have special thanks to Prof. Dr. Mahmod Alzaabalawi dean of the Faculty of
Agriculture, Banha University for providing necessary information regarding the project and
for her support in completing the project.
We all have special thanks to Eng. Hager Mohamed for her continuous support with us and
giving us comments and her kind cooperation and encouragement, which helped us in
completing this project.

i
ABSTRACT
Agriculture and modern farming are one of the fields where AI and Deep learning can have a
great impact. Maintaining healthy plants and monitoring their environment in order to
identify or detect diseases is essential to maintain a maximum crop yield. The implementation
of current high rocketing technologies including artificial intelligence (AI), machine learning,
and deep learning has proved to be extremely important in modern agriculture as a method of
advanced image analysis domain. Artificial intelligence adds time efficiency and the
possibility of identifying plant diseases, in addition to monitoring and controlling the
environmental conditions in farms. Several studies showed that machine learning and deep
learning technologies can detect plant diseases upon analyzing plant leaves with great accuracy
and sensitivity. In this study, considering the worth of machine learning for disease detection,
we present a convolutional neural network VGG-16 model to detect plant diseases, to allow
farmers to make timely actions with respect to treatment without further delay. To carry this
out, 39 different classes of plants diseases were chosen, and use with it 6 different
Augmentation Techniques. The techniques are image flipping, Gamma correction, noise
injection, PCA color augmentation, rotation, and Scaling. were 61,486 plant leaf images (both
diseased and healthy leaves) were acquired from the Plant Village dataset for training and
testing. In our work, we used 85% of the data for training, 15% for testing, 70% of the trained
data were taken as validation data. Total 36584 for train, 15679 for validation and remaining
images for testing. Based on the experimental results, the proposed model can achieve an
accuracy of about 98.7% with the testing loss being only 0.4418. The proposed model provides
a clear direction toward a deep learning-based plant disease detection to apply on a large scale
in future.

ii
TABLE OF CONTENTS

CERTIFICATE ...................................................................................... Error! Bookmark not defined.


ACKNOWLEDGEMENT ....................................................................................................................... i
ABSTRACT ........................................................................................................................................... ii
TABLE OF CONTENTS ....................................................................................................................... iii
CHAPTER 1 ........................................................................................................................................... 1
1.1. Introduction ................................................................................................................................. 1
1.2. Objective .................................................................................................................................. 2
1.3. Problem Statement ................................................................................................................... 3
CHAPTER 2 ........................................................................................................................................... 3
2. Literature Survey ............................................................................................................................ 3
CHAPTER 3 ........................................................................................................................................... 7
3.2. Methodology ............................................................................................................................ 7
CHAPTER 4 ......................................................................................................................................... 15
4. Implementation ............................................................................................................................. 15
4.1. Requirement Analysis ........................................................................................................ 15
4.1.1. Functional Requirement .................................................................................................. 15
4.1.2. Hardware Requirement .................................................................................................... 15
4.1.3. Software Requirement ..................................................................................................... 15
4.2. Code Snippets ........................................................................................................................ 15
4.3. Test Cases ............................................................................................................................... 17
CHAPTER 5 ......................................................................................................................................... 18
5.1. Results........................................................................................................................................ 18
5.2. Conclusion ................................................................................................................................. 22
5.2. Future work................................................................................................................................ 22
References ............................................................................................................................................ 23

iii
PLANT DISEASE DETECTION USING ML

CHAPTER 1
1.1. Introduction
Agriculture has always been a basic human need ever since Humans’ existence as plants were
a primary source of food. Even nowadays, agriculture is still considered an essential food
resource and is the center of several aspects in humans’ lives. As a matter of fact, agriculture
serves as the pillar of economy in many countries regardless of their developmental stages.
The various domains that show the importance of agriculture include the fact that agriculture
is a main source of livelihood where approximately 70% of the population depends on plants
and their cultivation for livelihood. This great percentage reflects on agriculture being the
most important resource that can stand a chance in the face of the rapidly increasing
population. One of the most critical challenges that face agriculture and affects it trade is plant
diseases and how to timely detect them and deal with them to improve the health of crops.

By definition, plant disease in a type of natural


problems that occur in plants affecting their
overall growth and might lead to plant death in
extreme cases. Plant diseases can occur
throughout the different stages of plant
development including seed development,
seedling, and seedling growth. When diseased,
plants go through different mechanical,
morphological, and biochemical changes
Truthfully, there are two main types of plant
stress classified as biotic stress represented by
living creatures that interact with plants in a way
that negatively affects their growth such as
bacteria, viruses, or fungi, or abiotic stress
represented by the collection of non-living
factors or the environmental factors. Figure1,
illustrates the collection of factors that Figure1
contribute to plant diseases

A common approach in this case is the use of remote sensing techniques that explore multi
and hyper spectral image captures. The methods that adopt this approach often employ digital
image processing tools to achieve their goals. Image processing technology in agricultural
research has made significant development.

Deep learning techniques, and in particular Convolutional Neural Networks (CNNs), have led
to significant progress in image processing. Since 2016, many applications for the automatic
identification of crop diseases have been developed. These applications could serve as a basis
for the development of expertise assistance or automatic screening tools. Such tools could
contribute to more sustainable agricultural practices and greater food production security.

1
PLANT DISEASE DETECTION USING ML

Figure2: shows plant diseases identification research timeline


Artificial intelligence, computer vision and machine learning utilizations can greatly enhance
the process of plant disease detection and is already applied in multiple research papers.
Such technologies are capable of not only detecting the presence of a disease, but it is also
possible to determine its severity, and to classify exactly which kind of disease is present in a
given plant sample. Based on their depth, the plant disease detection methods can be divided
into shallow architectures and deep architectures. Basic machine learning methods like
Random Forest (RF), Support Vector Machine (SVM), Naïve Bayes (NB), and K-Nearest
Neighbor (KNN) rely on specific design intended for features such that good features and
patterns must be recognized. These specific features include hue saturation value (HSV),
Histogram of Oriented gradient (HOG), linear binary pattern (LBP), and red-green-blue RGB
color features. In machine learning, according to the complexity of the classifier, the more data
is required for its training in order to achieve satisfactory results

So, why we use vgg16?


VGG-16 is one of the most commonly used CNN architecture, especially since it works well
with the ImageNet, which is large project utilized for visual object recognition procedures, and
it is considered one of the best models to be proposed so far due to its extreme usefulness in
the image classification’s field in the deep learning domain. Initially, this model was created
by Karen Simonyan and Andrew Zisserman in 2014, where they developed in during their work
in Oxford University titled “Very Deep Convolutional Networks for Large-Scale Image
Recognition”. In fact, “V” means Visual,” G” Geometry while “G” stands for research group
who contributed to the development of this Convolutional Neural Network model, whereas the
number 16 refers to the neural network layer’s number. ImageNet is so large that it contains
more than fourteen million images distributed over thousand classes. This architecture is one
of the top 5 models in terms of performance achievement in the ImageNet dataset, where its
accuracy reached 98.7%. As an approach for the Alex Net enhancement, this architecture was
submitted to ImageNet.

2
PLANT DISEASE DETECTION USING ML

1.2. Objective
Detection of plant leaves diseases and pests needs experience and experts. So, we like to
equip the young generation of inexperienced farmers with a Flask web application that can
help them in their farms to detect the diseases in their plants and provide them with
appropriate remedies and set of guidelines to deal with affected part according to the disease
detected.

1.3. Problem Statement


Create a Flask web application that makes use of CNN to build a model by making use of the
images of the plant leaf, so as to detect the disease and suggest the appropriate remedies to
counteract the disease.
If the leaf is found unhealthy i.e., diseased, our project tells what type of disease that the leaf
is infected with and brief description about it. Our main objective is to classify whether the
leaf is having Bacterial spot, Late Blight, Yellow Curl Leaf virus using Deep learning
techniques, and in particular Convolutional Neural Networks (CNNs) built in Pytorch Frame
work and VGG-16 model while the ANN and KNN were used to classify the plant diseases; a
content-based filtering recommendation algorithm was used to suggest relevant treatments for
the detected plant diseases after classification. The result of the implementation shows that the
system correctly detected and recommended treatment for plant diseases. Also suggesting
guidelines concerning how to deal with the plant in this situation according to the diseases
types

CHAPTER 2
2. Literature Survey

Introduction
Plant diseases pose a significant threat to agriculture, impacting crop yield and quality. Early
detection of plant diseases is crucial for effective management and prevention of widespread
outbreaks. Recent advancements in deep learning, particularly Convolutional Neural
Networks (CNNs), have shown promise in accurately detecting and classifying plant diseases
from images, contributing to more sustainable agriculture. This literature review examines
current research on CNNs and related models in plant disease detection, focusing on
methodologies, datasets, performance, and limitations.

CNN-Based Approaches for Plant Disease Detection

Several studies have highlighted CNNs as a powerful tool for image-based plant disease
detection. CNNs are well-suited for this task because of their ability to learn complex spatial
hierarchies in images, making them effective in identifying subtle visual patterns associated
with specific diseases.

3
PLANT DISEASE DETECTION USING ML

For instance, Ferentinos (2018) developed a deep learning model based on CNNs for
detecting diseases in 25 different plant species. The model achieved over 99% accuracy on the
Plant Village dataset, demonstrating CNNs' effectiveness in recognizing visual features
indicative of disease. This study used a VGG16-based model, emphasizing the impact of
transfer learning in achieving high accuracy with limited labeled data.

In another study, Mohanty, Hughes, and Salathé (2016) trained deep CNN models on the
Plant Village dataset, comprising more than 50,000 labeled images of healthy and diseased
plant leaves. Their model achieved an accuracy of 99.35%, underscoring CNNs’ potential for
high-performance disease detection. Their work further explored generalization to new
datasets, highlighting that training on diverse datasets improves the model's robustness in real-
world applications.

Transfer Learning and Pre-trained Models

Transfer learning has become an essential approach in plant disease detection due to limited
labeled data availability. By leveraging pre-trained CNN models, researchers have achieved
high accuracy with relatively small datasets. Too et al. (2019) investigated the performance of
pre-trained architectures such as ResNet, VGG, and Inception on plant disease detection.
They found that ResNet-50 outperformed other models, achieving an accuracy of 97.35% on a
custom dataset, demonstrating the power of deeper networks in capturing disease-specific
features.

Additionally, Picon et al. (2019) employed MobileNet, a lightweight CNN model, to detect
grapevine diseases. The model achieved accuracy levels comparable to more complex
architectures while significantly reducing computational requirements, making it suitable for
mobile and edge devices in real-time applications. This research illustrates the adaptability of
transfer learning for practical applications in agriculture.

Data Augmentation and Generalization

Generalization remains a challenge in plant disease detection, as models trained on one


dataset may perform poorly when tested on data from different sources. Lu et al. (2017)
addressed this issue by applying data augmentation techniques, such as rotation, scaling, and
flipping, to increase model robustness. Their augmented dataset improved the model’s
generalization capabilities, achieving an accuracy increase of up to 5% on external validation
data.

Moreover, Fuentes et al. (2018) proposed a region-based CNN (R-CNN) for detecting
multiple diseases in tomato plants. This model used selective search and data augmentation to
improve accuracy and robustness, demonstrating that careful data preparation is crucial for
disease detection across varying conditions and plant species.

Limitations and Future Directions

Despite the promising results, several challenges remain in CNN-based plant disease
detection. The dependency on large labeled datasets, limited generalization to different
conditions (e.g., varying lighting, angles, or environmental conditions), and high

4
PLANT DISEASE DETECTION USING ML

computational demands restrict practical deployment in real-time and resource-constrained


settings.

Future research may focus on expanding datasets with diverse environmental conditions,
developing lightweight models for deployment on mobile and IoT devices, and improving
robustness through advanced data augmentation or semi-supervised learning techniques.
Additionally, integrating CNNs with Internet of Things (IoT) technology for real-time disease
monitoring could greatly enhance agricultural practices.

Previous work applications:


1. Smart Farming: Pomegranate Disease Detection Using Image Processing, 2015
A web-based tool has been developed to identify fruit diseases by uploading fruit image to the
system. Feature extraction has been done using parameters such as colour, morphology and
CCV (colour coherence vector). Clustering has been done using the k-means algorithm. SVM
is used for classification as infected or non-infected. This work achieved an accuracy of 82%
to identify pomegranate disease. [3]

2. Leaf Disease Detection and Recommendation of Pesticides using Convolution Neural


Network, 2018
Crop production problems are common in India which severely effect rural farmers, agriculture
sector and the country’s economy as a whole. In Crops leaf plays an important role as it gives
information about the quantity and quality of agriculture yield in advance depending upon the
condition of leaf. In this paper we proposed the system which works on pre-processing, feature
extraction of leaf images from plant village dataset followed by convolution neural network for
classification of disease and recommending Pesticides using Tensor flow technology. The main
two processes that we use in our system is android application with Java Web Services and
Deep Learning. We have use Convolution Neural Network with different layers five, four &
three to train our model and android application as a user interface with JWS for interaction
between these systems. Our results show that the highest accuracy achieved for 5-layer model
with 95.05% for 15 epochs and highest validation accuracy achieved is for 5- layer model with
89.67% for 20 epochs using tensor flow. [4]

3. An Artificial Intelligence and Cloud Based Collaborative Platform for Plant Disease
Identification, Tracking and Forecasting for Farmers, 2018
This paper presents an automated, low cost and easy to use end-to-end solution to one of the
biggest challenges in the agricultural domain for farmers – precise, instant and early diagnosis
of crop diseases and knowledge of disease outbreaks - which would be helpful in quick decision
making for measures to be adopted for disease control. This proposal innovates on known prior
art with the application of deep Convolutional Neural Networks (CNNs) for disease
classification, introduction of social collaborative platform for progressively improved
accuracy, usage of geocoded images for disease density maps and expert interface for analytics.
High performing deep CNN model “Inception” enables real time classification of diseases in
the Cloud platform via a user facing mobile app. [5]

5
PLANT DISEASE DETECTION USING ML

4. CNN based Leaf Disease Identification and Remedy Recommendation System, 2019
This paper focus upon plant disease detection using image processing approach. This work
utilizes an open dataset of 5000 pictures of unhealthy and solid plants, where convolution
system and semi supervised techniques are used to characterize crop species and detect the
sickness status of 4 distinct classes. Convolution neural network is used to detect and classify
plant diseases. The Network is trained using the images taken in the natural environment and
achieved 99.32% classification ability. This shows the ability of CNN to extract important
features in the natural environment which is required for plant disease classification. [6]

5. Plant Leaf Diseases Detection and Classification Using Image Processing and Deep
Learning Techniques, 2020
This paper presents a system that is used to classify and detect plant leaf diseases using deep
learning techniques. The used images were obtained from (Plant Village dataset) website. In
our work, we have taken specific types of plants; include tomatoes, pepper, and potatoes, as
they are the most common types of plants in the world and in Iraq in particular. This Data Set
contains 20636 images of plants and their diseases. In our proposed system, we used the
convolutional neural network (CNN), through which plant leaf diseases are classified, 15
classes were classified, including 12 classes for diseases of different plants that were detected,
such as bacteria, fungi, etc., and 3 classes for healthy leaves. As a result, we obtained excellent
accuracy in training and testing, we have got an accuracy of (98.29%) for training, and
(98.029%) for testing for all data set that were used.[7]

6
PLANT DISEASE DETECTION USING ML

CHAPTER 3
3.2. Methodology
The main aim is to implement a web application with trained model or an efficient system
which provide plant diseases detection and classification. It predicts the disease class,
description for the disease and the suggested remedies for that disease. For that purpose, we
have used a collected dataset from Plant Village. The dataset has gone into two phases: 1st is
training phase and 2nd is testing phase. In the first phase: Image acquisition (fetching image
from the dataset), Image Pre-processing that include six techniques for increasing the data-set
size (The techniques are image flipping, Gamma correction, noise injection, PCA color
augmentation, rotation, and Scaling), dataset splitting into training, testing and validation
datasets and convolutional neural network (CNN) based training.

Figure3: shows plant disease detection process

In the second phase Image acquisition, Image Pre-processing, Classification and disease
identification and suggest appropriate remedies as shown in figure3.

7
PLANT DISEASE DETECTION USING ML

A. Image Acquisition:
For training, images are taken from a plant village dataset. In this data-set, 39 different classes
of plant leaf and background images are available as shown in table 1. The data-set containing
61,486 images and are saved in the system. Since the introduction of the Plant Village dataset,
it has become the most commonly used dataset for training and developing deep learning-based
plant disease identification and severity estimation models. The images are divided across 39
different diseases affecting 14 crops as shown in table1. Most of the images were acquired
under controlled lab conditions with uniform backgrounds. For the purpose of testing the
images of the plant leaves are taken from the dataset or captured images and when required and
then transferred to a folder on the system for analysis.

Fig. 4. Number of studies conducted for identifying diseases in


different crops using publicly available and custom datasets.

B. Image Pre-Processing:
Image should be processed before sending to the algorithm for testing and training purpose.
For that purpose, we used six different augmentation techniques for increasing the data-set size.
The techniques are image flipping, Gamma correction, noise injection, PCA color
augmentation, rotation, and Scaling.

Image flipping:
Description: This involves creating a mirrored version of the image either
horizontally (left to right) or vertically (top to bottom).
Purpose: Image flipping increases the dataset's variety by adding new orientations,
allowing the model to recognize plant diseases from different perspectives. This helps
the model become more robust in detecting features irrespective of how the image is
oriented.

8
PLANT DISEASE DETECTION USING ML

Gamma Correction
Description: Gamma correction adjusts an image's brightness by applying a non-
linear transformation to pixel values. If gamma < 1, the image darkens; if gamma > 1,
the image brightens.
Purpose: This technique simulates images taken under varying lighting conditions. It
helps the model learn features in both bright and dark environments, reducing the
impact of lighting variations on model accuracy.

Noise Injection
Description: Noise injection adds random pixel variations (like Gaussian noise) to the
image, simulating random imperfections.
Purpose: By adding noise, the model learns to focus on key features instead of noise
patterns. This makes the model more robust to image imperfections, like sensor noise
or environmental artifacts.

PCA Color Augmentation


Description: Principal Component Analysis (PCA) color augmentation adjusts the
image’s color channels based on the primary color components. It shifts colors in a
subtle, randomized way along the dominant color axes.
Purpose: This technique simulates slight color variations due to lighting or camera
settings. It reduces the model’s sensitivity to minor color shifts, helping it generalize
better to real-world scenarios with color differences.

Rotation
Description: This involves rotating the image by a specified angle, such as 90°, 180°,
or random angles within a certain range.
Purpose: Plants can appear at any angle in real-world images. Rotation enables the
model to recognize diseases irrespective of the plant’s orientation, making it more
robust to variations in angle.

Scaling
Description: Scaling involves resizing the image, either zooming in (making features
larger) or zooming out (making features smaller).
Purpose: This technique accounts for variations in distance between the camera and
the plant. Scaling allows the model to recognize diseases at different scales, improving
its adaptability to images with varied levels of zoom.

9
PLANT DISEASE DETECTION USING ML

Table 1: showing plant village dataset for 39 classes


different diseases affecting 14 crops

C. Convolutional Neural Network:


Once pre-processing is done, then CNN is used for training purpose and after that we get a
trained model. A Convolutional Neural Network (CNN) architecture is a deep learning model
designed for processing structured grid-like data, such as images. It consists of multiple layers,
including convolutional, pooling, and fully connected layers. CNNs are highly effective for
tasks like image classification, object detection, and image segmentation due to their
hierarchical feature extraction capabilities. By using this model, we classify the image that the
system is getting after pre-processing of testing image. Then we get particular disease name or
status of healthy leaf if there is no disease on that leaf. With the help of that disease name, we
get the remedies which will help the farmer to take action so as to eradicate or decrease the
effect of disease.

10
PLANT DISEASE DETECTION USING ML

Fig5: CNN architecture

1. Input Layer
The input layer contains the input images and their pixel values.

2. Convolution Layer
The Convolution Layer is a layer in a neural network where a small matrix, called a filter or
kernel, slides over the input image to perform a mathematical operation called convolution.
This operation creates a new matrix, known as a feature map or activation map, which
highlights specific features of the input image, such as edges, textures, or shapes.
How the Convolution Operation Works
1. Kernel/Filter: A kernel is a small, usually square matrix 3x3 with values that define a
specific pattern. This kernel is applied over the entire input image.
2. Sliding the Kernel: The kernel slides over the image, moving pixel by pixel
(determined by the stride). At each position, it performs an element-wise
multiplication with the overlapping section of the input image.
3. Summing the Values: The products from the element-wise multiplication are summed
up, resulting in a single value that is placed in the output feature map.
4. Resulting Feature Map: The final output of a convolution operation is a feature map,
which represents the presence and intensity of specific features in the input.

Key Parameters of Convolution Layers


• Filter Size: The dimensions of the kernel, commonly 3x3.
• Stride: Determines how far the filter moves each time. A stride of 1 moves the filter
one pixel at a time, while a stride of 2 moves it two pixels, resulting in a smaller
feature map.
• Padding: Adding extra pixels around the edges of the image (usually zeros) to control
the output size. Padding ensures that the filter has room to move across the entire
input, especially near the edges.

3. Pooling Layer
is used after convolution layers to down sample the feature maps. It works by summarizing
regions of the feature map, effectively reducing its size while retaining the most important
information. This is achieved by applying a specific operation, typically max pooling or
average pooling, to small patches within each feature map.
How Pooling Works
1. Pooling Window: The pooling layer uses a small sliding window (e.g., 2x2 or 3x3),
similar to the filter used in a convolution layer, to move across each feature map.

11
PLANT DISEASE DETECTION USING ML

2. Stride: The stride in pooling defines how far the window moves at each step.
Commonly, a stride of 2 is used to down sample by half.
3. Pooling Operation: For each position of the pooling window, a single value is
computed based on the chosen pooling method. The most common pooling methods
are:
o Max Pooling: Takes the maximum value within the pooling window. This
operation captures the most prominent feature within each region, helping the
network focus on key activations.
o Average Pooling: Calculates the average of all values within the pooling
window. This approach smooths out features, providing an average
representation of each region.

4. Non-Linear Layer (activation layer)


Activation Layer, introduces non-linearity into a (CNN). They enable the network to learn
complex patterns and relationships in the data as textures, shapes, and edges. These patterns
are vital for tasks like image classification and object detection, allowing CNNs to model a
wide range of features beyond simple linear transformations.
ReLU (Rectified Linear Unit)
• Definition: f(x)=max (0, x)
• How It Works: If the input is positive, ReLU passes it as-is. If the input is negative, it
outputs zero.
• Benefits: ReLU is fast to compute and helps prevent the vanishing gradient problem.
It introduces sparsity by setting negative values to zero, making the model more
efficient and less likely to overfit.

5. Fully Connected Layer


Dense Layer, every neuron is connected to every neuron in the previous layer. This layer is
typically used near the end of (CNNs) to combine extracted features and make final predictions.
Flattening the Input: The feature map output from the last pooling or convolution layer is
flattened into a 1D vector. As we predict 39 categories, the model output tensor of 1x39 size.
And from that tensor, we take an index of the maximum value in the tensor. That particular
index is our main prediction.

6. Normalize Layer
In our proposed system we use a batch normalize layer. Batch normalization layer form
normalizes any channel through a mini-batch. This can help to decrease sensitivity to data
variations. How It Works: Batch normalization normalizes the output of each layer by
adjusting the mean and variance within a mini-batch.
Specifically, for each feature in the mini-batch, the activations
are normalized to have a mean of 0 and a variance of 1. Then,
two learnable parameters, gamma (scale) and beta (shift), are
applied to maintain the flexibility of the model. Formula:
Given an input χ, batch normalization transforms it as:

12
PLANT DISEASE DETECTION USING ML

[Link] Layer
The network's performance can be difficult to interpret. It is normal to finish the CNN with a
SoftMax function in classification issues. After extracting values of 39 classes of plant diseases
in the fully connected step, a SoftMax will be made for them, so that the class will be selected
in each process and according to the features that were extracted through the previous layers
that the images of plant diseases went through it. In this layer, the correct class of disease is
determined by applying the SoftMax function.

Figure6: shows the VGG16 model architecture

D. Training
Training a network is a procedure of obtaining kernels in convolution layers and weights in
fully connected layers that reduce differences on a training dataset between output predictions
and specified ground truth labels. In our work, we used 85% of the data for training, 15% for
testing, 70% of the trained data were taken as validation data, through this stage so that the
network that has been built learns by extracting features from plant leaf disease images in order
to learn from these features for each image to be distinguished on its basis

E. Testing
The testing is a dataset utilized to provide an impartial final design fit evaluation on the training
set of data. In this stage, we use the groups that were trained in the previous step that was
trained in CNN, and the features were extracted by learning the network when the data set
passes from plant leaf diseases on this network, we used 15% of the data for testing.

13
PLANT DISEASE DETECTION USING ML

F. Detection for Plant Leaf Diseases and Remedies Prediction


After the previous operations, plant species diseases are detected and classified according to 39
classes types of plant diseases caused by three categories namely Biotic and Abiotic.
Biotic diseases: caused by the fungi, Bacteria, Viruses, Phytoplasmy, and Nematodes.
Abiotic diseases: caused by Nutrition, Moisture, Temperature and Toxic Chemicals
As shown in figure1
After detection and classification is done, the prediction of the remedies is done by the
application through the use of the APIs that fetch the suitable treatment for every class disease
and providing a brief description of the supplement and how it will be used. Also providing
guidelines for how to deal with the infected part and the suitable irrigation method for the plant
based on the status and the class of the disease.
The remedies information, the diseases description, and other supplements all were gathered
and placed in CSV files. While using ANN and KNN for this recommendation system or
choosing the right supplement and providing the diseases category accurately

Start

Input image

CNN
process

Disease name and


Remedies Prediction

End

Fig7: workflow of the app


methodology

14
PLANT DISEASE DETECTION USING ML

CHAPTER 4

4. Implementation
4.1. Requirement Analysis
4.1.1. Functional Requirement
• The system should provide an easy and efficient GUI to use.
• The system should be able to provide clear picture about the status of the leaf.
• If the leaf is found unhealthy i.e., diseased, the system should tell what type of
disease that the leaf is infected with.
• The system should also provide the remedies for the disease on which the plant
is infected.

4.1.2. Hardware Requirement


• Smart Phone
• Laptop or desktop with:
o Intel i5 or equivalent o
4GB RAM or more.

4.1.3. Software Requirement


• IDE: Jupyter Notebook
• Language: Python
• CNN

4.2. Code Snippets


Pre-Processing:

training_data = [] for img in

[Link](TRAIN_DIR):

label = label_img(img) path =

[Link](TRAIN_DIR,img) img =

[Link](path,cv2.IMREAD_COLOR) img =

[Link](img, (IMG_SIZE,IMG_SIZE))

training_data.append([[Link](img),[Link](label)])

shuffle(training_data)

15
PLANT DISEASE DETECTION USING ML

Building CNN Layers:

convnet = input_data(shape=[None, IMG_SIZE, IMG_SIZE, 3],


name='input')
convnet = conv_2d(convnet, 32, 3,
activation='relu')

convnet = max_pool_2d(convnet, 3)
convnet = conv_2d(convnet, 64, 3,
activation='relu')

convnet = max_pool_2d(convnet, 3)
convnet = conv_2d(convnet, 128, 3,
activation='relu')

convnet = max_pool_2d(convnet, 3)
convnet = conv_2d(convnet, 32, 3,
activation='relu')

convnet = max_pool_2d(convnet, 3)
convnet = conv_2d(convnet, 64, 3,
activation='relu')

convnet = max_pool_2d(convnet, 3)
convnet = fully_connected(convnet, 1024,
activation='relu')

convnet = dropout(convnet, 0.8)


convnet = fully_connected(convnet, 4,
activation='softmax')

convnet = regression(convnet, optimizer='adam',


learning_rate=LR, loss='categorical_crossentropy',
name='targets')

model = [Link](convnet, tensorboard_dir='log')

Training the model:


train = train_data[:-500] test

= train_data[-500:]

X = [Link]([i[0] for i in train]).reshape(-


1,IMG_SIZE,IMG_SIZE,3) Y

= [i[1] for i in train]

test_x = [Link]([i[0] for i in test]).reshape(-


1,IMG_SIZE,IMG_SIZE,3)
test_y = [i[1] for i in test]

16
PLANT DISEASE DETECTION USING ML

[Link]({'input': X}, {'targets': Y}, n_epoch=8,


validation_set=({'input': test_x}, {'targets': test_y}),
snapshot_step=40, show_metric=True, run_id=MODEL_NAME)
[Link](MODEL_NAME)

4.3. Test Cases


Test
Test Input Expected Results Actual Results Remark
Case ID

Should identify the Identified the leaf is


Select an image
image is diseased with infected with bacterial
1 with bacterial Pass
bacterial spot and spot and provided
spot
provide remedies remedies

Should identify the Identified the leaf is


Select an image
image is diseased with infected with yellow
2 with Yellow curl Pass
yellow curl leaf virus curl leaf virus and
leaf virus
and provide remedies provided remedies

Should identify the Identified the leaf is


Select an image
image is diseased with infected with late
3 with Late Blight Pass
light blight and provide blight disease and
disease
remedies provided remedies

Select a healthy Should identify the Identified the image


4 Pass
image image as healthy status as healthy

17
PLANT DISEASE DETECTION USING ML

CHAPTER 5
5.1. Results

Fig 5.1: Backend output (accuracy)

Fig 5.2: Frontend output (tkinter application)

18
PLANT DISEASE DETECTION USING ML

Fig 5.3: Detection of Yellow leaf curl virus

Fig 5.4: Remedies for Yellow leaf curl virus

19
PLANT DISEASE DETECTION USING ML

Fig 5.6: Detection of Bacterial spot

Fig 5.7: Remedies for Bacterial spot

20
PLANT DISEASE DETECTION USING ML

Fig 5.8: Detection of Late blight

Fig 5.9: Remedies for Late blight

21
PLANT DISEASE DETECTION USING ML

Fig 5.10: Detection of healthy leaf

5.2. Conclusion
To prevent losses, small farmers are dependent on a timely and accurate crop disease diagnosis.
In this study, Convolutional Neural Network will be used, and the model will be developed.
The final result will be a plant disease detection desktop application. This service is free, easy
to use. Thus, the user’s needs as defined in this paper have been fulfilled.
A thorough investigation exposes the capabilities and limitations of the model. The achieved
accuracy depends on a number of factors including the stage of disease, disease type,
background data and object composition. Due to this, a set of user guidelines would be required
for commercial use, to ensure the stated accuracy is delivered. As the model will be trained
using a plain background and singular leaf, imitation of these features is best.

5.2. Future work


Overall, we were able to understand how CNNs may be applied to empower small farmers in
their fight against plant disease. In the future, work will be focused on diversifying training
datasets for use in real life situations. Without such developments, the struggle against plant
disease will continue.

22
PLANT DISEASE DETECTION USING ML

References
[1] S. Arivazhagan, R. Newlin Shebiah, S. Ananthi, S. Vishnu Varthini, “Detection of
unhealthy region of plant leaves and classification of plant leaf diseases using texture
feature”, CIGR, 2013, vol.15, no.1, pp.211-217.
[2] Haiguang Wang, Guanlin Li, Zhanhong Ma, Xiaolong Li, “Image Recognition of Plant
Diseases Based on Backpropagation Networks”, 5th International Congress on Image and
Signal Processing (CISP 2012)

[3] Bhange, M., Hingoliwala, H.A., ‘Smart Farming: Pomegranate Disease Detection Using
Image Processing’, Second International Symposium on Computer Vision and the Internet,
Volume 58, pp. 280-288, 2015
[4] Pranali K. Kosamkar, [Link], Krushna Mantri, Shubham Rudrawar, Shubhan
Salmpuria, Nishant Gadekar, ‘Leaf Disease Detection and Recommendation of Pesticides
using Convolution Neural Network’, 2018 Fourth International Conference on Computing
Communication Control and Automation (ICCUBEA)

[5] Kaushik Kunal Singh, ‘An Artificial Intelligence and Cloud Based Collaborative Platform
for Plant Disease Identification, Tracking and Forecasting for Farmers’, 2018 IEEE
International Conference on Cloud Computing in Emerging Markets (CCEM)

[6] Suma V, R Amog Shetty, Rishab F Tated, Sunku Rohan, Triveni S Pujar, ‘CNN based Leaf
Disease Identification and Remedy Recommendation System’, Third International
Conference on Electronics Communication and Aerospace Technology [ICECA 2019]

[7] Marwan Adnan Jasim, Jamal Mustafa AL-Tuwaijari, “Plant Leaf Diseases Detection and
Classification Using Image Processing and Deep Learning Techniques”, 2020 International
Conference on Computer Science and Software Engineering (CSASE), Duhok, Kurdistan
Region - Iraq

23

You might also like