100% found this document useful (2 votes)
2K views

Plant Leaf Disease Detection Using CNN Report

Project Report based on Plant Leaf Disease Detection Using CNN

Uploaded by

ravi teja
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 (2 votes)
2K views

Plant Leaf Disease Detection Using CNN Report

Project Report based on Plant Leaf Disease Detection Using CNN

Uploaded by

ravi teja
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
You are on page 1/ 43

Plant Disease Recognition based on Leaf

Image Classification using CNN


A Project Report submitted in the partial fulfilment
of the requirements for the award of degree of

Bachelor of Technology in Computer Science and Engineering


Submitted by
Tadikonda Venkata Sai Ravi Teja
Reg. No. 178297601023
Under the esteemed guidance of
Dr. M Kamala Kumari, Associate Professor

Department of Computer Science and Engineering


University College of Engineering
Adikavi Nannaya University
Rajamahendravaram
2017 - 2021

Under the esteemed guidance of

Dr.H.Ravi Sankar, Senior Principal Scientist, C.T.R.I


Agricultural Knowledge Management Unit, I.C.A.R
ADIKAVI NANNAYA UNIVERSITY
RAJAMAHENDRAVARAM

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.

It's a genuine pleasure to express my deep sense of thanks and gratitude to my


mentor and project guide Dr. M Kamala Kumari, Associate Professor,
Department of Computer Science and Engineering for her excellent guidance
right from the selection of the project and her valuable suggestions throughout the
project work. Her constant and timely counsel has been the cause for me to
succeed, in completing this thesis in the college. She has given me tremendous
support in the technical front.

I profusely thank Dr. V Persis, Principal, University College of Engineering for


all the encouragement and support,

I also thank Dr. P Venkateswara Rao, Head of the Department, Department


of Computer Science and Engineering for the guidance throughout the
academic.

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.

TADIKONDA VENKATA SAI RAVI TEJA


178297601023
INDEX
S.NO Contents Page No

1 Abstract 1

2 Introduction 2

3 Literature Survey 3

4 Existing System and Proposed System 4

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

Fig No. Description Page No

6.1 System Architecture 7

7.2.1 Use Case Diagram for Developer 12


7.2.2 Use Case Diagram for User 13
7.2.3 Sequence Diagram for Developer 13
7.2.4 Class Diagram for User 14
8.1.1 Neural Network 15
8.1.2 Single Layer Neural Network 16
8.1.3 Example of Multi Layered Neural 17
Network
8.1.4 Recurrent Neural Network 17

8.1.5 Implementation of CNN 18


8.1.6 Using TensorFlow in CNN Application 19
8.1.7 Inductive Learning & Inductive 20
Transfer
8.1.8 Architecture of Inception V3 21
8.2.1 About Flutter 22
8.3.1 Generated Model 25
8.3.2 Training the model 26
8.3.3,8.3.4 Loss and Accuracy 27
9.1 Error rate of DifferentPre-defined 31
Models
9.2,9.3,9.4 Inception V3 Acc, Resnet50 Acc, 32
VGG16 Acc
10.1 Home overview 33
10.2 Option Popup 33
10.3 Selection of Image 33
10.4 Result 33
ABBRIVATION TABLE

Abbreviation Description

NN Neural Network

CNN Convolutional Neural Network

JDK Java Development Kit

SDK Software Development Kit

VGG Visual Geometry Group

UML Unified Modelling Language


Plant Disease Recognition based on Leaf
Image Classification using CNN
Plant Disease Detection using CNN
Chapter 1
ABSTRACT

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.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 1
Plant Disease Detection using CNN
Chapter 2

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.

In Traditional method, Farmers by their experience, or through the knowledge


of other or by any other Media, they may come to know about the Diseases that
occurred. From past few decades, Government is establishing Farmer and Crop
Welfare centres in large scale such that farmers with any of their queries, can visit
the centre and clarify them. When there is any outbreak of a disease, professionals
from those centres visit the field, take some sample, conduct some research and
declare the result and remedies.

Though it is an effective process, sometimes the results of the tested samples


