You are on page 1of 12

Plant Disease Detection using CNN

Abstract: ​These days crops are being affected by various types of bacteria and fungi which
leads to huge menace to food patronage. It is very difficult to identify these diseases, because
of the paucity of the basic infrastructure. As the smartphones are emerging and improvement
in computer-mission enabled that neural network has suggested for wireless-based disease
diagnosis. Using a dataset that includes different types of ailing and healthy plant leaflet
images, we train a Deep Neural Network (C-NN) to diagnose different types of crop diseases.
The model we created achieves a good accuracy as shown in the result page. This approach
creates a path for wireless-based crop analysis on a gigantic scale.

Keywords ​- Convolution neural network,​ deep learning, plant diseases detection.

INTRODUCTION sustainable development are to scale back


the usage of pesticides, cost to save lots of
India is eminent for Agriculture meaning
the environment and to extend the standard.
most of the people are engaged towards the
Precise and early diagnosis may reduce the
agriculture industry. The agriculture
usage of insecticides pesticides.
industry acts as a big role within the
economic sectors. Most of the plants are Plant disease can be defined as anything that
infected by various fungal and bacterial causes unhealthy to the plant. There are
diseases. Thanks to the exponential different reasons for that, which includes
inclination of the population, the climate poor nitrogen, air pollution, bacteria, fungus,
also causes disease. The main challenges of virus, etc. This damage leads to poor growth
of plants and loss of productivity. This will be a solution to every problem, the same
also cause major loss in the economy in way we have a solution to this problem,
terms of agriculture worldwide. Early deep learning helps us to come out of this
detection can help us to take necessary problem, which is used to detect the type of
actions or remedies which can help to raise disease.
the productivity as well as economic in
Nowadays, technology is widely used for
agriculture.
disease prediction. Plant diseases aren't only
Due to this damage, crucial agricultural a risk to food haven worldwide, it can also
plants are being threatened by different have catastrophic aftermath for small-scale
types of diseases and pests. As this damage farmers whose source of revenue rests on
can reduce the food yield and its quality we crop yield. Within the emerging world,
can say that it is a major threat to food almost eighty per cent of the agricultural
security which in turn leads to illness of a product is generated by small-scale farmers,
man. This disease has the capability to lower and reports of produce loss of fifty per cent.
the vegetable and fruit quality. About Furthermore, the most important fraction of
Forty-Two percent of the crops in the world hungry people sleep in small-scale farming
are destroyed yearly due to the damage of communities, making them a gaggle which
the crops. Therefore to reduce this damage, is particularly liable to pathogen-derived
a good and accurate diagnosis is needed. interruptions in the food supply.

The main support of human existence on Whenever the disease is identified correctly
earth is with the help of food and the plants. on its earliest appearance could be an
Plants which produce good quality food are important step for effective disease control.
prone to a variety of diseases because of This process is supported by many
external conditions of the environment. Due organisations. Furthermore, due to
to this, there is a huge loss in agriculture. advancement in technology this plant
Therefore early detection and necessary diagnosis can be done online by providing
remedies are to be taken to save our valuable the required information.
time and money. In the way that there will
The current process for identifying diseases completed on these images and group them
is observation through the naked eye by into an array. Then it's divided into testing
experts. For this process, they should and training. Then it's fed to our C-NN
continuously monitor the plants which can model and accuracy is noted.
be expensive. At an equivalent time in a few
In this project, we propose a unique deep
countries, they don't have suitable services,
learning architecture that uses a
maybe they will contact experts, but
Convolutional Neural Network (C-NN).
consulting them can be laborious and
These algorithms take images as input and
expensive in most cases. In these cases, the
convolve it with predefined filters as a part
most favourable technique for farming
of the process. A BXB sized image is taken
community is to opt for automatic detection
and it is convolved with a kernel of a certain
for plant diseases which operates just by
size. This process helps the model to learn a
observing the leaf of a diseased plant and it's
feature of the image and these features after
a non-expensive process
each operation are learnt by a respective
Plant disease detection by observing is a feature map. These maps can help us in
strenuous task as well as it is not accurate understanding the image and work with
enough. If the above-recommended weights.
technique is employed, it will take time to
CNN can be contained in different
detect the disease in a visual way. Most
convolution layers in which sets of different
common disease symptoms that can be seen
filters are used to identify the required
in plants mostly occur on a leaf which could
pattern counting with other layers like
resemble coloured spots which can be a sign
pooling. In classification of image, patterns
of fungal or bacterial infection
are squeezed through convolution and the
In this report, we present an efficient and different layers which are present in the
effective method for disease detection. The model repetitively to get the outputs
workflow of disease detection is described respectively. So therefore to train a model, a
as follows. First, images are located in the dataset is given for training as input to the
directory and therefore the pre-processing is model along with that, the weights and
kernel parameters are given to extract the applied not only in the agriculture domain,
patterns in the hidden layers to solve the but also in various domains which is
problem. If an error is occurred at the output successful. So therefore we apply this
side, then by using a technique called back technique for leaf disease detection
propagation is used to reduce the classified automatically. This detection in the early
error. In this model we have visualized the stage could be beneficial in terms of
layers present, to identify the behaviour of economic and production.
the method design for plant disease
diagnosis.

