Project Documentation

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 89

REAL-TIME DETECTION OF APPLE AND TOMATO

LEAF DISEASES USING DEEP LEARNING

A PROJECT REPORT

Submitted by
ARMSTERDAM.J (312116104010)
MOHAN.SR (312116104028)
TAARIQ DAWOOD BUHARI .SA (312116104046)

In a partial fulfillment for the award of the degree

of

BACHELOR OF ENGINEERING

in

COMPUTER SCIENCE AND ENGINEERING

SMK FOMRA INSTITUTEOF TECHNOLOGY,KANCHEEPURAM

ANNA UNIVERSITY :: CHENNAI-600 025


JULY 2020
i
ANNA UNIVERSITY :: CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this project report “REAL -TIME DETECTION OF APPLE AND
TOMATO LEAF DISEASES USING DEEP LEARNING ” is the bonafide
work of “ARMSTERDAM.J (312116104010), MOHAN.SR (312116104028)
and TAARIQ DAWOOD BUHARI.SA (312116104046)”who carried out the
project work under my supervision.

SIGNATURE SIGNATURE
MR.G.Gandhi Jabakumar, M.Tech., MR.D.Vinod,M.E.,
HEAD OF THE DEPARTMENT SUPERVISOR
ASSOCIATE PROFESSOR ASSISTANT PROFESSOR
Department of CSE Department of CSE
SMK Fomra Institute of Technology SMK Fomra Institute of Technology
Kelambakkam, Kelambakkam,
Chennai -603 103 Chennai-603103

Submitted for Project Viva-Voce Exam held on ……………………..

INTERNAL EXAMINER EXTERNAL EXAMINER

ii
ACKNOWLEDGEMENT

The successful completion of our project can be attributed to the blessings of

the almighty, the combined efforts made by us and the contribution made in one

form or the other, by the individuals we hereby acknowledge.

First of all, we express our heartfelt gratitude to our honourable

Correspondent Shree SRI KUMAR FOMRA, and our principal Dr. V.

KRISHNA KUMAR, M.E., Ph.D., for their wonderful support.

Our sincere thanks to Mr.S.K.VIJAI ANAND ,M.E., our Project

Coordinator, Mr.G.GANDHI JABAKUMAR,M.TECH., the Head of the

Department of Computer Science and Engineering and to our project supervisor

Mr.D.VINOD,M.E., for encouraging us to move ahead and for the being with us

right from the beginning of the project and guiding us at every step.

And our sincere thanks to the esteemed review panel for training us with the

presentation and providing more valuable suggestions to make this project

successful error-free and fault-proof system.

Last but not the least we thank our parents and friends for being with us all

the time and giving us the required moral support and love.

iii
ABSTRACT

Plant diseases are a major challenge in the agriculture sector and faster

detection of diseases in plant could help to develop an early treatment technique

while substantially reducing economic losses. In this work, the apple leaf disease

dataset (ALDD) and tomato leaf disease dataset (TLDD), which is composed of

laboratory images and complex images under real old conditions, is rapid storage

technology constructed via data augmentation and image annotation technologies.

Based on this, a new apple leaf and tomato disease detection model that uses deep-

CNN (Convolution Neural Network) is proposed by introducing the Google Net

Inception structure and Rainbow concatenation. The proposed INAR-SSD (SSD

with Inception module and Rainbow concatenation) model is trained to detect these

negative common apple and tomato leaf diseases. The novel INAR-SSD model

provides a high-performance solution for the early diagnosis of apple and tomato

leaf diseases that can perform real-time detection of these diseases with higher

accuracy and faster detection speed than previous method.

iv
TABLE OF CONTENTS

CHAPTER NO TITLE PAGE NO.

ABSTRACT Iv

LIST OF FIGURES Ix

LIST OF ABBREVATIONS X

1 INTRODUCTION 1

1.1 INTRODUCTION 1

1.2 INTRODUCTION TO PYTHON 3

1.2.1 PYTHON ADVANTAGE 3

1.3 DEEP LEARNING 6

1.3.1 HUMAN BRAIN VS ARTIFICIAL 6

NETWORK

1.3.2 ARTIFICIAL NEURAL NETWORK 7

PROCESS

2 LITERATURE SURVEY 10

3 SYSTEM DESIGN 15

3.1 EXISTING SYSTEM 15

3.2 PROPOSED SYSTEM 15

3.3 MODULES 15

3.3.1 IMAGE CAPTURING 15

3.3.2 FEATURE SELECTION 16


v
3.3.3 CLASSIFICATION 16

3.4 ALGORITHM EXPLANATION 16

3.4.1 CONVOLUTIONAL NEURAL 16

NETWORK

3.4.1.1 FIRST LAYER-MATH PART 17

3.4.1.2 FIRST LAYER-HIGH LEVEL 18

PRESPECTIVE

3.4.1.3 FULLY CONNECTED LAYER 21

3.4.1.4 TRAINING 22

3.5 APPLE LEAF DISEASES DATASETS 24

3.6 TOMATO LEAF DISEASES DATASETS 26

4 REQUIREMENTS SPECIFICATION 28

4.1 HARDWARE REQUIREMENTS 28

4.2 SOFTWARE REQUIREMENTS 28

4.3 PERFORMANCE REQUIREMENTS 28

4.4 SAFETY REQUIREMENTS 28

5 SYSTEM DESIGN SPECIFICATION 30

5.1 DESIGN AND IMPLEMENTATION 30

CONSTRAINTS

5.1.1 CONSTRAINTS IN ANALYSIS 30


vi
5.1.2 CONSTRAINTS IN DESIGN 30

5.1.3 CONSTRAINTS IN 30

IMPLEMENTATION

5.2 ARCHITECTURAL DIAGRAM 31

5.2.1 BLOCK DIAGRAM 31

5.2.2 SEQUENCE DIAGRAM 32

5.2.3 USE CASE DIAGRAM 33

5.2.4 ACTIVITY DIAGRAM 34

5.2.5 COLLABORATION DIAGRAM 36

6 TESTING SPECIFICATION 37

6.1 TESTING 37

6.2 CODING STANDARDS 37

6.2.1 NAMING CONVENTIONS 38

6.2.2 VALUE CONVENTIONS 38

6.2.3 SCRIPT WRITING AND COMMENTING 39

STANDARD

6.3 SYSTEM TESTING 39

6.4 TEST DATA AND OUTPUT 40

6.4.1 UNIT TESTING 40

6.4.2 FUNCTIONAL TESTING 41

6.4.3 PERFORMANCE TEST 41


vii
6.4.4 STRESS TEST 41

6.4.5 STRUCTURED TEST 41

6.4.6 INTEGRATION TESTING 42

6.5 TESTING TECHNIQUES 43

6.5.1 WHITE BOX TESTING 43

6.5.2 BLACK BOX TESTING 44

6.5.3 SOFTWARE TESTING STRATERGIES 44

6.5.4 PROGRAM TESTING 45

6.5.5 SECURITY TESTING 46

6.5.6 VALIDATION TESTING 46

6.5.7 USER ACCEPTANCE TESTING 47

7 CONCLUSION 48

8 FUTURE ENHACEMENT 49

APPENDIX 1 CODING 50

APPENDIX 2 EXPERIMENTAL RESULTS 68

REFERENCES 74

viii
LIST OF FIGURES

NO. TABLE NAME PAGE NO.

5.2.1 Block Diagram 31

5.2.2 Sequence Diagram 32

5.2.3 Use Case Diagram 34

5.2.4 Activity Diagram 35

5.2.5 Collaboration Diagram 36

A.2.1 Unmasked Image 68

A.2.2 Masked Image 68

A.2.3 Training 69

A.2.4 Testing 70

A.2.4.1 Testing Tomato Leaf 70

A.2.4.2 Testing Apple Leaf 72

ix
LIST OF ABBREVATIONS

ABBREVIATION EXPANSION

ALDD Apple Leaf Diseases Datasets

TLDD Tomato Leaf Diseases Datasets

CNN Convolutional Neural Network

R-SSD Rainbow Concatenation Solid-State Storage Device

SVM Support Vector Machine

VGG-INCEP Visual Geometry Group Network With The Inception

Module

x
CHAPTER 1

INTRODUCTION

1.1 INTRODUCTION

The apple leaf and tomato leaf diseases is detected using convolutional
neural network for high accuracy detection. Plant diseases are a major threat to
plant growth and crop yield and many researchers have expended substantial
efforts on detecting plant disease. Traditionally, visual examination by experts has
been carried out to diagnose plant diseases and biological examination is the
second option, if necessary. In recent years, through the development of computer
technology, machine learning has been widely utilized to train and detect plant
diseases and is a satisfactory alternative for the detection of plant diseases. It is
easier to realize higher accuracy by using a deep learning approach that is based on
convolution neural networks. In this proposed system a deep learning approach
that is based on improved convolution neural networks (CNN) for the real-time
detection of apple and tomato leaf diseases. The proposed deep-learning based
approach can automatically identify the discriminative features of the diseased
apple and tomato images detect the types of apple and tomato leaf diseases with
high accuracy.