aren’t quick enough. By the time enough damage might have been done. Hence to
solve this problem, a tool can be developed that uses computer vision, that can
classify the image based on the disease.

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.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 2
Plant Disease Detection using CNN
Chapter 3
LITERATURE SURVEY
Detecting diseases in plants in early stages is one of the major concerns in
Agriculture field. So, there are many researchers who are already working on the
issue of detecting plant diseases and diagnosing them some of the results of the
research done in detecting plant diseases are as follows…

Sk Mahmudul Hassan, Arnab Kumar Maji used, deep convolutional-


neural-network (CNN) models for identifying and diagnosing diseases in plants from
their leaves. Standard CNN models require a large number of parameters and higher
computation cost. Standard convolutions are replaced by depth separable
convolution, which reduces the parameter number and computation cost. The
implemented models achieved a disease-classification accuracy rates of 98.42%,
99.11%, 97.02%, and 99.56% using InceptionV3, InceptionResNetV2,
MobileNetV2, and EfficientNetB0, respectively, which were greater than that of
traditional handcrafted-feature-based approaches.

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

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 3
Plant Disease Detection using CNN
Chapter 4
EXISTING SYSTEM
In most of the areas Farmers use traditional methods, like sorting out
the disease from their past experience, or getting information from the internet. These
methods may not always lead to perfect result.

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.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 4
Plant Disease Detection using CNN
Chapter 5
REQUIREMENTS

These requirements are classified into various sections.

5.1 Hardware Requirements: -


➢ RAM: - 8GB or above (higher recommended)
➢ Hard disk: - 512 GB or above
➢ Processor: - i5 or above
➢ GPU:- Nvidia preferred

5.2 Software Requirements: -


➢ Operating System: - Windows
➢ Work station: - Google Colab/ Anaconda
➢ Editor: - Vs Code
➢ Front end: - Android Studio, Flutter, Java
➢ Language: - Dart, Python
➢ Data Set: - Tobacco Disease Dataset

5.3 Functional Requirements: -


The functional requirements for a system describe what the system should do.
Those requirements depend on the type of software being developed, the expected
users of the software. These are statement of services the system should provide, how
the system should react to particular inputs and how the system should behave in
particular situation.
 This model is used to predict whether the Leaf which is given as input
has a disease or not, if its having a disease, it will classify which type
of disease it is.
 The dataset which is taken as a Input, consists of all the images,
separated with respective disease. On the whole the set of diseases are
separated as train, test, and validation datasets to get a better output.
Tadikonda Venkata Sai Ravi Teja
178297601023, B.Tech (CSE) 5
Plant Disease Detection using CNN
5.4 Non-Functional Requirements: -
Non-functional requirements are requirements that are not directly
concerned with the specified function delivered by the system. They may
relate to emergent system properties such as reliability, response time and store
occupancy.

 Accuracy: The model uses machine learning algorithms, artificial


neural network for providing accurate results based on input data

 Performance: The model provides better performance for a given


input data when all the attributes that define the heart condition of a
person are specified.

 Ease of Use: The system is user friendly and simple interface


implemented so any can use this system without any difficulties.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 6
Plant Disease Detection using CNN
Chapter 6
ARCHITECTURE

System architecture is a conceptual model that defines the structure,


behaviour, and more views of a system. An architecture description is a formal
description and representation of a system, organized in a way that supports reasoning
about the structure and behaviour of the system. A representation of a system,
including a mapping of functionally onto hardware and software components, a
mapping of the software architecture onto the hardware architecture, and human
interaction with these components.

Fig: 6.1 System Architecture

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 7
Plant Disease Detection using CNN
Chapter 7
DESIGN

7.1 Phases of Leaf Disease Detection: -


Plant Disease Recognition based on Leaf Image Classification is trained model
which is built using Convolutional neural network which is a deep learning approach
works by taking an image as an input and then classifying it with the respective class.
The System includes Training and Testing Phase along with Data Acquisition, Data
Pre-processing, Data Argumentation, Model Building, and Classification.