SYSTEM ANALYSIS
The images we have used in this model were
taken from the internet sources. The dataset Existing System
contains both types of ailing and healthy
Outbreak of plant diseases can lead to death
plant leaflet images which are of fifteen
and famine. The result of famine in 1943
thousand images with fifteen different types
which was caused by helminthosporium
of crop diseases. The images were rifted into
caused a heavy loss of crop yield and deaths
training and testing data-sets that comprises
in North India. These losses are caused by
the ratio of 7:3. The image size we have
not taking preventive steps to protect the
taken in this model is 256 X 256 which are
crop-yield by identifying the disease and
used to feed into our model. This is highly
treating them.
recommended architecture as there are
repeating convolution sections such that it Continuous monitoring of experts is needed
makes it difficult to interpret by the other which is the main default method for
layers in the model. identifying crop diseases. This is an
expensive method for both small scale and
In the recent study, it has been said that deep
large scale farmers. Furthermore, in
learning which is a front line for image
developing third world countries, there is a
based processing gives us accurate or
shortage of experts and consulting them
meticulous results and huge potential in
agriculture areas. This modern technique is
could be expensive and time consuming for training and remaining thirty percent for
them. testing. These images are generally
appearing in the form of a matrix holding
the values of the cells in the form of
Proposed System neurons. These neurons are fed as an input
to the layers of the network. The
There are a number of strategies currently
construction of the CNN model is done for
used to utilize computer-based systems of
further analysis. Now, the model is tested
plants derived from images to specific
for implementation. If the model is accurate,
classifier systems as input parameters.
then the data is satisfied with the network or
In this proposed system the images are else the model is modified for achieving
collected. These images are given as input to better construction.
our proposed classifier and it displays the
disease it has affected with. To make this
possible we have created a model using
Convolutional Neural Network. This can be
useful to both small scale and large scale
farmers as this could be more accurate and
less time consuming. Moreover it could be
helpful to poor farmers as it could be less
expensive​.

SYSTEM DESIGN
System Architecture

The diagram below shows how the


prediction mechanism occurs in the model.
At first the dataset is pre-processed, after
that it is converted to an array. From the
dataset, seventy percent of data is used for
Fig. Process flow of complete project.
General explanation :​
1.The input test image is acquired and
preprocessed in the next stage and then it is
converted into array form for comparison.
2.The selected dataset is properly segregated
and preprocessed.
3.The model is trained using CNN and then
classification takes place.
4.The comparison of the test image and
therefore the trained model happen followed
by the display of the result.

Fig. Use case diagram


UML DIAGRAMS
One of the basic methods to show how a
Use Case Diagrams
system works is to use a UML diagram.
It defines and develops a Single Modeling From the above diagram, the user interacts
Language (UML) via the user case study. with the system by uploading an image, after
The connection between actors, their pre-processing an image, the predicted
objectives and their dependencies is output will be displayed.
supplied by the functionality of the system.
State Chart Diagram
The functionality of the individual actors
will be demonstrated. The roles of the actor State charts are used in “computer” science
are performed throughout the process. and other related fields. State diagrams
allow a finite number of states to make up
the structure described often in this case,
sometimes these are logical abstractions.
There are several types of state diagrams
that are slightly different from different ReLu, convolution_layer, normalization
logical expressions. layer and dropout Layers. In Recognition, an
image is taken as an input as well as label
name conversely class name would be the
output.

Input Layer

In the input layer of C-NN an image is given


as input. Deep learning models need
enormous image data for training them. The
number of channels is equal to the size of
the image. For example if the number of
channels are three then it is a colour image
and for gray-scale image it is one. The size
of the dataset can be increased by data
augmentation techniques, these techniques
are done on image before these are fed into
the model. These augmentation techniques
include transposing, zoom, cropping and
rotate operations whereas conserving the
Fig. State chart diagram label of the image

Convolutional Layer

ARCHITECTURE OF DEEP This is the first layer of C-NN and images


are taken as input. The major operation of
CONVOLUTIONAL this layer is to convolute the images. With
the help of filters the image is convoluted
NEURAL NETWORK and produces the feature maps. The output
of this layer can be written as
A C-NN is identical to a neural network; it
encompasses input as well as output layers
in inclusion to this a few middling hidden
layers are also present among them. These
hidden layers encompass a pooling layer,
ReLU Layer scaled by an element gamma. The equation
for output of this layer is
This Layer is also known as the activation
layer, Relu is used to induce non-linearity to
the system.It is also used for neutralizing
negative activation values. ReLu is
initialised after every convolution. In case of
multiclass classification ReLu can be used
but for binary classification sigmoid
function should be used Fully Connected Layer

It implies, these are the layers that each and