The problem of efficient plant disease protection is closely related to the


problems of sustainable agriculture inexperienced pesticide usage can cause the
development of long-term resistance of the pathogens, severely reducing the ability
to fight back. Timely and accurate diagnosis of plant diseases is one of the pillars of
precision agriculture.

1
It is crucial to prevent unnecessary waste of financial and other resources,
thus achieving healthier production in this changing environment, appropriate and
timely disease identification including early prevention has never been more
important. There are several ways to detect plant pathologies .

Some diseases do not have any visible symptoms, or the effect becomes
noticeable too late to act, and in those situations, a sophisticated analysis is
obligatory. However, most diseases generate some kind of manifestation in the
visible spectrum, so the naked eye examination of a trained professional is the prime
technique adopted in practice for plant disease detection. In order to achieve accurate
plant disease diagnostics a plant pathologist should possess good observation skills
so that one can identify characteristic symptoms. Variations in symptoms indicated
by diseased plants may lead to an improper diagnosis since amateur gardeners and
hobbyists could have more difficulties determining it than a professional plant
pathologist. An automated system designed to help identify plant diseases by the
plant’s appearance and visual symptoms could be of great help to amateurs in the
gardening process and also trained professionals as a verification system in disease
diagnostics. Advances in computer vision present an opportunity to expand and
enhance the practice of precise plant protection and extend the market of computer
vision applications in the field of precision agriculture.
The goal of the neural network is to solve problems in the same way that the
human brain would, although several neural networks are more abstract. Modern
neural network projects typically work with a few thousand to a few million neural
units and millions of connections, which are still several orders of magnitude less
complex than the human brain and closer to the computing power of a worm. New
brain research often stimulates new patterns in neural networks.
One new approach is using connections which span much further and link
2
processing layers rather than always being localized to adjacent neurons. Other
research being explored with the different types of signal over time that axons
propagate, such as Deep Learning, interpolates greater complexity than a set of
boolean variables being simply on or off. Their inputs can also take on any value
between 0 and 1. Also, the neuron has weights for each input and an overall bias.
The weights are real numbers expressing importance of the respective inputs to the
output. The bias is used for controlling how easy the neuron is getting to output 1.
For a neuron with really big bias it is easy to output 1, but when the bias is very
negative then it is difficult to output 1

1.2 INTRODUCTION TO PYTHON

Python is a widely used general-purpose, high level programming language.

It was initially designed by Guido van Rossum in 1991 and developed by Python

Software Foundation. It was mainly developed for emphasis on code readability,

and its syntax allows programmers to express concepts in fewer lines of code.

Python is a programming language that lets you work quickly and integrate

systems more efficiently.

It is used for:

 web development (server-side)


 software development
 mathematic
 System scripting

1.2.1PYTHON ADVANTAGE

3
Python can be used on a server to create web applications. Python can be
used along side software to create workflows. Python can connect to database
systems. It can also read and modify files. Python can be used to handle big data
and perform complex mathematics. Python can be used for rapid prototyping, or
for production-ready software development. Python works on different platforms
(Windows, Mac, Linux, Raspberry Pi, etc).Python has a simple syntax similar to
the English language. Python has syntax that allows developers to write programs
with fewer lines than some other programming languages .Python runs on an
interpreter system, meaning that code can be executed as soon as it is written. This
means that prototyping can be very quick. Python can be treated in a procedural
way, an object-orientated way or a functional way. The most recent major version
of Python is Python 3, which we shall be using in this tutorial. However, Python 2,
although not being updated with anything other than security updates, is still quite
popular. Python 2.0 was released in 2000, and the 2.x versions were the prevalent
releases until December 2008.At that time, the development team made the
decision to release version 3.0, which contained a few relatively small but
significant changes that were not backward compatible with the 2.x versions.
Python 2 and 3 are very similar, and some features of Python 3 have been back
ported to Python 2. But in general, they remain not quite compatible. Both Python
2 and 3 have continued to be maintained and developed, with periodic release
updates for both. As of this writing, the most recent versions available are 2.7.15
and 3.6.5. However, an official End Of Life date of January 1, 2020 has been
established for Python 2, after which time it will no longer be maintained.

Python is still maintained by a core development team at the Institute, and


Guido is still in charge, having been given the title of BDFL (Benevolent Dictator

4
For Life) by the Python community. The name Python, by the way, derives not
from the snake, but from the British comedy troupe Monty Python’s Flying Circus,
of which Guido was, and presumably still is, a fan. It is common to find references
to Monty Python sketches and movies scattered throughout the Python
documentation. It is possible to write Python in an Integrated Development
Environment, such as Thonny, Pycharm, Netbeans or Eclipse which are
particularly useful when managing larger collections of Python files.

Python was designed to for readability, and has some similarities to the
English language with influence from mathematics . Python uses new lines to
complete a command, as opposed to other programming languages which often
use semicolons or parentheses. Python relies on indentation, using whitespace,to
define scope; such as the scope of loops, functions and classes. Other programming
languages often use curly-brackets for this purpose. Many languages are compiled,
meaning the source code you create needs to be translated into machine code, the
language of your computer’s processor, before it can be run. Programs written in
an interpreted language are passed straight to an interpreter that runs them directly.
This makes for a quicker development cycle because you just type in your code
and run it, without the intermediate compilation step. One potential downside to
interpreted languages is execution speed. Programs that are compiled into the
native language of the computer processor tend to run more quickly than
interpreted programs. For some applications that are particularly computationally
intensive, like graphics processing or intense number crunching, this can be
limiting. In practice, however, for most programs, the difference in execution
speed is measured in milliseconds, or seconds at most, and not appreciably
noticeable to a human user.

5
The expediency of coding in an interpreted language is typically worth it for
most applications. For all its syntactical simplicity, Python supports most
constructs that would be expected in a very high-level language, including
complex dynamic data types, structured and functional programming, and object-
oriented programming. Additionally, a very extensive library of classes and
functions is available that provides capability well beyond what is built into the
language, such as database manipulation or GUI programming.

1.3DEEP LEARNING

Deep Learning is a specialized form of Machine Learning that uses


supervised, unsupervised, or semi-supervised learning to learn from data
representations. It is similar to the structure and function of the human nervous
system, where a complex network of interconnected computation units works in a
coordinated fashion to process complex information. Machine Learning is an
approach or subset of Artificial Intelligence that is based on the idea that machines
can be given access to data along with the ability to learn from it. Deep Learning
takes Machine Learning to the next level.

There are many aspects of Deep Learning as listed below

1. Multiple levels of hierarchical representations


2. Multi-layered neural networks
3. Training of large neural networks
4. Multiple non-linear transformations
5. Pattern recognition
6. Feature extraction
7. High-level data abstractions model

1.3.1HUMAN BRAIN VS. ARTIFICIAL NEURAL NETWORKS

The computational models in Deep Learning are loosely inspired by the

human brain. The multiple layers of training are called Artificial Neural Networks.

6
ANNs are processing devices (algorithms or actual hardware) that are
modeled on the neuronal structure of the mammalian cerebral cortex but on a much
smaller scale. It is a computing system made up of a number of simple, highly
interconnected processing elements which process information through their
dynamic state response to external inputs.

1.3.2ARTIFICIAL NEURAL NETWORKS PROCESS

Artificial Neural Networks consist of the following four main parts:

 Neurons
 Nodes
 Input
 Output

7
NEURON

Artificial Neural Networks contain layers of neurons. A neuron is a


computational unit that calculates a piece of information based on weighted input
parameters. Inputs accepted by the neuron are separately weighted.

Inputs are summed and passed through a non-linear function to produce


output. Each layer of neurons detects some additional information, such as edges
of things in a picture or tumors in a human body. Multiple layers of neurons can be
used to detect additional information about input parameters.
NODES
Artificial Neural Network is an interconnected group of nodes akin to the vast
network of layers of neurons in a brain. Each circular node represents an artificial
neuron and an arrow represents a connection from the output of one neuron to the
input of another.
8
INPUTS
Inputs are passed into the first layer. Individual neurons receive the inputs,
with each of them receiving a specific value. After this, an output is produced
based on these values.
OUTPUTS
The outputs from the first layer are then passed into the second layer to be
processed. This continues until the final output is produced. The assumption is that
the correct output is predefined. Each time data is passed through the network, the
end result is compared with the correct one, and tweaks are made to their values
until the network creates the correct final output each time.