Phases of Leaf Disease Detection are outlined as follows;

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.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 8
Plant Disease Detection using CNN
c) Data Argumentation:
Data Argumentation is Technique used to increase the amount of data by
adding slightly modified copies of existing images. This functionality helps to
reduce overfitting when training the model. This process is implemented in the
current model because the dataset that is taken from the organization isn’t large
enough, hence the model will not extract the features of the feed properly, as a
result the model will not be trained properly so we may not get a proper result at
end.
As apart of Data Argumentation some transformation functions are applied to the
existing dataset such as horizontal flipping, vertical flipping, zooming, cropping,
rotation, noise injection etc.
In the current system horizontal flipping, and rescaling of the images, zoom-in to
images etc are applied on trained data set.

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 %.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 9
Plant Disease Detection using CNN
e) Training and Testing
After feeding the input to the selected model the model is complied and trained
and validated for some number of epochs. Then we can know the accuracy of the
trained model. We can also compile using different models, such that the
difference in the accuracy is known and which algorithm best fits of the system.

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.

7.2 System Design:


The Unified Modelling Language (UML) allows the software engineer to
express an analysis model using the modelling notation that is governed by a set of
syntactic-semantic and pragmatic rules. The Unified Modelling Language is
commonly used to visualize and construct software-intensive systems. Because
software has become much more complex in recent years, developers are finding it
more challenging to build complex applications within short periods. Even when they
do, these software applications are often filled with bugs, and it can take programmers
weeks to find and fix them. This is time that has been wasted, since an approach could
have been used which would have reduced the number of bugs before the application
was completed.

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.

• User Model View

• Structural model view

• Behavioural Model View

• Implementation Model View

• Environmental Model View

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 (-).

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 11
Plant Disease Detection using CNN
Class diagram shows a collection of classes, interfaces, associations,
collaborations, and constraints.

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.

Use Case Diagram


A use case diagram at its simplest is a representation of a user's interaction
with the system that shows the relationship between the user and the different use
cases in which the user is involved. A use case diagram can identify the different
types of users of a system and the different use cases and will often be
accompanied by other types of diagrams as well. The use cases are represented by
either circles or ellipses.

Fig: 7.2.1 Use Case for Developer

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 12
Plant Disease Detection using CNN

Fig: 7.2.2 Use Case for User

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.

Fig 7.2.3 Sequence Diagram for developer


Tadikonda Venkata Sai Ravi Teja
178297601023, B.Tech (CSE) 13
Plant Disease Detection using CNN
Class Diagram
Class diagram is a static diagram. It represents the static view of an
application. Class diagram is not only used for visualizing, describing, and
documenting different aspects of a system but also for constructing executable
code of the software application. Class diagram describes the attributes and
operations of a class and also the constraints imposed on the system. The class
diagrams are widely used in the modelling of object-oriented systems because
they are the only UML diagrams, which can be mapped directly with object-
oriented languages. Class diagram shows a collection of classes, interfaces,
associations, collaborations, and constraints. It is also known as a structural
diagram.

Fig 7.2.4 Class Diagram for User

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 14
Plant Disease Detection using CNN
Chapter 8
IMPLEMENTATION

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

Fig 8.1.1 Neural Network

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 15
Plant Disease Detection using CNN
The Architecture of Neural network

There are basically three types of architecture of the neural network.

1. Single Layer feedforward network

2. Multi-Layer feedforward network

3. Recurrent network

1. Single- Layer Feedforward Network

In this, we have an input layer of source nodes projected on an output layer of


neurons. This network is a feedforward or acyclic network. It is termed a single
layer because it only refers to the computation neurons of the output layer. No
computation is performed on the input layer; hence it is not counted.

Fig 8.1.2 Single Layer Neural Network

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 16
Plant Disease Detection using CNN
2. Multi-Layer Feedforward 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

Fig 8.1.3 Example of multi-layered Neural Network

3. Recurrent Networks

A recurrent is almost similar to a feedforward network. The major difference is that


it at least has one feedback loop. There might be zero or more hidden layers, but at
least one feedback loop will be there.

Fig 8.1.4 Recurrent Neural Network

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 17
Plant Disease Detection using CNN
Convolutional Neural Network (CNN)

Introduction

A convolutional neural network (CNN) is a type of artificial neural network used in


image recognition and processing that is specifically designed to process pixel data.

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.

Fig 8.1.5 Implementation of CNN using Simple example

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.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 18
Plant Disease Detection using CNN
TensorFlow

Introduction

TensorFlow is an open-source end-to-end platform for creating Machine Learning


