Project Documentation
Project Documentation
Project Documentation
A PROJECT REPORT
Submitted by
ARMSTERDAM.J (312116104010)
MOHAN.SR (312116104028)
TAARIQ DAWOOD BUHARI .SA (312116104046)
of
BACHELOR OF ENGINEERING
in
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
ii
ACKNOWLEDGEMENT
the almighty, the combined efforts made by us and the contribution made in one
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
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
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
Based on this, a new apple leaf and tomato disease detection model that uses deep-
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
iv
TABLE OF CONTENTS
ABSTRACT Iv
LIST OF FIGURES Ix
LIST OF ABBREVATIONS X
1 INTRODUCTION 1
1.1 INTRODUCTION 1
NETWORK
PROCESS
2 LITERATURE SURVEY 10
3 SYSTEM DESIGN 15
3.3 MODULES 15
NETWORK
PRESPECTIVE
3.4.1.4 TRAINING 22
4 REQUIREMENTS SPECIFICATION 28
CONSTRAINTS
5.1.3 CONSTRAINTS IN 30
IMPLEMENTATION
6 TESTING SPECIFICATION 37
6.1 TESTING 37
STANDARD
7 CONCLUSION 48
8 FUTURE ENHACEMENT 49
APPENDIX 1 CODING 50
REFERENCES 74
viii
LIST OF FIGURES
A.2.3 Training 69
A.2.4 Testing 70
ix
LIST OF ABBREVATIONS
ABBREVIATION EXPANSION
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.
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
It was initially designed by Guido van Rossum in 1991 and developed by Python
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
It is used for:
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.
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
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.
Neurons
Nodes
Input
Output
7
NEURON
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.
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
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
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.
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.
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.
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.
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.
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.
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.
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
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
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.
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
that integrity level, then the hardware must be at least of the same integrity
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
highest level of integrity required must be applied to all systems in the same
environment.
29
CHAPTER 5
5.1.2CONSTRAINTS IN DESIGN
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:
Fig:5.2.2
32
5.2.3 USE CASE DIAGRAM:
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.
33
Fig:5.2.3
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:
between software objects. They require use cases, system operation contracts and
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.
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
Naming conventions
Value conventions
37
Message box format
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
CLASS NAMES
Class names are problem domain equivalence and begin with capital letter
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.
Value conventions ensure values for variable at any point of time. This
38
involves the following:
Comments are included to minimize the number of surprises that could occur when
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
Testing checks for the errors, as a whole of the project testing involves the
code.
40
software design (i.e.), the module. The white-box testing techniques were heavily
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.
Performance Test
Stress Test
Structure 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 .
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.
independent paths within a module have been have been exercised at least once.
Execute all loops at their boundaries and within their operational bounds.
Handling end of file condition, I/O errors, buffer problems and textual errors
in output information
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
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
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
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.
43
Flow graph notation
Cyclometric complexity
conducted to ensure that “all gears mesh”, that is the internal operation performs
Equivalence partitioning
Comparison testing
A software testing strategy provides a road map for the software developer.
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
The developer of the software and an independent test group conduct 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
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.
45
variable, a pair of Boolean parentheses A relational operator or on arithmetic
program the purpose of condition test is to deduct not only errors in the condition
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
as a package. Interfacing errors have been uncovered and corrected and a final
in many ways, but a simple definition is that validation succeeds when the
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.
Thus the proposed system under consideration has been tested by using
User acceptance of the system is key factor for the success of any system. The
touch with prospective system and user at the time of developing and making
47
CHAPTER 7
CONCLUSION
48
CHAPTER 8
FUTURE ENHANCEMENT
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
img = cv2.imread(filepath)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
for c in contours:
max_contour = contour_info[0]
mask = np.zeros(edges.shape)
mask_stack = np.dstack([mask]*3)
fileName += '-masked.'
print (filepath)
cv2.imwrite(filepath, masked)
if __name__ == '__main__':
#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
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]
def create_train_data():
training_data = []
label = label_img(img)
path = os.path.join(TRAIN_DIR,img)
img = cv2.imread(path,cv2.IMREAD_COLOR)
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 = []
path = os.path.join(TEST_DIR,img)
img_num = img.split('.')[0]
img = cv2.imread(path,cv2.IMREAD_COLOR)
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()
#train_data = np.load('train_data.npy')
import tflearn
tf.reset_default_graph()
convnet = max_pool_2d(convnet, 3)
convnet = max_pool_2d(convnet, 3)
convnet = max_pool_2d(convnet, 3)
convnet = max_pool_2d(convnet, 3)
convnet = max_pool_2d(convnet, 3)
if os.path.exists('{}.meta'.format(MODEL_NAME)):
model.load(MODEL_NAME)
print('model loaded!')
train = train_data[:-500]
test = train_data[-500:]
56
model.save(MODEL_NAME)
TESTING:
import tkinter as tk
import shutil
import os
import sys
window = tk.Tk()
window.title("Dr. Plant")
window.geometry("500x510")
window.configure(background ="lightgreen")
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()
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"
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: "
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"
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()
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."
window1.mainloop()
60
def analysis():
import cv2
import numpy as np
import os
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 = []
img_num = img.split('.')[0]
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
import tensorflow as tf
tf.reset_default_graph()
convnet = max_pool_2d(convnet, 3)
convnet = max_pool_2d(convnet, 3)
convnet = max_pool_2d(convnet, 3)
convnet = max_pool_2d(convnet, 3)
if os.path.exists('{}.meta'.format(MODEL_NAME)):
model.load(MODEL_NAME)
print('model loaded!')
fig = plt.figure()
img_num = data[1]
img_data = data[0]
63
y = fig.add_subplot(3, 4, num + 1)
orig = img_data
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"
64
if str_label == 'bacterial':
else:
font=("", 15))
def openphoto():
dirPath = "testpicture"
fileList = os.listdir(dirPath)
shutil.copy(fileName, dst)
load = Image.open(fileName)
render = ImageTk.PhotoImage(load)
img.image = render
img.place(x=0, y=0)
title.destroy()
button1.destroy()
window.mainloop()
67
APPENDIX 2
EXPERIMENTAL RESUL
RESULT
A.2.1UNMASKED IMAGE
(a) Tomato Leaf Unmasked Image (b) Apple Leaf Unmasked Image
(a) Tomato Leaf Masked Image (b) Apple Leaf Masked Image
68
A.2.3.TRAINING :
(I)
(II)
69
A.2.4 TESTING
(I)
(II)
70
(III)
(IV)
71
A.2.4.2 TESTING APPLE LEAF:
(I)
(II)
72
(III)
(IV)
73
REFERENCES
[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).
[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
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.
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
75