9
CHAPTER 2
LITERATURE SURVEY
H. Lu et al. (2019) CONet: A Cognitive Ocean Network [1]. The scientific
and technological revolution of the Internet of Things has begun in the area of
oceanography. Historically, humans have observed the ocean from an external
viewpoint in order to study it. In recent years, however, changes have occurred in
the ocean, and laboratories have been built on the seafloor. Approximately 70.8%
of the Earth's surface is covered by oceans and rivers. The Ocean of Things is
expected to be important for disaster prevention, ocean-resource exploration, and
underwater environmental monitoring. Unlike traditional wireless sensor networks,
the Ocean Network has its own unique features, such as low reliability and narrow
bandwidth. These features will be great challenges for the Ocean Network.
Furthermore, the integration of the Ocean Network with artificial intelligence has
become a topic of increasing interest for oceanology researchers. The Cognitive
Ocean Network (CONet) will become the mainstream of future ocean science and
engineering developments. In this article, we define the CONet. The contributions
of the paper are as follows: (1) a CONet architecture is proposed and described in
detail; (2) important and useful demonstration applications of the CONet are
proposed; and (3) future trends in CONet research are presented.

Chunxe Wu et al.(2018) A Greedy Deep Learning Method for Medical


Disease Analysis [2].This paper proposes a novel method of deep learning,
GDWDL, which applied to the classification of mobile multimedia for medical
diseases. With the help of mobile multimedia technology, we timely follow-up
observation to patients and exchange the collected information into data
information. It can better and more effectively classify the patients, taking into
account the large amount of data on the basis of large data accumulation Complex
and difficult. Using the weight method to measure intrinsic relation between the
sample and the dictionary atom, we deal with the over-fitting phenomenon for the
limited training set through 12 -norm regularization constraint. At the same time,
we introduce the model of the deep network learning, and make local information
between the layers train to ensure that each layer is convergence, layer by layer to
10
promote their own characteristics, in order to achieve the best classification effect.
The combination of healthcare and machine learning can play a great role in
machine learning, and better improve efficiency in the field of mobile multimedia
for healthcare. In this paper the GDWL accuracy is 90.67 we can easily see that
the algorithm proposed in this paper is superior to other algorithms in the
performance of patient classification by processing the collected medical data and
testing the data.

H. Lu, Y. Li, M. Chen et al.(2018) Brain intelligence :Go beyond artificial


intelligence [3]. Artificial intelligence (AI) is an important technology that supports
daily social life and economic activities. It contributes greatly to the sustainable
growth of Japan's economy and solves various social problems. In recent years, AI
has attracted attention as a key for growth in developed countries such as Europe
and the United States and developing countries such as China and India. The
attention has been focused mainly on developing new artificial intelligence
information communication technology (ICT) and robot technology (RT).
Although recently developed AI technology certainly excels in extracting certain
patterns, there are many limitations. Most ICT models are overly dependent on big
data, lack a self-idea function, and are complicated. In this paper, rather than
merely developing nextgeneration artificial intelligence technology, we aim to
develop a new concept of general-purpose intelligence cognition technology called
“Beyond AI”. Specifically, we plan to develop an intelligent learning model called
“Brain Intelligence (BI)” that generates new ideas about events without having
experienced them by using artificial life with an imagine function.

J. Li, N.Wang et al.(2018) New secret sharing scheme based on faster R-


CNNs image retrieval [4]. Secret image sharing has been attracting considerable
research attention in recent years as images become ubiquitous on the Internet and
mobile applications. In traditional (t, n) threshold secret image sharing schemes,
the sender embeds the secret image into several shadow images and sends them to
all participants. However, the shadow images are vulnerable during the
transmission process on the Internet. In order to ensure the security of the shadow
images which contain secret information, a new secret sharing scheme is proposed
based on Faster Region Convolutional Neural Networks (Faster R-CNNs). This
11
scheme uses a query image which does not have any secret information but looks
similar to the original shadow image. Each participant retrieves the corresponding
shadow image to search the query image in a big image database. As a result
shadow images are searched by using Faster R-CNNs and stored in a database
which is protected from being attacked, rather than transmitted over the network
directly in the proposed scheme.

Caglayan.A et al.(2018) Volumetric object recognition using 3-D CNNs on


depth data [5]. Recognizing 3-D objects has a wide range of application areas from
autonomous robots to self-driving vehicles. The popularity of low-cost RGB-D
sensors has enabled a rapid progress in 3-D object recognition in the recent years.
Most of the existing studies use depth data as an additional channel to the RGB
channels. Instead of this approach, we propose two volumetric representations to
reveal rich 3-D structural information hidden in depth images. We present a 3-D
convolutional neural network (CNN)-based object recognition approach, which
utilizes these volumetric representations and single and multi-rotational depth
images. A robot can change its viewpoints in the environment and collect multiple
images of objects to increase recognition accuracy using the proposed approach.
We believe the proposed method can be useful for robotic vision applications
including semantic mapping and recognition tasks.

H. Lu, Y. Li et al.(2018) Low illumination underwater light field images


reconstruction using deep convolutional neural networks [6]. High-definition
display technology for underwater images is of great significance for many
applications, such as marine animal observation, seabed mining, and marine
fishery production. The traditional underwater visual display systems have
problems, such as low visibility, poor real-time performance, and low resolution,
and cannot meet the needs of real-time high-definition displays in extreme
environments. To solve these issues, we propose an underwater image
enhancement method and a corresponding image super-resolution algorithm. To
improve the quality of underwater images, we modify the Retinex algorithm and
combine it with a neural network. The Retinex algorithm is used to defog the
underwater image, and then, the image brightness is improved by applying gamma
correction. Then, by combining with the dark channel prior and multilayer
12
perceptron, the transmission map is further refined to improve the dynamic range
of the image. In the super-resolution process, the current convolutional neural
network reconstruction algorithm is only trained on the Y channel, which will lead
to problems due to the insufficient acquisition of the color feature.

X. Zhang et al.(2018) Identification of maize leaf diseases using improved


deep convolutional neural networks [7]. In the field of agricultural information, the
automatic identification and diagnosis of maize leaf diseases is highly desired. To
improve the identification accuracy of maize leaf diseases and reduce the number of
network parameters, the improved GoogLeNet and Cifar10 models based on deep
learning are proposed for leaf disease recognition in this paper. Two improved
models that are used to train and test nine kinds of maize leaf images are obtained by
adjusting the parameters, changing the pooling combinations, adding dropout
operations and rectified linear unit functions, and reducing the number of classifiers.
In addition, the number of parameters of the improved models is significantly
smaller than that of the VGG and AlexNet structures. During the recognition of eight
kinds of maize leaf diseases, the GoogLeNet model achieves a top - 1 average
identification accuracy of 98.9%, and the Cifar10 model achieves an average
accuracy of 98.8%.
M. Kulin et al.(2018) End-to-end learning from spectrum data: A deep
learning approach for wireless signal identification in spectrum monitoring
applications [8]. This paper presents a comprehensive and systematic introduction
to end-to-end learning from spectrum data - a deep learning based unified approach
for realizing various wireless signal identification tasks, which are the main
building blocks of spectrum monitoring systems. The approach develops around
the systematic application of deep learning techniques to obtain accurate wireless

13
signal classifiers in an end-to-end learning pipeline. In particular, convolutional
neural networks (CNNs) lend themselves well to this setting, because they consist
of many layers of processing units capable to automatically extract non-linear and
more abstract wireless signal features that are invariant to local spectral and
temporal variations, and train wireless signal classifiers that can outperform
traditional approaches.

14
CHAPTER 3
SYSTEM ANALYSIS

3.1 EXISITING SYSTEM

In recent years, with the popularization of digital cameras and other electronic
devices, automatic plant disease diagnosis has been widely applied as a satisfactory
alternative. Nevertheless, in most cases, traditional machine learning approaches
such as support vector machine (SVM) and K-means clustering have complex
image preprocessing and feature extraction steps, which reduce the efficiency of
disease diagnosis.

3.2PROPOSED SYSTEM
In this proposed system a deep learning approach that is based on improved
convolution neural networks (CNN) for the real-time detection of apple and tomato
leaf diseases. The proposed deep-learning based approach can automatically
identify the discriminative features of the diseased apple and tomato images and
detect the types of diseases with high accuracy. At the same time the proposed
approach can detect not only various diseases in the same diseased image but also
the same disease of different sizes in the same diseased image.

3.3 MODULES :

 Image Capturing
 Feature Selection
 Classification

3.3.1 IMAGE CAPTURING

15
In this module we create a basic infrastructure to establish the proposed
feature of image handling in python. Prepare the python environment to access
video input device, in this case a camera.

3.3.2 FEATURE SELECTION

Image annotation is a vital step of which the objective is to label the positions
and classes of object spots in the diseased images. For this stage, a convolution
neural networks (CNN) algorithm that provides a frame selection function is
developed in Python.

3.3.3 CLASSIFICATION

The bounding box will be detected in which the disease is affected in the
apple leaf. Finally the disease will be labeled which types of disease are affected.

3.4 ALGORITHM EXPLANATION

3.4.1 CONVOLUTIONAL NEURAL NETWORK

Convolutional neural networks (CNN) sounds like a weird combination of