every node is connected to the next node in
the coefficients. These coefficients support
each and every node in the pooling data. The
multiple sets of output from the pooling
layer is connected to F-CL. The job of FCL
is to collectively draw the top best cases for
the object or an image. At the end of this
layer it follows different techniques which
Max-Pooling Layer includes S-VM, soft-max for the probability
distribution to pick the top best solution. Its
In Max pooling, the image is down-sized for equation is
output. No learning is done in this layer. The
output from Conv layers is a feature map,
after pooling this map is of reduced size and
conserving its features in the output based
on filter and strides defined. This layer can
help us avoid overfitting.

IMPLEMENTATION
Batch Normalization Layer

In this layer we can find activation of each Preprocessing


channel by subtracting and dividing
mini-batch mean and standard deviation. Pre-processing the dataset will improve the
This layer comes before the ReLu layer. The
accuracy and performance. We perform
input is shifted by a beta offset and then it is
pre-processing techniques on our image After creating our CNN model we will be
dataset by resizing or reshaping them. After optimizing it using Adam optimizer from
that, we check for a .DS_Store file which Keras library and the loss function is cross
holds the attributes /metadata information. If entropy.
it is present is removed and then the images
Then the training is commenced by calling a
are converted into an array. This process is
model.fit_generator to which image data
done on the whole dataset which includes
generator is supplied and trained. C-NN has
test and train data. The dataset consists of
different layers like Activation, Flatten,
almost 15000 images of different diseased
Convolution_2D and Max_Pooling_2D.
and healthy plants. The training data is
After the completion of training, the model
employed to train the model so that it can
can detect disease among plant species.
classify the required test-set.
After Training and pre-processing,
comparison of the trained model and test
image takes place to predict the disease.
Training

After Pre-processing the images we will be


converting them into array using a function. Testing
Using label_binarizer from scikit-learn
library we will convert each image label to
binary levels and this instance is saved using
pickle. Then we further pre-process the data
by scaling the data points from [0, 255].
After that we will be splitting our data into
test/train sets using 80 percent of images for
training purposes and rest for testing. An
image data generator object is initialised After training the classifier we test its

which performs random shifts, rotations, knowledge on the test set which we created

crops and flips on our image dataset. earlier and accuracy is calculated
After testing the model we save it with the ● After this the dataset is
help of a library called pickle. Then the divided into test and training
model is saved in GDrive. To test the model set based on requirement.
we trained we will be uploading an image ● After pre-processing, the next
belonging to a certain plant which is move is to encode the labels
affected by the disease. After uploading the with LabelEncoder and
file in drive we will be accessing it using its thereby dividing the dataset
file path and then pre-process and predict into two groups, train and test
the class it belongs using predict_class sets. Additionally we will be
function and print the result. transforming input features to
Tensors for both numeric and
categorical variables and
RESULT column features are
described.
In this project we have designed a program
using CNN. The programming language
being used is python. Its packages which are
We have trained our model and saved it
being here are numpy, sklearn, matplotlib,
before exploring results. Let's have a glance
keras, scikit-learn. The following are the
at the summary of our model. The summary
steps to be taken in
of our model’s Architecture is
order to achieve experimental results.

● The initial step is to import


the necessary libraries and
read the data from the file to
the dataset.
● Pre-processing the dataset
and encoding it so that the
machine can understand and
easily parse it.
exploring results. The testing accuracy
resulted is ​97.00118​%.

For testing we use a separate image


which has to be pre-processed, hence for
testing any image can be used as a test
image. If any disease is identified in the
image, the label will be shown and the
aim of the project will be achieved.
CONCLUSION
Among image-classification methods,
C-NNs beat outdated image-processing
This project aims to implement an inventive
methods. This is also observed in the idea to determine the damaged crops. By
automatic detection of PlantDiseases. ​We using the above-mentioned technology, the
images are given as input to it or technology
have trained our model and saved it before
for the recognition of diseases. This model is
very helpful for the agriculture community,
especially in remote villages. As India is a
developing country, this technology can help and what possible solutions are automatic
in many ways. This system helps in terms of once the disease is identified.
reducing the time to detect diseases. This
technology helps us for fast identification of
the disease and take necessary actions or
remedies for good productivity in agriculture.
As further the project can be developed or
implemented by using multimedia REFERENCES
(Audio/Video) to tell what type of disease is
[1] Detection and Classification of Plant [4] Plant Disease Detection and
Leaf Diseases by using a Deep Learning Classification by Deep Learning PMCID:
Algorithm. ISSN: 2278-0181. PMC6918394 PMID: 31683734

[2] How Convolutional Neural Networks [5] Plant Disease Detection and its Solution
Diagnose Plant Disease. ​Volume: 2019, using Image Classification. Volume 119 No.
Article ID: 9237136, DOI: 14 2018, 879-884 ISSN: 1314-3395
10.34133/2019/9237136​.
[6] Plant Leaf Recognition Using a
[3] Detection of Plant Disease by Leaf Convolution Neural Network March 2017
Image Using Convolution Neural Networks DOI: 10.5391/IJFIS.2017.17.1.26
978-1-5386-9353-7/19/ ©2019 IEEE

You might also like