applications. It is a symbolic math library that uses dataflow and differentiable
programming to perform various tasks focused on training and inference of deep
neural networks. It allows developers to create machine learning applications using
various tools, libraries, and community resources.

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

TensorFlow is a library developed by the Google Brain Team to accelerate machine


learning and deep neural network research.

Fig 8.1.6 An Application showing the use of TensorFlow in CNN

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 19
Plant Disease Detection using CNN
Transfer Learning

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.

Working of Transfer Learning Concept

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.

Fig 8.1.7 Inductive Learning and Inductive Transfer

How to use Transfer Learning

You can use transfer learning on your own predictive modelling problems.

Two common approaches are as follows:

1. Develop Model Approach

2. Pre-trained Model Approach


Tadikonda Venkata Sai Ravi Teja
178297601023, B.Tech (CSE) 20
Plant Disease Detection using CNN
Inception V3
Introduction
Inception v3 mainly focuses on burning less computational power by modifying the
previous Inception architectures Inception V, Inception V2.
In comparison to VGGNet, Inception Networks (GoogLeNet/Inception v1) have
proved to be more computationally efficient, both in terms of the number of
parameters generated by the network and the economic cost incurred (memory and
other resources). If any changes are to be made to an Inception Network, care needs
to be taken to make sure that the computational advantages aren’t lost.

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.

Fig 8.1.8 Architecture of Inception V3

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

Flutter is a free and open-source mobile UI framework created by Google.

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.

Flutter consists of two important parts:

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).

A Framework (UI Library based on widgets): A collection of reusable UI elements


(buttons, text inputs, sliders, and so on) that you can personalize for your own needs.

Fig 8.2.1 About Flutter

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 22
Plant Disease Detection using CNN
Google Colab

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.

What Colab Offers You?

• Write and execute code in Python

• Document your code that supports mathematical equations

• Create/Upload/Share notebooks

• Import/Save notebooks from/to Google Drive

• Import/Publish notebooks from GitHub

• Import external datasets e.g. from Kaggle

• Integrate PyTorch, TensorFlow, Keras, OpenCV

• Free Cloud service with free GPU

Using Free GPU

For working on Deep Learning Projects, a in order to improve the


performance of the system, a GPU is required. It’s very costly to afford, and some
times may not be even available at all time. This effects the working of the system
by adding additional weight to it.

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.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 23
Plant Disease Detection using CNN
8.3 Sample Code:-

#model construction

#importing the Packages and Libraries

from tensorflow.keras.layers import Input, Lambda, Dense, Flatten


from tensorflow.keras.models import Model
from tensorflow.keras.applications.inception_v3 import InceptionV3
#from keras.applications.vgg16 import VGG16
from tensorflow.keras.applications.inception_v3 import preprocess_input
from tensorflow.keras.preprocessing import image
from tensorflow.keras.preprocessing.image import ImageDataGenerator,load_img
from tensorflow.keras.models import Sequential
import numpy as np
from glob import glob

#Importing google drive contents


from google.colab import drive
drive.mount('/content/drive') #a key will be generated link will be poped paste the key in that popup

#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

inception = InceptionV3(input_shape=IMAGE_SIZE + [3], weights='imagenet',


include_top=False)

for layer in inception.layers:

layer.trainable = False

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 24
Plant Disease Detection using CNN
folders =glob('/content/drive/MyDrive/4th year projecttobacco2/tb_data/train/*')

x = Flatten()(inception.output)

prediction = Dense(len(folders), activation='softmax')(x)

# create a model object

model = Model(inputs=inception.input, outputs=prediction)

model.summary()

Fig 8.3.1 Generated Model

#Data Argumentation

from tensorflow.keras.preprocessing.image import ImageDataGenerator

train_datagen = ImageDataGenerator(rescale = 1./255, shear_range = 0.2,

zoom_range = 0.2, horizontal_flip = True)

test_datagen = ImageDataGenerator(rescale = 1./255)

training_set = train_datagen.flow_from_directory(

'/content/drive/MyDrive/4th year project tobacco2/tb_data/train',

target_size = (224, 224), batch_size = 16, class_mode = 'categorical')

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 25
Plant Disease Detection using CNN
test_set = test_datagen.flow_from_directory(

'/content/drive/MyDrive/4th year project tobacco2/tb_data/test',

target_size = (224, 224), batch_size = 16, class_mode = 'categorical')