biology and math with a little CS sprinkled in, but these networks have been some
of the most influential innovations in the field of computer vision. 2012 was the
first year that neural nets grew to prominence as Alex Krizhevsky used them to
win that year’s ImageNet competition (basically, the annual Olympics of computer
vision), dropping the classification error record from 26% to 15%, an astounding
improvement at the time. Ever since then, a host of companies have been using
deep learning at the core of their services. Facebook uses neural nets for their

16
automatic tagging algorithms, Google for their photo search, Amazon for their
product recommendations, Pinterest for their home feed personalization, and
Instagram for their search infrastructure.

3.4.1.1 FIRST LAYER– MATH PART

The first layer in a CNN is always a Convolutional Layer. First thing to make
sure you remember is what the input to this conv (I’ll be using that abbreviation a
lot) layer is. Like we mentioned before, the input is a 32 x 32 x 3 array of pixel
values. Now, the best way to explain a convolutional layer is to imagine a
flashlight that is shining over the top left of the image. Let’s say that the light this
flashlight shines covers a 5 x 5 area. And now, let’s imagine this flashlight sliding
across all the areas of the input image. In machine learning terms, this flashlight is
called a filter (or sometimes referred to as a neuron or a kernel) and the region that
it is shining over is called the receptive field. Now this filter is also an array of
numbers (the numbers are called weights or parameters). A very important note is
that the depth of this filter has to be the same as the depth of the input (this makes
sure that the math works out), so the dimension of this filter is 5 x 5 x 3. Now, let’s
take the first position the filter is in for example. It would be the top left corner.
As the filter is sliding, or convolving, around the input image, it is multiplying the
values in the filter with the original pixel values of the image (aka
computing element wise multiplications). These multiplications are all summed up
(mathematically speaking, this would be 75 multiplications in total). So now you
have a single number. Remember, this number is just representative of when the
filter is at the top left of the image. Now, we repeat this process for every location
on the input volume. (Next step would be moving the filter to the right by 1 unit,
then right again by 1, and so on). Every unique location on the input volume
produces a number. After sliding the filter over all the locations, you will find out
that what you’re left with is a 28 x 28 x 1 array of numbers, which we call
an activation map or feature map. The reason you get a 28 x 28 array is that there
are 784 different locations that a 5 x 5 filter can fit on a 32 x 32 input image. These
784 numbers are mapped to a 28 x 28 array.

17
Let’s say now we use two 5 x 5 x 3 filters instead of one. Then our output
volume would be 28 x 28 x 2. By using more filters, we are able to preserve the
spatial dimensions better. Mathematically, this is what’s going on in a
convolutional layer.

3.4.1.2 FIRST LAYER – HIGH LEVEL PERSPECTIVE

However, let’s talk about what this convolution is actually doing from a high
level. Each of these filters can be thought of as feature identifiers. When I say
features, I’m talking about things like straight edges, simple colors, and curves.
Think about the simplest characteristics that all images have in common with each
other. Let’s say our first filter is 7 x 7 x 3 and is going to be a curve detector. (In
this section, let’s ignore the fact that the filter is 3 units deep and only consider the
top depth slice of the filter and the image, for simplicity.)As a curve detector, the
filter will have a pixel structure in which there will be higher numerical values
along the area that is a shape of a curve (Remember, these filters that we’re talking
about as just numbers!).

18
Now, let’s go back to visualizing this mathematically. When we have this
filter at the top left corner of the input volume, it is computing multiplications
between the filter and pixel values at that region. Now let’s take an example of an
image that we want to classify, and let’s put our filter at the top left corner.

Remember, what we have to do is multiply the values in the filter with the
original pixel values of the image.

19
Basically, in the input image, if there is a shape that generally resembles the
curve that this filter is representing, then all of the multiplications summed together
will result in a large value! Now let’s see what happens when we move our filter.

The value is much lower! This is because there wasn’t anything in the image
section that responded to the curve detector filter. Remember, the output of this
conv layer is an activation map. So, in the simple case of a one filter convolution
(and if that filter is a curve detector), the activation map will show the areas in
which there at mostly likely to be curves in the picture. In this example, the top left
value of our 26 x 26 x 1 activation map (26 because of the 7x7 filter instead of
5x5) will be 6600. This high value means that it is likely that there is some sort of
curve in the input volume that caused the filter to activate. The top right value in
our activation map will be 0 because there wasn’t anything in the input volume that
caused the filter to activate (or more simply said, there wasn’t a curve in that
region of the original image). Remember, this is just for one filter. This is just a
filter that is going to detect lines that curve outward and to the right. We can have
20
other filters for lines that curve to the left or for straight edges. The more filters,
the greater the depth of the activation map, and the more information we have
about the input volume.

3.4.1.3 FULLY CONNECTED LAYER

Now that we can detect these high level features, the icing on the cake is
attaching a fully connected layer to the end of the network. This layer basically
takes an input volume (whatever the output is of the conv or ReLU or pool layer
preceding it) and outputs an N dimensional vector where N is the number of
classes that the program has to choose from. For example, if you wanted a digit
classification program, N would be 10 since there are 10 digits. Each number in
this N dimensional vector represents the probability of a certain class. For
example, if the resulting vector for a digit classification program is [0 .1 .1 .75 0 0
0 0 0 .05], then this represents a 10% probability that the image is a 1, a 10%
probability that the image is a 2, a 75% probability that the image is a 3, and a 5%
probability that the image is a 9 (Side note: There are other ways that you can
represent the output, but I am just showing the softmax approach). The way this
fully connected layer works is that it looks at the output of the previous layer
(which as we remember should represent the activation maps of high level
features) and determines which features most correlate to a particular class. For
example, if the program is predicting that some image is a dog, it will have high
values in the activation maps that represent high level features like a paw or 4 legs,
etc. Similarly, if the program is predicting that some image is a bird, it will have
high values in the activation maps that represent high level features like wings or a
beak, etc. Basically, a FC layer looks at what high level features most strongly
correlate to a particular class and has particular weights so that when you compute
the products between the weights and the previous layer, you get the correct
probabilities for the different classes.

21
3.4.1.4 TRAINING

Now, this is the one aspect of neural networks that I purposely haven’t
mentioned yet and it is probably the most important part. There may be a lot of
questions you had while reading. How do the filters in the first conv layer know to
look for edges and curves? How does the fully connected layer know what
activation maps to look at? How do the filters in each layer know what values to
have? The way the computer is able to adjust its filter values (or weights) is
through a training process called backpropagation.

Before we get into backpropagation, we must first take a step back and talk
about what a neural network needs in order to work. At the moment we all were
born, our minds were fresh. We didn’t know what a cat or dog or bird was. In a
similar sort of way, before the CNN starts, the weights or filter values are
randomized. The filters don’t know to look for edges and curves. The filters in the
higher layers don’t know to look for paws and beaks. As we grew older however,
our parents and teachers showed us different pictures and images and gave us a
corresponding label. This idea of being given an image and a label is the training
process that CNNs go through. Before getting too into it, let’s just say that we have
a training set that has thousands of images of dogs, cats, and birds and each of the
images has a label of what animal that picture is. Back to backprop.

So backpropagation can be separated into 4 distinct sections, the forward pass,


the loss function, the backward pass, and the weight update. During the forward
pass, you take a training image which as we remember is a 32 x 32 x 3 array of
numbers and pass it through the whole network. On our first training example,
since all of the weights or filter values were randomly initialized, the output will
probably be something like [.1 .1 .1 .1 .1 .1 .1 .1 .1 .1], basically an output that
doesn’t give preference to any number in particular. The network, with its current
weights, isn’t able to look for those low level features or thus isn’t able to make
any reasonable conclusion about what the classification might be. This goes to
the loss function part of backpropagation. Remember that what we are using right
now is training data. This data has both an image and a label. Let’s say for example
that the first training image inputted was a 3. The label for the image would be [0 0
0 1 0 0 0 0 0 0]. A loss function can be defined in many different ways but a
common one is MSE (mean squared error), which is ½ times (actual - predicted)
squared.
22
Let’s say the variable L is equal to that value. As you can imagine, the loss
will be extremely high for the first couple of training images. Now, let’s just think
about this intuitively. We want to get to a point where the predicted label (output
of the ConvNet) is the same as the training label (This means that our network got
its prediction right).In order to get there, we want to minimize the amount of loss
we have. Visualizing this as just an optimization problem in calculus, we want to
find out which inputs (weights in our case) most directly contributed to the loss (or
error) of the network.

This is the mathematical equivalent of a dL/dW where W are the weights at a


particular layer. Now, what we want to do is perform a backward pass through the
network, which is determining which weights contributed most to the loss and
finding ways to adjust them so that the loss decreases. Once we compute this
derivative, we then go to the last step which is the weight update. This is where
we take all the weights of the filters and update them so that they change in the
opposite direction of the gradient.

23
The learning rate is a parameter that is chosen by the programmer. A high
learning rate means that bigger steps are taken in the weight updates and thus, it
may take less time for the model to converge on an optimal set of weights.
However, a learning rate that is too high could result in jumps that are too large
and not precise enough to reach the optimal point.

