Plant Leaf Disease Detection Using CNN Report
Plant Leaf Disease Detection Using CNN Report
CERTIFICATE
This is to certify that the project entitled, Plant Disease Recognition based on
Leaf Image Classification using CNN submitted by Mr. Tadikonda Venkata
Sai Ravi Teja, Reg No:178297601023, University College of Engineering,
Adikavi Nannaya University, Rajamahendravaram, Andhra Pradesh, India is
record of the bonafide Project work carried out by his under my supervision and
guidance and is worthy of my consideration for the award of the degree of
Bachelor of Technology in Computer Science and Engineering.
________________ ____________________
INTERNAL GUIDE HEAD OF THE DEPARTMENT
_______________________
EXTERNAL EXAMINER
ADIKAVI NANNAYA UNIVERSITY
RAJAMAHENDRAVARAM
I certify that,
The work contained in this report is original and has been done by me under the
guidance of my supervisor. The work has not been submitted to any other Institute
for any degree or diploma. I have followed the guidelines provided by the
university in preparing the report. I have conformed to the norms and guidelines
given in the Ethical Code of Conduct of the Institute. Whenever I have used
materials (data, theoretical analysis, figures, and text) from other sources, I have
given due credit to them by citing them in the text of the report and giving their
details in the references. Further, I have taken permission from the copyright
owners of the sources, whenever necessary.
Signature of Student
ACKNOWLEDGEMENT
I feel fortunate to pursue my Bachelor of Technology degree in Computer Science
and Engineering on the campus of Adikavi Nannaya University,
Rajamahendravaram, Andhra Pradesh, India. It provided all the facilities in the
areas of Computer Science and Engineering.
A great deal of thanks goes to Review Committee Members and the entire
Faculty of University College of Engineering, Adikavi Nannaya University,
Rajamahendravaram for their excellent supervision and valuable suggestions.
I also would like to thank Dr H Ravi Shankar Sir, Senior Principal Scientist,
C.T.R.I for entrusting me with the opportunity to work in this project.
I am always thankful to my family, friends, and well-wishers for all their trust and
constant support in the successful completion of my project.
1 Abstract 1
2 Introduction 2
3 Literature Survey 3
5 Requirements
i. Hardware Requirements 5
ii. Software Requirements
iii. Functional Requirements
iv. Non-Functional Requirements
6 Architecture 7
7 Design 8
i. Functional Design
ii. System Design (UML Diagrams)
8 Implementation 15
i. Concepts
ii. Platforms and Tools
iii. Sample Code
9 Testing 31
10 Output 33
11 Conclusion 34
12 Bibliography 35
LIST OF FIGURES
Abbreviation Description
NN Neural Network
This project is based on developing a mobile application for the farmers, which
helps them to detect the disease using Computer Vision with in less time.
Using this mobile based application, farmer can capture the image of the disease
on the leaf and search for the result. The algorithm will classify the disease and predict
the damage on scale and also the remedies that are to be taken as a precautionary
measure.
INTRODUCTION
Agriculture is considered as driving sector of a nation’s economy. One of the
unsolved problems in Agriculture is, Detection of Type of disease for a crop during
the right time.
This tool works after it gets trained by the images, of disease that already
occurred at some point of time. Based on those data, the tool extracts the features of
the diseases (like brown spots, weakened stems, folded leaf’s, insets, etc) from the
images. Stores those features. In future when the farmer uses that tool, if the data of
that disease is already trained, then it easily identifies the disease with in a second.
We can also get the remedy from further spread of the disease and detect the disease
at it initial state itself. In case if it is a new disease then it will be a professional work.
The Tool is a mobile application. There are many ways to classify the image,
but one of them, the most popular way is by using CNN (Convolutional Neural
Network) a Deep Learning concept, which is used mostly for image classification and
Object Detection. In order to make the task faster we are using the concept of Transfer
Learning. This reduces the cost of building and training the algorithm, and we will
get a more accurate result, than by using traditional CNN.
D. Tiwari, Adem Tuncer used transfer learning and various pre-trained model
on the potato leaves image dataset and concluded that VGG 19 gave the optimal
accuracy of 97.8% compared to 92% accuracy of back propagation neural network
and 95% accuracy of support vector machine
Also, there are agricultural institutes which are available to the farmers at all
time. Scientists will visit the fields and take the samples of the diseased plants for
testing. The results will take some time, but during this time some damage might
already might be done. And when it comes to a new type of disease, the damage might
be even worse. There are also case that all the villages may have the facility of Local
administration offices, to report the information to the nearest institute. Thus, the
problem cannot be identified
Apart from traditional methods there are also advanced methods that are
already implemented. Machine Learning approaches include traditional computer
vision algorithms like haar, hog, sift, surf, image segmentation, Support Vector
Machines (SVM), using K-Nearest Neighbours (KNN), K-means and Artificial
Neural Networks (ANN). . Deep Learning based plant disease classification models
includes the use of a variety of CNN models such as AlexNet, GoogleNet, VGGNet
etc. It seems that sometime the availability of datasets for some crops may not be
available and sometime the available dataset may not be sufficient.
PROPOSED SYSTEM
In this project I have used the Concept of Transfer Learning for image
classification. The main advantage in using transfer learning is that instead of starting
the learning process from scratch, the model starts from patterns that have been
learned when solving a different problem which is similar in nature to the one being
solved. This way the model leverages previous learnings and avoids starting from
scratch. In image classification, transfer learning is usually expressed through the use
of pre-trained models. A pre-trained model is a model that was trained on a large
benchmark dataset to solve a similar problem to the one that we want to solve.
a) Data Acquisition:
The Dataset used in building this model is Tobacco Dataset which is gathered by
C.T.R.I organization as a part of Research. The Dataset is a Collection of images,
which are classified into their respective Diseases.
b) Data Pre-Processing:
In Data Pre-Processing, the data set has to be prepared to be feed to the model
taken. In order to get more accurate results, the dataset has to be first divided into
3 different categories Train Dataset, Validation Dataset, Test Dataset. Each of
these categories has its own importance the Train dataset will get the maximum
share of the images, as train set is used for training the model selected. Validation
set is used for verifying the trained model whether the model is accurate or not
and we can know the accuracy while training for each Epoch. Hence validation
set plays a major role. The Accuracy denotes the efficiency power of the model
built. The best possible range between 85- 98%.
The Test set is used to validate the final obtained model, the image set in Test is
passed to model, for checking the output is right or not. Hence stating that how
well the model can perform for real time images. Best Practise is to give different
images to each of these sets, to avoid overfitting of the model.
d) Model Building:
This Phase is considered as the most important phase of the entire System.
Here we are implementing the concept of transfer learning. i.e., we make use of
the predefined models that are already existing and by modifying those models by
changing the top most layer with our required output classes.
The weights of the models which connects the nodes are not changed. Only the
top most layer (output) layer is fitted.
The selection of the model also play’s a vital role in defining the accuracy of the
system. Each model has its own set of parameters, image size etc.
Few examples of these Keras Application models Resnet, Inception series,
MobileNet, VGG, DenseNet etc.
These models have different built time, accuracy and also the classification time
based on their weights. Hence out of these models considering the accuracy, I
used Inception V3 Model, for the construction of the system.
Its supported image size is 224, 224 via 3 channels. The model was trained for 20
Epochs, and the accuracy is around 96.1 %.
f) Classification:
This phase includes the User. The user using the mobile application either takes
a snap of Leaf to check whether the crop is infected or not, else he can also select
the image from his device. As the mobile application is built on Flutter platform,
its much easy to import the Model that was built.
While building the application the model was fitted into it, hence after the user
launches the mobile application, and passes the image, the features of the image
are extracted and compared to the model output. When it matches with the correct
vector, it gives the respective class as the result. When the features are not
matched with any of the vectors, it will not show any result, stating that the image
is not valid.
Since UML is not a methodology, it does not require any formal work
products. Yet it does provide several types of diagrams that, when used within a given
Tadikonda Venkata Sai Ravi Teja
178297601023, B.Tech (CSE) 10
Plant Disease Detection using CNN
methodology, increase the ease of understanding an application under development.
There is more to UML than these diagrams, but for my purposes here, the diagrams
offer a good introduction to the language and the principles behind its use. By placing
standard UML diagrams in your methodology's work products, you make it easier for
UML-proficient people to join your project and quickly become productive.
UML system is represented using five different views that describe the system
from a distinctly different perspective. Each view is defined by a set of diagrams
which is as follows.
UML Diagrams
Use Case Diagram
Use Case diagrams identify the functionality provided by the system (use
cases), the users who interact with the system (actors), and the association
between the users and the functionality. Use Cases are used in the Analysis phase
of software development to articulate the high-level requirements of the system.
The primary goals of the Use Case diagrams include:
1. Providing a high-level view of what the system does.
2. Identifying the users ("actors") of the system.
3. Determining areas needing human-computer interfaces.
Class Diagram
Class Diagram is collections of class of the system and the relations between
them.
Classes consists of Attributes, and Operations. These attributes and operations are
used with their access Specifiers with Public (+), Protected (#), Private (-).
Sequence Diagram
Sequence Diagram Sequence diagrams document the interactions between classes
to achieve a result, such as a use case. Because UML is designed for object-
oriented programming, these communications between classes are known as
messages. The Sequence diagram lists objects horizontally, and time vertically,
and models these messages over time.
Sequence Diagram
A sequence diagram is an interaction diagram that emphasizes the time
ordering of messages. A sequence diagram shows a set of objects and the
messages sent and received by those objects. The objects are typically named or
anonymous instances of classes, but may also represent instances of other things,
such as collaborations, components, and node.
8.1 Concepts : -
Neural Network
The computing systems inspired by biological neural networks to perform
different tasks with a huge amount of data involved is called artificial neural
networks or ANN. Different algorithms are used to understand the relationships
in a given set of data to produce the best results from the changing inputs. The
network is trained to produce the desired outputs, and different models are used
to predict the future results with the data. The nodes are interconnected so that it
works like a human brain. Different correlations and hidden patterns in raw data
are used to cluster and classify the data
3. Recurrent network
In this, there are one or more hidden layers except for the input and output layers.
The nodes of this layer are called hidden neurons or hidden units. The role of the
hidden layer is to intervene between the output and the external input. The input
layer nodes supply the input signal to the second layer’s nodes, i.e. the hidden layer,
and the output of the hidden layer acts as an input for the next layer, which
continues for the rest of the network
3. Recurrent Networks
Introduction
CNNs are powerful image processing, artificial intelligence (AI) that use deep
learning to perform both generative and descriptive tasks, often using machine
vison that includes image and video recognition, along with recommender systems
and natural language processing (NLP).
The layers of neurons are arranged in such a way as to cover the entire visual field
avoiding the piecemeal image processing problem of traditional neural networks.
A CNN uses a system much like a multilayer perceptron that has been designed for
reduced processing requirements. The layers of a CNN consist of an input layer, an
output layer and a hidden layer that includes multiple convolutional layers, pooling
layers, fully connected layers and normalization layers. The removal of limitations
and increase in efficiency for image processing results in a system that is far more
effective, simpler to trains limited for image processing and natural language
processing.
Introduction
Currently, the most famous deep learning library in the world is Google's
TensorFlow. Google product uses machine learning in all of its products to improve
the search engine, translation, image captioning or recommendations
Introduction
Transfer learning is a machine learning method where a model developed for a task
is reused as the starting point for a model on a second task.
Transfer learning only works in deep learning if the model features learned from the
first task are general.
This form of transfer learning used in deep learning is called inductive transfer. This
is where the scope of possible models (model bias) is narrowed in a beneficial way
by using a model fit on a different but related task.
You can use transfer learning on your own predictive modelling problems.
In an Inception v3 model, several techniques for optimizing the network have been
put suggested to loosen the constraints for easier model adaptation. The techniques
include factorized convolutions, regularization, dimension reduction, and
parallelized computations.
Architecture
The architecture of an Inception v3 network is progressively built, step-by-step, as
explained below : All the above concepts are consolidated into the final architecture
1. Factorized Convolutions
2. Smaller convolutions
3. Asymmetric Convolutions
4. Auxiliary classifier
5. Grid size reduction
Tadikonda Venkata Sai Ravi Teja
178297601023, B.Tech (CSE) 21
Plant Disease Detection using CNN
8.2 Platforms and Tools
Flutter
Introduction
In a few words, it allows you to create a native mobile application with only one
codebase. This means that you can use one programming language and one codebase
to create two different apps (for iOS and Android).
To develop with Flutter, you will use a programming language called Dart.
An SDK (Software Development Kit): A collection of tools that are going to help
you develop your applications. This includes tools to compile your code into native
machine code (code for iOS and Android).
Introduction
Colab is a free Jupyter notebook environment that runs entirely in the cloud. Most
importantly, it does not require a setup and the notebooks that you create can be
simultaneously edited by your team members - just the way you edit documents in
Google Docs. Colab supports many popular machine learning libraries which can be
easily loaded in your notebook.
• Create/Upload/Share notebooks
Colab provides GPU service hence the only requirement would be stable broadband
connection. It follows pay as you go method hence for high level projects payment
may be required. But it is open for small and medium level projects.
#model construction
#Loading Dataset
IMAGE_SIZE = [224, 224]
train_path = ' /content/drive/MyDrive/4th year project tobacco2/tb_data/train
valid_path = '/content/drive/MyDrive/4th year project tobacco2/tb_data/val'
#Building the model
layer.trainable = False
x = Flatten()(inception.output)
model.summary()
#Data Argumentation
training_set = train_datagen.flow_from_directory(
model.compile(loss='categorical_crossentropy', optimizer='adam',
metrics=['accuracy'])
steps_per_epoch=len(training_set), validation_steps=len(test_set) )
tflite_model = converter.convert()
#HomePage.dart
• Loading the model and image parameters
• HomePage UI
Depending on the dataset set and the weights of the each model the accuracy may
vary for different models.
OUTPUT
Still the concept of medication and details about those disease are yet to be
included. Also by the availability of a large dataset, and more number of classes we
can built a more efficient model, hence we can know the ability of model working
and its accuracy. In future, by using more efficient pre-model we can achieve much
better accuracy. Even though this project already implemented by traditional Neural
Networks, using Transfer Learning concepts, the accuracy of the result may increase
and being a precompiled model, the weights are predefined hence the time taken to
build the model will decrease.
An accurate and efficient image classification system has been developed which
achieves comparable result with the existing state-of-art system. The project uses
recent techniques in the field of computer vision and neural networks.
This application is very useful for the farmers to detect the disease within no time,
such that the prevention of the disease from a wide spread can be stopped.
BIBLIOGRAPHY