#Training the model

model.compile(loss='categorical_crossentropy', optimizer='adam',

metrics=['accuracy'])

r = model.fit_generator( training_set, validation_data=test_set, epochs=20,

steps_per_epoch=len(training_set), validation_steps=len(test_set) )

Fig 8.3.2 Training Result

#Plotting the loss and accuracy

import matplotlib.pyplot as plt

# plot the loss


plt.plot(r.history['loss'], label='train loss')
plt.plot(r.history['val_loss'], label='val loss')
plt.legend()
plt.show()
plt.savefig('LossVal_loss')

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 26
Plant Disease Detection using CNN
# plot the accuracy
plt.plot(r.history['accuracy'], label='train acc')
plt.plot(r.history['val_accuracy'], label='val acc')
plt.legend()
plt.show()
plt.savefig('AccVal_acc')

Fig 8.3.3 Loss

Fig 8.3.4 Accuracy


#Saving the model
import tensorflow as tf
converter =
tf.lite.TFLiteConverter.from_saved_model('/content/drive/MyDrive/project_model
s/model7') # path to the SavedModel directory

tflite_model = converter.convert()

with open('/content/drive/MyDrive/project_models_lite/model7_tflite.tflite', 'wb')


as f:
f.write(tflite_model)

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 27
Plant Disease Detection using CNN
#sample code for mobile application
#main.dart

#HomePage.dart
• Loading the model and image parameters

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 28
Plant Disease Detection using CNN
• Picking the image and Classifying the image

• Camera and gallery

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 29
Plant Disease Detection using CNN
• Dialog Box UI

• HomePage UI

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 30
Plant Disease Detection using CNN
Chapter 9
TESTING
Inception v3 Training and Results
Inception v3 was trained on ImageNet and compared with other contemporary
models, as shown below.

Fig 9.1 Error Rates of Different Predefined Model

As shown in the table, when augmented with an auxiliary classifier, factorization of


convolutions, RMSProp, and Label Smoothing, Inception v3 can achieve the lowest
error rates compared to its contemporaries.

Testing and Accuracy comparision


As a part of testing compared the results with 2 more models Resnet50 and VGG16
and the accuracy is as shown below.

Depending on the dataset set and the weights of the each model the accuracy may
vary for different models.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 31
Plant Disease Detection using CNN

Fig 9.2 Inception V3 Acc Fig 9.3 Resnet 50 Acc

Fig 9.4 VGG 16 Acc

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 32
Plant Disease Detection using CNN
Chapter 10

OUTPUT

Fig 10.1 Home screen Fig 10.2 Option Popup

Fig 10.4 Result Fig 10.3 Selection of Image


Tadikonda Venkata Sai Ravi Teja
178297601023, B.Tech (CSE) 33
Plant Disease Detection using CNN
Chapter 11
CONCLUSION AND FUTURE WORK

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.

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 34
Plant Disease Detection using CNN
Chapter 12

BIBLIOGRAPHY

1. Sk Mahmudul Hassan , Arnab Kumar Maji , Michał Jasi ´nski , Zbigniew


Leonowicz and Elzbieta Jasi ´nska , “Identification of Plant-Leaf Diseases
Using CNN and Transfer-Learning Approach”, Multidisciplinary Digital
Publishing Institute (MDPI), 2021
2. D. Tiwari, Adem Tuncer, S. Bhardwaj M. Ashish, N. Gangwar, A. Sharma,
S. Patel, “Potato Leaf Diseases Detection Using Deep Learning”,
International Conference on Intelligent Computing and Control Systems,
2020.
3. Inception V3 https://blog.paperspace.com/popular-deep-learning-
architectures-resnet-inceptionv3-squeezenet/
4. TensorFlow- https://www.tensorflow.org/learn
5. Transfer learning - https://keras.io/guides/transfer_learning/
6. Neural Networks - https://www.coursera.org/learn/neural-networks-deep-
learning
7. CNN - https://www.coursera.org/learn/convolutional-neural-networks

Tadikonda Venkata Sai Ravi Teja


178297601023, B.Tech (CSE) 35

You might also like