The process of forward pass, loss function, backward pass, and parameter
update is one training iteration. The program will repeat this process for a fixed
number of iterations for each set of training images (commonly called a batch).
Once you finish the parameter update on the last training example, hopefully the
network should be trained well enough so that the weights of the layers are tuned
correctly.

3.5 APPLE LEAF DIEASES DATASETS

At the beginning of our work, many human and material resources were
devoted to the collection of diseased apple leaves because few suitable datasets
were available for the real-time detection of apple leaf diseases. The disease
patterns of apple leaves vary with the season and with other factors such as the
humidity, temperature and illuminance. For example, rainy weather is conducive to
the generation and spread of germs, thereby resulting in the expansion and
diffusion of the disease spots on affected leaves. Taking that into consideration,
images of ALDD are collected under various weather conditions for more
comprehensive applications. In addition to the artificially collected images, other
images in the dataset are supplied by Apple Experiment Station of Northwest A&F
University in Baishui county, Shaanxi province, China. A total of 2029 images of
diseased apple leaves are obtained, which correspond to five classes: Alternaria

24
leaf spot (caused by Alternaria alternata f.sp mali), Brown spot (caused by
Marssonina coronaria), Mosaic (caused by Papaya ringspot virus), Grey spot
(caused by Phyllosticta pirina Sacc and Coryneum foliicolum) and Rust (caused by
Pucciniaceae glue rust). These five common diseases of apple leaves are selected
for two reasons: initially, these five types of diseases can be visually identified
from leaves, which is essential for the application of CNNs. In addition, they are
responsible for substantial yield reductions in the apple industry.
First, lesions that are caused by the same disease show certain commonalities
under similar natural conditions. Second, the yellow lesions in the Mosaic class
diffuse throughout the leaves, which distinguish them from other lesions. Third,
the Alternaria leaf spot and Grey spot are similar in terms of geometric features,
thereby increasing the complexity of detecting them. Finally, the Rust class is
composed of rust-yellow spots that have brown pinhead-sized points in the center.
Because of the remarkable difference, Rust is easier to distinguish from other
diseases. These observations are helpful for the diagnosis and recognition of
various apple leaf diseases.The collected dataset has the following three
characteristics:First, multiple diseases may co-occur on the samediseased image.
Second, most images contain complex backgrounds,which ensures the high
generalization performance namely, a basic pre-network and a feature extraction
and fusion structure, as illustrated in Figure 5. To increase network's adaptability to
various scales of apple leaf disease spots, conv4_1 and conv4_2 of VGGNet are
replaced with two GoogLeNet Inception modules. Via this approach, the capability
of multi-scale feature extraction can be improved. The feature extraction and
fusion structure is designed by applying the Rainbow concatenation method to
improve the feature fusion performance. Pooling and deconvolution are performed
simultaneously to create feature maps among layers so that when the detection is
performed, all the cases are considered, regardless of whether the size of the object
is appropriate for the specified scale or not. This improved SSD model implements
multi-angle feature fusion by utilizing the Inception module to extract features of
various sizes and Rainbow concatenation to enhance contextual connections
among layers, with the objective of improving the detection performance for small
apple leaf disease spots.

25
3.6 TOMATO LEAF DISEASES DATASETS

This paper concentrates on identifying tomato leaf disease by deep learning.


In this section, the abstract mathematical model about identifying tomato leaf
disease is displayed at frst. Meanwhile, the process of typical CNN is described
with formulas. Ten, the dataset and data augmentation are presented. Finally, we
introduced three powerful deep neural networks adopted in this paper, i.e.,AlexNet
GoogLeNet, and ResNet.

The paper concentrates on identifying tomato leaf disease by deep learning. In


this section, the abstract mathematical model about identifying tomato leaf disease
is displayed at frst. Meanwhile, the process of typical CNN is described with
formulas. Ten, the dataset and data augmentation are presented. Finally, we
introduced three powerful deep neural networks adopted in this paper, i.e.,
AlexNet, GoogLeNet, and ResNet. Te main process of tomato leaf disease

26
identifcation in this work can be abstracted as a mathematical model . First, we
assume the mapping function from tomato leaves to diseases is f:X->Y
f:X and then
send the training samples to the optimization method. Te hypothesis set H means
possible objectivee functions with diferent parameters; through a series of
parameters update, we can get the fnal assumption g≈y.

27
CHAPTER 4

REQUIREMENTS SPECIFICATION

4.1 HARDWARE REQUIREMENTS

 Hard Disk : 500GB and Above


 RAM : 4GB and Above
 Processor : I3 and Above

4.2 SOFTWARE REQUIREMENTS

 Operating System : Windows 7 , 8, 10 (64 bit)


 Software : Python
 Tools : Python 3.7 IDLE, jupyter Note Book and
Spyder
4.3 PERFORMANCE REQUIREMENTS

The application at this side controls and communicates with the following
three main general components. Embedded browser in charge of the navigation
and accessing to the web service. The server side contains the main parts of the
functionality of the proposed architecture. The components at this tier are the
following are web server, security module, server-side capturing engine,
preprocessing engine, database system, verification engine, output module.

4.4 SAFETY REQUIREMENTS


The software may be safety-critical. If so, there are issues associated with its

integrity level. The software may not be safety-critical although it forms part of

28
a safety-critical system. For example, software may simply log transactions. If a

system must be of a high integrity level and if the software is shown to be of

that integrity level, then the hardware must be at least of the same integrity

level. There is little point in producing 'perfect' code in some language if

hardware and system software (in widest sense) are not reliable. If a computer

system is to run software of a high integrity level then that system should not at

the same time accommodate software of a lower integrity level. Systems with

different requirements for safety levels must be separated. Otherwise, the

highest level of integrity required must be applied to all systems in the same

environment.

29
CHAPTER 5

SYSTEM DESIGN SPECIFICATION

5.1 DESIGN AND IMPLEMENTATION CONSTRAINT


5.1.1CONSTRAINTS IN ANALYSIS
 Constraints as Informal Text

 Constraints as Operational Restrictions

 Constraints Integrated in Existing Model Concepts

 Constraints as a Separate Concept

 Constraints Implied by the Model Structure

5.1.2CONSTRAINTS IN DESIGN

 Determination of the Involved Classes

 Determination of the Involved Objects

 Determination of the Involved Actions

 Determination of the Require Clauses

 Global actions and Constraint Realization

5.1.3 CONSTRAINTS IN IMPLEMENTATION

A hierarchical structuring of relations may result in more classes and a more


complicated structure to implement. Therefore it is advisable to transform the
hierarchical relation structure to a simpler structure such as a classical flat one. It is
rather straightforward to transform the developed hierarchical model into a
bipartite, flat model, consisting of classes on the one hand and flat relations on the
30
other. Flat relations are preferred at the design level for reasons of simplicity and
implementation ease. There is no identity or functionality associated with a flat
relation. A flat relation corresponds with the relation concept of entity-relationship
modeling and many object oriented methods.
5.2 ARCHITECTURE DIAGRAM:

5.2.1 BLOCK DIAGRAM:

Convolution
Webcam Video Feature neural
streaming Selection network

Bounding
Result Performance Classification box
measure disease

Fig: 5.2.1

31
5.2.2 SEQUENCE DIAGRAM:

A Sequence diagram is a kind of interaction diagram that shows how


processes operate with one another and in what order. It is a construct of Message
Sequence diagrams are sometimes called event diagrams, event sceneries and
timing diagram.

Fig:5.2.2

32
5.2.3 USE CASE DIAGRAM:

Unified Modeling Language (UML) is a standardized general-purpose


modeling language in the field of software engineering. The standard is managed
and was created by the Object Management Group. UML includes a set of graphic
notation techniques to create visual models of software intensive systems. This
language is used to specify, visualize, modify, construct and document the artifacts
of an object oriented software intensive system under development. A Use case
Diagram is used to present a graphical overview of the functionality provided by a
system in terms of actors, their goals and any dependencies between those use
cases.

Use case diagram consists of two parts:

Use case: A use case describes a sequence of actions that provided something of
measurable value to an actor and is drawn as a horizontal ellipse.

Actor: An actor is a person, organization or external system that plays a role in


one or more interaction with the system.

33
Fig:5.2.3

5.2.4 ACTIVITY DIAGRAM:

Activity diagram is a graphical representation of workflows of stepwise


activities and actions with support for choice, iteration and concurrency. An
activity diagram shows the overall flow of control.

The most important shape types:

34
 Rounded rectangles represent activities.
 Diamonds represent decisions.
 Bars represent the start or end of concurrent activities.
 A black circle represents the start of the workflow.
 An encircled circle represents the end of the workflow.

Fig:5.2.4

35
5. 2.5COLLABORATION DIAGRAM:

UML Collaboration Diagrams illustrate the relationship and interaction

between software objects. They require use cases, system operation contracts and

domain model to already exist. The collaboration diagram illustrates messages

being sent between classes and objects.

Fig:5.2.5

36
CHAPTER 6

TESTING SPECIFICATION

6.1 TESTING

Once the design aspect of the system is finalizes the system enters into the
coding and testing phase. The coding phase brings the actual system into action by
converting the design of the system into the code in a given programming
language. Therefore, a good coding style has to be taken whenever changes are
required it easily screwed into the system.

6.2 CODING STANDARDS

Coding standards are guidelines to programming that focuses on the physical

structure and appearance of the program. They make the code easier to read,

understand and maintain. This phase of the system actually implements the

blueprint developed during the design phase. The coding specification should be in

such a way that any programmer must be able to understand the code and can bring

about changes whenever felt necessary. Some of the standard needed to achieve the

above-mentioned objectives are as follows:

 Naming conventions

 Value conventions

 Script and comment procedure

37
 Message box format

 Exception and error handling

6.2.1 NAMING CONVENTIONS

Naming conventions of classes, data member, member functions, procedures

etc., should be self-descriptive. One should even get the meaning and scope of the

variable by its name. The conventions are adopted for easy understanding of the

intended message by the user. So it is customary to follow the conventions. These

conventions are as follows:

CLASS NAMES

Class names are problem domain equivalence and begin with capital letter

and have mixed cases.

MEMBER FUNCTION AND DATA MEMEBER NAME

Member function and data member name begins with a lowercase letter with

each subsequent letters of the new words in uppercase and the rest of letters in

lowercase.

6.2.2 VALUE CONVENTIONS

Value conventions ensure values for variable at any point of time. This

38
involves the following:

 Proper default values for the variables.

 Proper validation of values in the field.

 Proper documentation of flag values.

6.2.3 SCRIPT WRITING AND COMMENTING STANDARD

Script writing is an art in which indentation is utmost important. Conditional

and looping statements are to be properly aligned to facilitate easy understanding.

Comments are included to minimize the number of surprises that could occur when

going through the code.

6.2.4 MESSAGE BOX FORMAT

When something has to be prompted to the user, he must be able to

understand it properly. To achieve this, a specific format has been adopted in

displaying messages to the user. They are as follows:

 X – User has performed illegal operation.

 ! – Information to the user.

6.3 SYSTEM TESTING

Testing is performed to identify errors. It is used for quality assurance.

39
Testing is an integral part of the entire development and maintenance process. The

goal of the testing during phase is to verify that the specification has been

accurately and completely incorporated into the design, as well as to ensure the

correctness of the design itself. For example the design must not have any logic

faults in the design is detected before coding commences, otherwise the cost of

fixing the faults will be considerably higher as reflected. Detection of design faults

can be achieved by means of inspection as well as walkthrough.

Testing is one of the important steps in the software development phase.

Testing checks for the errors, as a whole of the project testing involves the

following test cases:

 Static analysis is used to investigate the structural properties of the Source

code.

 Dynamic testing is used to investigate the behavior of the source code by

executing the program on the test data.

6.4 TEST DATA AND OUTPUT

6.4.1 UNIT TESTING

Unit testing is conducted to verify the functional performance of each


modular component of the software. Unit testing focuses on the smallest unit of the

40
software design (i.e.), the module. The white-box testing techniques were heavily

employed for unit testing.

6.4.2 FUNCTIONAL TESTS

Functional test cases involved exercising the code with nominal input values
for which the expected results are known, as well as boundary values and special
values, such as logically related inputs, files of identical elements, and empty files.

Three types of tests in Functional test:

 Performance Test

 Stress Test

 Structure Test

6.4.2.1 PERFORMANCE TEST

It determines the amount of execution time spent in various parts of the unit,

program throughput, and response time and device utilization by the program unit .

6.4.2.2 STRESS TEST

Stress Test is those test designed to intentionally break the unit. A Great deal
can be learned about the strength and limitations of a program by examining the
manner in which a programmer in which a program unit breaks.

6.4.2.3 STRUCTURE TEST

Structure Tests are concerned with exercising the internal logic of a


program and traversing particular execution paths. The way in which White-Box
41
test strategy was employed to ensure that the test cases could Guarantee that all

independent paths within a module have been have been exercised at least once.

 Exercise all logical decisions on their true or false sides.

 Execute all loops at their boundaries and within their operational bounds.

 Exercise internal data structures to assure their validity.

 Checking attributes for their correctness.

 Handling end of file condition, I/O errors, buffer problems and textual errors

in output information

6.4.3 INTEGRATION TESTING

Integration testing is a systematic technique for construction the program

structure while at the same time conducting tests to uncover errors associated with

interfacing. i.e., integration testing is the complete testing of the set of modules

which makes up the product. The objective is to take untested modules and build a

program structure tester should identify critical modules. Critical modules should

be tested as early as possible. One approach is to wait until all the units have

passed testing, and then combine them and then tested. This approach is evolved

from unstructured testing of small programs. Another strategy is to construct the

product in increments of tested units. A small set of modules are integrated for

42
together and tested, to which another module is added and tested in combination.

And so on. The advantages of this approach are that, interface dispenses can be

easily found and corrected.

The major error that was faced during the project is linking error. When all

the modules are combined the link is not set properly with all support files. Then

we checked out for interconnection and the links. Errors are localized to the new

module and its intercommunications. The product development can be staged, and

modules integrated in as they complete unit testing. Testing is completed when the

last module is integrated and tested.

6.5 TESTING TECHNIQUES

6.5.1 WHITE BOX TESTING

This testing is also called as Glass box testing. In this testing, by knowing the

specific functions that a product has been design to perform test can be conducted

that demonstrate each function is fully operational at the same time searching for

errors in each function. It is a test case design method that uses the control

structure of the procedural design to derive test cases. Basis path testing is a white

box testing.

Basis path testing:

43
 Flow graph notation

 Cyclometric complexity

 Deriving test cases

 Graph matrices Control

6.5.2 BLACK BOX TESTING

In this testing by knowing the internal operation of a product, test can be

conducted to ensure that “all gears mesh”, that is the internal operation performs

according to specification and all internal components have been adequately

exercised. It fundamentally focuses on the functional requirements of the software.

The steps involved in black box test case design are:

 Graph based testing methods

 Equivalence partitioning

 Boundary value analysis

 Comparison testing

6.5.3 SOFTWARE TESTING STRATEGIES:

A software testing strategy provides a road map for the software developer.

Testing is a set activity that can be planned in advance and conducted

systematically. For this reason a template for software testing a set of steps which

44
we can place specific test case design methods should be strategy should have the

following characteristics:

 Testing begins at the module level and works “outward” toward the

integration of the entire computer based system.

 Different testing techniques are appropriate at different points in time.

 The developer of the software and an independent test group conduct testing.

 Testing and Debugging are different activities but debugging must be

accommodated in any testing strategy.

6.5.4. PROGRAM TESTING:

The logical and syntax errors have been pointed out by program testing. A

syntax error is an error in a program statement that in violates one or more rules of

the language in which it is written. An improperly defined field dimension or

omitted keywords are common syntax error. These errors are shown through error

messages generated by the computer. A logic error on the other hand deals with the

incorrect data fields, out-off-range items and invalid combinations. Since the

compiler s will not deduct logical error, the programmer must examine the output.

Condition testing exercises the logical conditions contained in a module. The

possible types of elements in a condition include a Boolean operator, Boolean

45
variable, a pair of Boolean parentheses A relational operator or on arithmetic

expression. Condition testing method focuses on testing each condition in the

program the purpose of condition test is to deduct not only errors in the condition

of a program but also other a errors in the program.

6.5.5 SECURITY TESTING:

Security testing attempts to verify the protection mechanisms built in to a

system well, in fact, protect it from improper penetration. The system security must

be tested for invulnerability from frontal attack must also be tested for in

vulnerability from rear attack. During security, the tester places the role of

individual who desires to penetrate system.

6.5.6 VALIDATION TESTING

At the culmination of integration testing, software is completely assembled

as a package. Interfacing errors have been uncovered and corrected and a final

series of software test-validation testing begins. Validation testing can be defined

in many ways, but a simple definition is that validation succeeds when the

software functions in manner that is reasonably expected by the customer.

Software validation is achieved through a series of black box tests that demonstrate

conformity with requirement. After validation test has been conducted, one of two.

46
conditions exists.

 The function or performance characteristics confirm to specifications

and are accepted

 A validation from specification is uncovered and a deficiency created.

 Deviation or errors discovered at this step in this project is corrected

prior to completion of the project with the help of the user by

negotiating to establish a method for resolving deficiencies.

 Thus the proposed system under consideration has been tested by using

validation testing and found to be working satisfactorily. Though there

were deficiencies in the system they were not catastrophic

6.5.7 USER ACCEPTANCE TESTING

User acceptance of the system is key factor for the success of any system. The

system under consideration is tested for user acceptance by constantly keeping in

touch with prospective system and user at the time of developing and making

changes whenever required. This is done in regarding to the following points.

 Input screen design.


 Output screen design

47
CHAPTER 7
CONCLUSION

This paper has proposed a real-time detection approach is based on improved


convolutional neural networks for apple and tomato leaf diseases. The deep-
learning-based approach can automatically extract the discriminative features of
the diseases apple images and detect the five common types of apple leaf diseases
with high accuracy in real time. In this study, to ensure satisfactory generalization
performance of the proposed model and a sufficient apple disease image dataset, a
total of 26,377 images with uniform and complex backgrounds were collected in
the laboratory and in a real apple field and generated via data augmentation
technology. Furthermore, the new deep convolution neural network model,
namely, INAR-SSD, was designed by introducing the GoogLeNet. Inception
module and integrating the Rainbow concatenation to enhance the multi-scale
disease object detection and small diseased object detection performances. And we
concentrate on identifying tomato leaf disease using deep convolutional neural
networks by transfer learning. The utilized networks are based on the pretrained
deep learning models of AlexNet, GoogLeNet, and ResNet. First we compared the
relative performance of these networks by using SGD and Adam optimization
method, revealing that the ResNet with SGD optimization method obtains the
highest result with the best accuracy, 96.51%. Then, the performance evaluation of
batch size and number of iterations affecting the transfer learning of the ResNet
was conducted. A small batch size of 16 combining a moderate number of
iterations of 4992 is the optimal choice in this work. Our findings suggest that, for
a particular task, neither large batch size nor large number of iterations may
improve the accuracy of the target model. The setting of batch size and number of
iterations depends on your data set and the utilized network. Next, the best
combined model was used to fine tune the structure. Fine-tuning ResNet layers
from 37 to “fc” obtained the highest accuracy 97.28% in identifying tomato leaf
disease. Based on the amount of available data, layer-wise fine-tuning may provide
a practical way to achieve the best performance of the application at hand. We
believe that the results obtained in this work will bring some inspiration to other
similar visual recognition problems, and the practical study of this work can be
easily extended to other plant leaf disease identification problems .

48
CHAPTER 8

FUTURE ENHANCEMENT

This paper also discussed some feature extraction and classification


techniques to extract the features of infected leaf and the classification of apple and
tomato diseases. And we also extract and classified the uninfected leaf of apple and
tomato to detect the healthy accuracy of the leaf. According to these studies,
convolution neural networks have been used extensively in the field of crop
disease identification and satisfactory results have been obtained. However, object
detection has not been applied to the real-time monitoring of apple and tomato leaf
diseases, which is of high practical value for agricultural applications. Therefore,
in our work, an object detection model for the detection of apple and tomato leaf
diseases is proposed. And we also proposed remedies for infected leaf . From these
methods, we can accurately identify and classify various plant diseases using deep
learning approach on improved convolution neural network.

49
APPENDIX 1

CODING

MASKING:

import cv2

import numpy as np

def image_masking(filepath):

BLUR = 21

CANNY_THRESH_1 = 10

CANNY_THRESH_2 = 200

MASK_DILATE_ITER = 10

MASK_ERODE_ITER = 10

MASK_COLOR = (0.0,0.0,0.0) # In BGR format

img = cv2.imread(filepath)

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

edges = cv2.Canny(gray, CANNY_THRESH_1, CANNY_THRESH_2)

edges = cv2.dilate(edges, None)

edges = cv2.erode(edges, None)


50
contour_info = []

contours, hierarchy = cv2.findContours(edges, cv2.RETR_LIST,


cv2.CHAIN_APPROX_NONE)

for c in contours:

contour_info.append((c, cv2.isContourConvex(c), cv2.contourArea(c),))

contour_info = sorted(contour_info, key=lambda c: c[2], reverse=True)

max_contour = contour_info[0]

mask = np.zeros(edges.shape)

cv2.fillConvexPoly(mask, max_contour[0], (255))

mask = cv2.dilate(mask, None, iterations=MASK_DILATE_ITER)

mask = cv2.erode(mask, None, iterations=MASK_ERODE_ITER)

mask = cv2.GaussianBlur(mask, (BLUR, BLUR), 0)

mask_stack = np.dstack([mask]*3)

mask_stack = mask_stack.astype('float32') / 255.0

img = img.astype('float32') / 255.0

masked = (mask_stack * img) + ((1-mask_stack) * MASK_COLOR)

masked = (masked * 255).astype('uint8')


51
fileName, fileExtension = filepath.split('.')

fileName += '-masked.'

filepath = fileName + fileExtension

print (filepath)

cv2.imwrite(filepath, masked)

if __name__ == '__main__':

#filepath =input("Enter Image File Name:\n")

#filepath='E:/LOKESH/Plant-Leaf-Disease-Detection-master/test1.jpg'

image_masking('E:/Python_19-20_Projects/Apple Leaf/Module -
1/testpicture/8.jpg')

TRAINING:

import cv2

import numpy as np

import os

from random import shuffle

from tqdm import tqdm

TRAIN_DIR = 'train/train'

TEST_DIR = 'test/test'

IMG_SIZE = 50

LR = 1e-3
52
MODEL_NAME = 'model/dwij28leafdiseasedetection-0.001-2conv-
basic.model.hdf5'

def label_img(img):

word_label = img[0]

if word_label == 'h': return [1,0,0,0]

elif word_label == 'b': return [0,1,0,0]

elif word_label == 'v': return [0,0,1,0]

elif word_label == 'l': return [0,0,0,1]

def create_train_data():

training_data = []

for img in tqdm(os.listdir(TRAIN_DIR)):

label = label_img(img)

path = os.path.join(TRAIN_DIR,img)

img = cv2.imread(path,cv2.IMREAD_COLOR)

img = cv2.resize(img, (IMG_SIZE,IMG_SIZE))

training_data.append([np.array(img),np.array(label)])

shuffle(training_data)

np.save('train_data.npy', training_data)
53
return training_data

def process_test_data():

testing_data = []

for img in tqdm(os.listdir(TEST_DIR)):

path = os.path.join(TEST_DIR,img)

img_num = img.split('.')[0]

img = cv2.imread(path,cv2.IMREAD_COLOR)

img = cv2.resize(img, (IMG_SIZE,IMG_SIZE))

testing_data.append([np.array(img), img_num])

shuffle(testing_data)

np.save('test_data.npy', testing_data)

return testing_data

train_data = create_train_data()

# If you have already created the dataset:

#train_data = np.load('train_data.npy')

import tflearn

from tflearn.layers.conv import conv_2d, max_pool_2d

from tflearn.layers.core import input_data, dropout, fully_connected

from tflearn.layers.estimator import regression


54
import tensorflow as tf

tf.reset_default_graph()

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)


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

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


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

model = tflearn.DNN(convnet, tensorboard_dir='log')

if os.path.exists('{}.meta'.format(MODEL_NAME)):

model.load(MODEL_NAME)

print('model loaded!')

train = train_data[:-500]

test = train_data[-500:]

X = np.array([i[0] for i in train]).reshape(-1,IMG_SIZE,IMG_SIZE,3)

Y = [i[1] for i in train]

test_x = np.array([i[0] for i in test]).reshape(-1,IMG_SIZE,IMG_SIZE,3)

test_y = [i[1] for i in test]

model.fit({'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)

56
model.save(MODEL_NAME)

TESTING:

import tkinter as tk

from tkinter.filedialog import askopenfilename

import shutil

import os

import sys

from PIL import Image, ImageTk

window = tk.Tk()

window.title("Dr. Plant")

window.geometry("500x510")

window.configure(background ="lightgreen")

title = tk.Label(text="Click below to choose picture for testing disease....",


background = "lightgreen", fg="Brown", font=("", 15))

title.grid()

def bact():

window.destroy()

window1 = tk.Tk()
57
window1.title("Dr. Plant")

window1.geometry("500x510")

window1.configure(background="lightgreen")

def exit():

window1.destroy()

rem = "The remedies for Bacterial Spot are:\n\n "

remedies = tk.Label(text=rem, background="lightgreen",

fg="Brown", font=("", 15))

remedies.grid(column=0, row=7, padx=10, pady=10)

rem1 = " Discard or destroy any affected plants. \n Do not compost them. \n
Rotate yoour tomato plants yearly to prevent re-infection next year. \n Use copper
fungicites"

remedies1 = tk.Label(text=rem1, background="lightgreen",

fg="Black", font=("", 12))

remedies1.grid(column=0, row=8, padx=10, pady=10)

0 button = tk.Button(text="Exit", command=exit)

button.grid(column=0, row=9, padx=20, pady=20)

window1.mainloop()

def vir():

window.destroy()

58
window1 = tk.Tk()

window1.title("Dr. Plant")

window1.geometry("650x510")

window1.configure(background="lightgreen")

def exit():

window1.destroy()

rem = "The remedies for Yellow leaf curl virus are: "

remedies = tk.Label(text=rem, background="lightgreen",

fg="Brown", font=("", 15))

remedies.grid(column=0, row=7, padx=10, pady=10)

rem1 = " Monitor the field, handpick diseased plants and bury them. \n Use
sticky yellow plastic traps. \n Spray insecticides such as organophosphates,
carbametes during the seedliing stage. \n Use copper fungicites"

remedies1 = tk.Label(text=rem1, background="lightgreen",

fg="Black", font=("", 12))

remedies1.grid(column=0, row=8, padx=10, pady=10)

button = tk.Button(text="Exit", command=exit)

button.grid(column=0, row=9, padx=20, pady=20)

window1.mainloop()

59
def latebl():

window.destroy()

window1 = tk.Tk()

window1.title("Dr. Plant")

window1.geometry("520x510")

window1.configure(background="lightgreen")

def exit():

window1.destroy()

rem = "The remedies for Late Blight are: "

remedies = tk.Label(text=rem, background="lightgreen",

fg="Brown", font=("", 15))

remedies.grid(column=0, row=7, padx=10, pady=10)

rem1 = " Monitor the field, remove and destroy infected leaves. \n Treat
organically with copper spray. \n Use chemical fungicides,the best of which for
tomatoes is chlorothalonil."

remedies1 = tk.Label(text=rem1, background="lightgreen",

fg="Black", font=("", 12))

remedies1.grid(column=0, row=8, padx=10, pady=10)

button = tk.Button(text="Exit", command=exit)

button.grid(column=0, row=9, padx=20, pady=20)

window1.mainloop()

60
def analysis():

import cv2

import numpy as np

import os

from random import shuffle

from tqdm import \

tqdm

verify_dir = 'testpicture'

IMG_SIZE = 50

LR = 1e-3

MODEL_NAME = 'model/dwij28leafdiseasedetection-0.001-2conv-
basic.model.hdf5'

def process_verify_data():

verifying_data = []

for img in tqdm(os.listdir(verify_dir)):

path = os.path.join(verify_dir, img)

img_num = img.split('.')[0]

img = cv2.imread(path, cv2.IMREAD_COLOR)

img = cv2.resize(img, (IMG_SIZE, IMG_SIZE))

verifying_data.append([np.array(img), img_num])

np.save('verify_data.npy', verifying_data)
61
return verifying_data

verify_data = process_verify_data()

import tflearn

from tflearn.layers.conv import conv_2d, max_pool_2d

from tflearn.layers.core import input_data, dropout, fully_connected

from tflearn.layers.estimator import regression

import tensorflow as tf

tf.reset_default_graph()

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


62
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 = tflearn.DNN(convnet, tensorboard_dir='log')

if os.path.exists('{}.meta'.format(MODEL_NAME)):

model.load(MODEL_NAME)

print('model loaded!')

import matplotlib.pyplot as plt

fig = plt.figure()

for num, data in enumerate(verify_data):

img_num = data[1]

img_data = data[0]
63
y = fig.add_subplot(3, 4, num + 1)

orig = img_data

data = img_data.reshape(IMG_SIZE, IMG_SIZE, 3)

model_out = model.predict([data])[0]

if np.argmax(model_out) == 0:

str_label = 'healthy'

elif np.argmax(model_out) == 1:

str_label = 'bacterial'

elif np.argmax(model_out) == 2:

str_label = 'viral'

elif np.argmax(model_out) == 3:

str_label = 'lateblight'

if str_label =='healthy':

status ="HEALTHY"

else:

status = "UNHEALTHY"

message = tk.Label(text='Status: '+status, background="lightgreen",

fg="Brown", font=("", 15))

message.grid(column=0, row=3, padx=10, pady=10)

64
if str_label == 'bacterial':

diseasename = "Bacterial Spot "

disease = tk.Label(text='Disease Name: ' + diseasename,


background="lightgreen",

fg="Black", font=("", 15))

disease.grid(column=0, row=4, padx=10, pady=10)

r = tk.Label(text='Click below for remedies...', background="lightgreen",


fg="Brown", font=("", 15))

r.grid(column=0, row=5, padx=10, pady=10)

button3 = tk.Button(text="Remedies", command=bact)

button3.grid(column=0, row=6, padx=10, pady=10)

elif str_label == 'viral':

diseasename = "Yellow leaf curl virus "

disease = tk.Label(text='Disease Name: ' + diseasename,


background="lightgreen",

fg="Black", font=("", 15))

disease.grid(column=0, row=4, padx=10, pady=10)

r = tk.Label(text='Click below for remedies...', background="lightgreen",


fg="Brown", font=("", 15))

r.grid(column=0, row=5, padx=10, pady=10)

button3 = tk.Button(text="Remedies", command=vir)

button3.grid(column=0, row=6, padx=10, pady=10)

elif str_label == 'lateblight':


65
diseasename = "Late Blight "

disease = tk.Label(text='Disease Name: ' + diseasename,


background="lightgreen",

fg="Black", font=("", 15))

disease.grid(column=0, row=4, padx=10, pady=10)

r = tk.Label(text='Click below for remedies...', background="lightgreen",


fg="Brown", font=("", 15))

r.grid(column=0, row=5, padx=10, pady=10)

button3 = tk.Button(text="Remedies", command=latebl)

button3.grid(column=0, row=6, padx=10, pady=10)

else:

r = tk.Label(text='Plant is healthy', background="lightgreen", fg="Black",

font=("", 15))

r.grid(column=0, row=4, padx=10, pady=10)

button = tk.Button(text="Exit", command=exit)

button.grid(column=0, row=9, padx=20, pady=20)

def openphoto():

dirPath = "testpicture"

fileList = os.listdir(dirPath)

for fileName in fileList:

os.remove(dirPath + "/" + fileName)


66
fileName = askopenfilename(initialdir=r'E:\Project\Full\Real-Time Detection of
Apple Leaf Diseases Using CNN\testpicture', title='Select image for analysis ',

filetypes=[('image files', '.jpg')])

dst = r"E:\Project\Full\Real-Time Detection of Apple Leaf Diseases Using


CNN\testpicture"

shutil.copy(fileName, dst)

load = Image.open(fileName)

render = ImageTk.PhotoImage(load)

img = tk.Label(image=render, height="250", width="500")

img.image = render

img.place(x=0, y=0)

img.grid(column=0, row=1, padx=10, pady = 10)

title.destroy()

button1.destroy()

button2 = tk.Button(text="Analyse Image", command=analysis)

button2.grid(column=0, row=2, padx=10, pady = 10)

button1 = tk.Button(text="Get Photo", command = openphoto)

button1.grid(column=0, row=1, padx=10, pady = 10)

window.mainloop()

67
APPENDIX 2

EXPERIMENTAL RESUL
RESULT

A.2.1UNMASKED IMAGE

(a) Tomato Leaf Unmasked Image (b) Apple Leaf Unmasked Image

A.2.2 MASKED IMAGE:

(a) Tomato Leaf Masked Image (b) Apple Leaf Masked Image

68
A.2.3.TRAINING :

(I)

(II)

69
A.2.4 TESTING

A.2.4.1 TESTING TOMATO LEAF

(I)

(II)

70
(III)

(IV)

71
A.2.4.2 TESTING APPLE LEAF:

(I)

(II)

72
(III)

(IV)

73
REFERENCES

[1] H.Lu et al. (2019). ``CONet: A cognitive ocean network.'' [Online].

[2] Chunxe Wu, C. Luo, N. Xiong, W. Zhang, and T. Kim, ``A greedy deep

learning method for medical disease analysis,'' IEEE Access, vol. 6.(2018).

[3] H. Lu, Y. Li, M. Chen, H. Kim, and S. Serikawa, ``Brain intelligence:

Go beyond articial intelligence,'' Mobile Netw. Appl., vol. 23, no. 2,

pp. 368375, Apr. 2018.

[4] J. Li, N.Wang, Z.-H.Wang, H. Li, C.-C. Chang, and H.Wang, ``New secret

sharing scheme based on faster R-CNNs image retrieval,'' IEEE Access, vol. 6, pp.

4934849357, 2018.

[5] A. Caglayan and A. B. Can, ``Volumetric object recognition using 3-D CNNs

on depth data,'' IEEE Access, vol. 6, pp. 2005820066, 2018.

[6] H. Lu, Y. Li, T. Uemura, H. Kim, and S. Serikawa, ``Low illumination

underwater light field images reconstruction using deep convolutional neural

networks,'' Future Gener. Comput. Syst., vol. 82, pp. 142148, May 2018.

[7]X. Zhang, Y. Qiao, F. Meng, C. Fan, and M. Zhang, ``Identication of maize leaf

diseases using improved deep convolutional neural networks,'' IEEE Access, vol.

6, pp. 3037030377, 2018.

74
[8] M. Kulin, T. Kazaz, I. Moerman, and E. De Poorter, ``End-to-end learning

from spectrum data: A deep learning approach for wireless signal identification in

spectrum monitoring applications,'' IEEE Access, vol. 6, pp. 1848418501, 2018.

75

You might also like