You are on page 1of 55

Plant Diseases Detection and

Finding Solution

A PROJECT REPORT

Submitted by

RAGULRAJKUMAR S (951518104046 )

VISHVA S (951518104073)

YOGESHWARAN G (951518104075)

In partial fulfillment for the award of the degree

Of
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE AND ENGINEERING
KALASALINGAM INSTITUTE OF TECHNOLOGY

ANNA UNIVERSITY :: CHENNAI 600 025


March 202

1
BONAFIDE CERTIFICATE

Certified that this project report “PLANT DISEASE DETECTION


AND FINDING SOLUTION”is the bonafide work of
“RAGULRAJKUMAR S(951518104046)”, “VISHVA
S(951518104073)”, “YOGESHWARAN G(951518104075)”.

SIGNATURE SIGNATURE

Mrs.P.Packiya Lakshmi M.E., Mrs.G.Sumathi M.E.,

HEAD OF THE DEPARTMENT SUPERVISOR

Professor, Assistant Professor,

Department of CSE, Department of CSE,

Kalasalingam Institute of Kalasalingam Institute of

Technology, Technology,

Anand Nagar, Krishnankoil Anand Nagar,Krishnankoil

626 126 626 126

Submitted for the Project Viva-Voice held on………………..

Internal Examiner External Examiner

2
ACKNOWLEDGEMENT

I express my sincere thanks to our respected Secretary Ilayavallal,Thiru.

D.K.Sridharan M.Com., M.B.A.,M.Phil.,Ph.D., for providing more facilities, to do

this project work.

A deep bouquet of thanks to respected Principal Dr. S.Harikrishnan, M.E., Ph.D,

for having provided the facilities required for my project.

I sincerely thank Mrs.P.Packiya Lakshmi,M.E.., Professor and Head, Department

of Computer Science and Engineering, Kalasalingam Institute of Technology and Project

Coordinator Mrs.P.Packiya Lakshmi,M.E.., Professor, Department of Computer

Science and Engineering who inspired me and gave me time to make this project to work

a grand success.

I also thank my guide Mrs.G.Sumathi M.E., Assistant Professor, Department of

Computer Science and Engineering for his valuable guidance throughout and it is great

privilege to express my gratitude to her.

I extend my heartfelt thanks and profound gratitude to all the faculty members of

my department for their kind help during my project work.

Finally I express my sincere thanks to my parent, who have constantly encouraged

me and for being the source of encouraging spirits throughout my course.

3
ABSTRACT

Identification and early prevention of plant diseases are important for


improving the production of crops. And also if the plant diseases cross the early
stage we provide a solution for the disease that the plant has. Previously there are
other projects created to detect the diseases that a plant has and they were based
on agriculture crops and this project is based on both agriculture crops and
gardening plants. An application for finding disease of a plant based on the leaf
images of the plant, and giving solution for it based on the disease that the plant
has, we used a dataset with 16000 images of the tomato leaf,it has 10 different of
classes of images, Convolutional Autoencoder (CAE) network and Convolutional
Neural Network(CNN) have been used to automatically detect the plant diseases.
It is a hybrid model, this model will detect the Bacterial spot diseases present in
the peach plant using images of plant leaves. In this experiment , The hybrid
model requires lesser number of training parameters as compared with other
models.

4
LISTOFCONTENTS

S.NO CONTENT PAGE.NO

ABSTRACT 4

LIST OF FIGURES 8

LIST OF ABBREVIATION 8

1. INTRODUCTION 9
2. SYSTEM PROPOSAL 10

2.1. Existing System


2.2. Proposed System
2.3. Literature Survey
3. SYSTEM DIAGRAMS 16
3.1. Architecture Diagram
3.2. Flow Diagram
1.3. UML Diagrams
4. IMPLEMENTATION 19
4.1. Modules
4.2. Modules Description
5. SYSTEM REQUIREMENTS 21
5.1. Hardware Requirements

5
5.2. Software Requirements
5.3. Software Description
5.4. Feasibility Study
6. TESTING OF PRODUCTS 27
6.1. Unit Testing
6.1.1. Functional Testing

6.1.2. Performance Testing

6.1.3. Stress Testing

6.1.4. Structured Testing

6.2. System Testing

6.3. Integration Testing

6.3.1. Bottom Up

6.3.2. Top Down

6.4. Black box Testing

6.5. White box Testing

7. CONCLUSION AND FUTURE 33


ENHANCEMENT
7.1. Conclusion

6
7.2. Future Enhancement
8. SAMPLE CODING AND SAMPLE 34
SCREENSHOT
9. REFERENCES 54

7
LIST OF FIGURES

Figure No. Caption Page No.

3.1 Architecture Diagram 16

3.2 Flow Diagram 16

3.3.1 Use Case Diagram 17

3.3.2 Sequence Diagram 17

3.3.3 Activity Diagram 18

3.3.4 Class Diagram 18

LIST OF ABBREVIATIONS

TITLE EXPANSION

OS Operating System
CAE Convolutional Auto Encoder
CNN Convolutional Neural Network

8
CHAPTER 1
INTRODUCTION

Leaves being the most sensitive part of plants show disease symptoms at the
earliest. The crops need to be monitored against diseases from the very first stage
of their life-cycle to the time they are ready to be harvested. Initially, the method
used to monitor the plants from diseases was the traditional naked eye
observation that is a time-consuming technique which requires experts to
manually monitor the crop fields. In the recent years, a number of techniques
have been applied to develop automatic and semi-automatic plant disease
detection systems and automatic detection of the diseases by just seeing the
symptoms on the plant leaves makes it easier as well as cheaper. These systems
have so far resulted to be fast, inexpensive and more accurate than the
traditional method of manual observation by farmers In most of the cases disease
symptoms are seen on the leaves, stem and fruit. The plant leaf for the
detection of disease is considered which shows the disease symptoms. There are
many cases where farmers do not have a fully compact knowledge about the crops
and the disease that can get affected to the crops. This project can be effectively
used by farmers thereby increasing the yield rather than visiting the expert and
getting their advice. The main objective is not only to detect the disease using
image processing technologies. A feature-based approach is proposed here which
tries to overcome the limitations of previous work in terms of accuracy and
portability and the essence of the research lies in provision of high accuracy and
portability to mobile devices. . Convolutional Autoencoder (CAE) network and
Convolutional Neural Network(CNN) have been used to automatically detect the
plant diseases. It is a hybrid model, this model will detect the Bacterial spot
diseases present in the peach plant using images of plant leaves.

9
CHAPTER 2
SYSTEM PROPOSAL

2.1 Existing System

Plant disease detection using hybrid model based on convolutional


autoencoder and convolutional neural network by Punam Bedi and Pushkar Gole
have used the the same algorithm that we used in our project , it has 99.35%
training accuracy and 98.38% testing accuracy

Disadvantages

 That project meant to detect and classify plant images healthy


or unhealthy based
on the Leaf spots in the images.
2.2 Proposed System

The proposed model is introduced to overcome disadvantage that arise in the


existing system. in the existed project output for the given input will be the name
of the disease that plant have ,but in this project in addition a solution for the
disease will be given too. It enhances the performance of the overall classification
results.
Advantages

 Multi-class classification- classify into 9 different diseases in


plant and 1 healthy plant
 Giving solution based on the disease the plant has.
2.3 Literature Survey

10
1. Title: A hybrid deep learning-based fruit classification using attention
model and convolution autoencoder

Year: 2020

Author: Gang Xue,Shifeng Liu,Yicao Ma

In this paper, they developed a hybrid deep learning-based fruit image


classification framework, named attention-based densely connected convolutional
networks with convolution autoencoder (CAE-ADN), which uses a convolution
autoencoder to pre-train the images and uses an attention-based DenseNet to
extract the features of image. In the first part of the framework, an unsupervised
method with a set of images is applied to pre-train the greedy layer-wised CAE.
We use CAE structure to initialize a set of weights and bias of ADN. In the second
part of the framework, the supervised ADN with the ground truth is implemented.

In this work, an attention-based densely connected convolutional network with


convolution autoencoder (CAE-ADN) framework is developed, which uses a
convolution autoencoder to pre-train the attention-based densely connected
convolutional networks, In the first part of the framework, an unsupervised method
with a set of images is applied to pre-train the greedy layer-wised CAE. We use
CAE structure to initialize a set of weights and bias of ADN. In the second part of
the framework, the supervised ADN with the ground truth is implemented. The
final part of the framework makes a prediction of the category of fruits.

In this work, they developed a hybrid deep learning-based fruit image


classification approach, which uses a convolution autoencoder to pre-train the
images and uses an attentionbased DenseNet to extract the features of image. In the
first part of the framework, an unsupervised method with a set of images is applied
to pre-train the greedy layer-wised CAE. We use the CAE structure to initialize a

11
set of weights and bias of ADN. In the second part of the framework, the
supervised ADN with the ground truth is implemented. The final part of the
framework makes a prediction of the category of fruit.

2. Title: Tomato Leaf Diseases Detection Using Deep Learning Technique

Year: 2021

Author: Muhammad E.H. Chowdhury, Tawsifur Rahman,Amith Khandakar,

Nabil Ibtehaz,Aftab Ullah Khan, Muhammad Salman Khan, Nasser Al-


Emadi,

Mamun Bin Ibne Reaz, Mohammad Tariqul Islam , Sawal Hamid Md. Ali

In this study, they have extensively studied the performance of the different
state-of-the-art convolutional neural networks (CNNs) classification network
architectures i.e. ResNet18, MobileNet, DenseNet201, and InceptionV3 on 18,162
plain tomato leaf images to classify tomato diseases. The comparative performance
of the models for the binary classification (healthy and unhealthy leaves), six-class
classification (healthy and various groups of diseased leaves), and ten-class
classification (healthy and various types of unhealthy leaves) are also reported.

This research investigated how different CNNbased architectures perform on


classification of tomato leaf images. The study was divided into 3 sub-studies of 2
class classification (Healthy, and Unhealthy), 6 class classification (Healthy,
Fungi, Bacteria, Mold, Virus, and Mite), and 10 class classification (Healthy, Early
blight, Septoria leaf spot, Target spot, Leaf mold, Bacterial spot, Late bright mold,

12
Tomato Yellow Leaf Curl Virus, Tomato Mosaic Virus, and Two-spotted spider
mite).

3. Title: Plant disease detection using hybrid model based on


convolutional autoencoder and

convolutional neural network

Year: 2021

Author: Punam Bedi, Pushkar Gole

This paper proposes a novel hybrid model based on Convolutional


Autoencoder (CAE) network and Convolutional Neural Network (CNN) for
automatic plant disease detection. To the best of our knowledge, a hybrid system
based on CAE and CNN to detect plant diseases automatically has not been
proposed in any state-ofthe-art systems present in the literature. In this work, the
proposed hybrid model is applied to detect Bacterial Spot disease present in peach
plants using their leaf images.

This paper proposes a novel hybrid model for automatic plant disease detection
based on CAE and CNN with fewer training parameters as compared to other state-
of-the-art systems present in the literature. Although there are various techniques
present in the literature used for automatic plant disease detection, but a hybrid
system of CAE combined with a CNN has not been proposed until now in any
existing research work to the best of our knowledge. Dimensionality reduction
using CAE in the proposed model results in reduction of number of training
parameters of the model.

13
. In this paper, a novel hybrid model was proposed for automatic plant disease
detection that was based on two Deep Learning techniques named Convolutional
Autoencoder (CAE) network and Convolutional Neural Network (CNN). The
proposed hybrid model first obtained compressed domain representations of leaf
images using the encoder network of CAE and then used the compressed domain
representations for classification using CNN. Due to dimensionality reduction
using CAE, the number of features, and hence the number of training parameters
reduced significantly as compared to existing state-of-the-art systems.

4. Title: Image based Plant leaf disease detection using Deep learning

Year: 2021

Author: S. Poornam,A. Francis Saviour Devaraj

The proposed methodology consists of collection of Plant leaf dataset, Image


preprocessing, Image Augmentation and Neural network training. The dataset is
collected from ImageNet for training phase. The CNN technique is used to
differentiate the healthy leaf from disease affected leaf. In image preprocessing
resizing the image is carried out to reduce the training phase time. Image
augmentation is performed in training phase by applying various transformation
function on Plant images. The Network is trained by Caffenet deep learning
framework. CNN is trained with ReLu (Rectified Linear Unit).

Image Preprocess – During learning process the image preprocesses with high
resolution and it selects the Region of Interest which differentiates the leaf images
from its surroundings. The image size changed to decrease the training time. Image
Augmentation – Image augmentation used for increase the dataset and the network

14
can able to learn more features from image during training phase. The various
transformations applied on training dataset to increase the dataset. The affine
transformation and perspective transformation applied, this function performs
rotations of image on different axis by various degrees. Pretrained model-The
CNN pretrained on Image Net dataset. When pretrained model used the new
classifier can be added related to leaf disease classification rather than original
classifiers.

15
CHAPTER 3
SYSTEM DIAGRAMS

3.1. ARCHITECTURE DIAGRAM

3.2. FLOW DIAGRAM

16
3.3.UML Diagram

3.3.1. USECASE DIAGRAM

3.3.2. SEQUENCE DIAGRAM

17
3.3.3. ACTIVITY DIAGRAM

3.3.4. CLASS DIAGRAM

18
CHAPTER 4
IMPLEMENTATIONS

4.1. Modules

Dataset collection
Pre-training using CAE
Dimensionality reduction using CAE
Disease identification using CNN
4.2. Module Description

Dataset collection:

I collected tomato leaf images from a dataset named PlantVillage to


get the leaf images of peach plants. It has collection of different tomato diseases
and a healthy tomato leaf
Images , except the healthy Leaf there’s 9 more different Collection of different
tomato disease images.
Pre-training using CAE:

The collected data set has been passed through a model which has
CAE encoder and decoder, this model several layers in it, using this model the data
set that we have will be pre-trained time before getting to the CNN.

Dimensionality reduction using CAE:

After the pre-training stage the CAE encoder alone work to reduce the
dimensionality of the images that we have in our dataset, Here image will be
compressed into small, not compressing the size but compressing the pixel values
of the images.

19
Disease identification using CNN:

After the dimensionality reduction , we connect the encoder of CAE


with the neural network layers(CNN), once again this combination (hybrid model)
of model will be trained again with the already trained images, after all the process
we can classify the disease and give the solution for it.

20
CHAPTER 5
SYSTEM REQUIREMENTS

5.1. Hardware Requirement

 System : Pentium IV 2.4 GHz

 Hard Disk :200 GB

 Mouse : Logitech.

 Keyboard : 110 keys enhanced

 Ram : 8GB

5.2. Software Requirement

 O/S : Windows 7

 Language :Python

 Front End: Anaconda Navigator - Spyder

5.3. Software Description

Python

Python is one of those rare languages which can claim to be both simple and
powerful. You will find yourself pleasantly surprised to see how easy it is to
concentrate on the solution to the problem rather than the syntax and structure of
the language you are programming in. The official introduction to Python is
Python is an easy to learn, powerful programming language. It has efficient high-

21
level data structures and a simple but effective approach to object-oriented
programming. Python's elegant syntax and dynamic typing, together with its
interpreted nature, make it an ideal language for scripting and rapid application
development in many areas on most platforms. I will discuss most of these features
in more detail in the next section.

Features of

Python Simple

Python is a simple and minimalistic language. Reading a good Python


program feels almost like reading English, although very strict English! This
pseudo-code nature of Python is one of its greatest strengths. It allows you to
concentrate on the solution to the problem rather than the language itself.

Easy to Learn

As you will see, Python is extremely easy to get started with. Python has an
extraordinarily simple syntax, as already mentioned.

Free and Open Source

Python is an example of a FLOSS (Free/Libré and Open Source Software).


In simple terms, you can freely distribute copies of this software, read its source
code, make changes to it, and use pieces of it in new free programs. FLOSS is
based on the concept of a community which shares knowledge. This is one of the
reasons why Python is so good - it has been created and is constantly improved by
a community who just want to see a better Python.

22
High-level Language

When you write programs in Python, you never need to bother about the
low-level details such as managing the memory used by your program, etc.

Portable

Due to its open-source nature, Python has been ported to (i.e. changed to
make it work on) many platforms. All your Python programs can work on any of
these platforms without requiring any changes at all if you are careful enough to
avoid any system-dependent features.

You can use Python on GNU/Linux, Windows, FreeBSD, Macintosh, Solaris,


OS/2, Amiga, AROS, AS/400, BeOS, OS/390, and # -*- coding: utf-8 -*-

z/OS, Palm OS, QNX, VMS, Psion, Acorn RISC OS, VxWorks, PlayStation,
Sharp Zaurus, Windows CE and PocketPC!

You can even use a platform like Kivyto create games for your computer and for
iPhone, iPad, and Android.

Interpreted

This requires a bit of explanation.

A program written in a compiled language like C or C++ is converted from


the source language i.e. C or C++ into a language that is spoken by your computer
(binary code i.e. 0s and 1s) using a compiler with various flags and options. When
you run the program, the linker/loader software copies the program from hard disk
to memory and starts running it.

Python, on the other hand, does not need compilation to binary. You just run
the program directly from the source code. Internally, Python converts the source

23
code into an intermediate form called byte codes and then translates this into the
native language of your computer and then runs it. All this, actually, makes using
Python much easier since you don't have to worry about compiling the program,
making sure that the proper libraries are linked and loaded, etc. This also makes
your Python programs much more portable, since you can just copy your Python
program onto another computer and it just works!

Object Oriented

Python supports procedure-oriented programming as well as object-oriented


programming. In procedure-oriented languages, the program is built around
procedures or functions which are nothing but reusable pieces of programs. In
object-oriented languages, the program is built around objects which combine data
and functionality. Python has a very powerful but simplistic way of doing OOP,
especially when compared to big languages like C++ or Java.

Extensible

If you need a critical piece of code to run very fast or want to have some
piece of algorithm not to be open, you can code that part of your program in C or
C++ and then use it from your Python program.

Embeddable

You can embed Python within your C/C++ programs to give scripting
capabilities for your program's users.

Extensive Libraries

The Python Standard Library is huge indeed. It can help you do various
things involving regular expressions, documentation generation, unit testing,

24
threading, databases, web browsers, CGI, FTP, email, XML, XML-RPC, HTML,
WAV files, cryptography, GUI (graphical user interfaces), and other system-
dependent stuff. Remember, all this is always available wherever Python is
installed. This is called the Batteries Included philosophy of Python.

Besides the standard library, there are various other high-quality libraries which
you can find at the Python Package Index.

5.4. FEASIBILITY STUDY

The feasibility study is carried out to test whether the proposed system is
worth being implemented. The proposed system will be selected if it is best enough
in meeting the performance requirements.

The feasibility carried out mainly in three sections namely.

• Economic Feasibility

• Technical Feasibility

• Behavioural Feasibility

Economic Feasibility

Economic analysis is the most frequently used method for evaluating


effectiveness of the proposed system. More commonly known as cost benefit
analysis. This procedure determines the benefits and saving that are expected from
the system of the proposed system. The hardware in system department if
sufficient for system development.

Technical Feasibility

25
This study centre around the system’s department hardware, software and to
what extend it can support the proposed system department is having the required
hardware and software there is no question of increasing the cost of implementing
the proposed system. The criteria, the proposed system is technically feasible
and the proposed system can be developed with the existing facility.

Behavioural Feasibility

People are inherently resistant to change and need sufficient amount of


training, which would result in lot of expenditure for the organization. The
proposed system can generate reports with day-to-day information immediately at
the user’s request, instead of getting a report, which doesn’t contain much detail.

26
CHAPTER 6
TESTING OF PRODUCTS

The most important phase in Software development life cycle is System testing.
The number and nature of errorsin a newly designed system depends on the system
specification and the time frame given for the design.

A newly designed system should have all the subsystems working


together, but in reality each subsystems work independently. During this phase, all
the subsystems are gathered into one pool and tested to determine whether it meets
the user requirements.

Testing is done at two levels – testing of individual modules and


testing the entire system. During the system testing, the system is used
experimentally to ensure that the software will run according to the specifications
and in the way the user expects. Each test case is designed with the intent of
finding errors in the way the system will process it.

Testing plays a very critical role in determining the reliability and


efficiency of software and hence is a very important stage in software
development. Software testing is done at different levels. They are the unit testing
and system testing which comprises of integration testing and acceptance testing.

Types of Testing

6.1. Unit Testing

6.2. System Testing

6.3. Integration Testing

6.4. Black box Testing

27
6.5. White box Testing

6.1. UNIT TESTING

Unit Testing is a level of software testing where individual units/


components of a software are tested. The purpose is to validate that each unit of the
software performs as designed. A unit is the smallest testable part of software. It
usually has one or a few inputs and usually a single output.

In procedural programming a unit may be an individual program, function,


procedure, etc. In object-oriented programming, the smallest unit is a method,
which may belong to a base/ super class, abstract class or derived/ child class.
(Some treat a module of an application as a unit. This is to be discouraged as there
will probably be many individual units within that module.)

Unit testing increases confidence in changing/ maintaining code. If good


unit tests are written and if they are run every time any code is changed, we will
be able to promptly catch any defects introduced due to the change. Also, if codes
are already made less interdependent to make unit testing possible, the unintended
impact of changes to any code is less.

Codes are more reusable. In order to make unit testing possible, codes
need to be modular. This means that codes are easier to reuse.

The project is divided into various modules and unit testing has been
done.

There are 4 categories in unit testing

 Functional testing

 Performance testing

28
 Stress testing

 Structured testing

6.1.1. FUNCTIONAL TESTING

Functional testing cases involves executing the code with


normal input values for which the expected result are known as well as boundary
values as modules of X matrices.

6.1.2. PERFORMANCE TESTING

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


the units. The certain amount of performance testing is done during unit testing.

6.1.3. STRESS TESTING

Stress testing is the test designed to intentially break the system as a


unit into many small parts or units.

6.1.4. STRUCTURED TESTING

Structural testing, also known as glass box testing or white box testing
is an approach where the tests are derived from the knowledge of the software's
structure or internal implementation.The other names of structural testing includes
clear box testing, open box testing, logic driven testing or path driven testing.

Structural Testing Techniques:

 Statement Coverage - This technique is aimed at exercising all


programming statements with minimal tests.

 Branch Coverage - This technique is running a series of tests to


ensure that all branches are tested at least once.

29
 Path Coverage - This technique corresponds to testing all possible
paths which means that each statement and branch are covered.

6.2. SYSTEM TESTING

System Testing is a level of the software testing where a


complete

and integrated software is tested. The purpose of this test is to evaluate the
system's compliance with the specified requirements. The process of testing an
integrated system to verify that it meets specified. System test falls under the black
box testing category of software testing. White box testing is the testing of the
internal workings or code of a software application. In contrast, black box or
system testing is the opposite. System test involves the external workings of the
software from the user's perspective.

System testing involves testing the software code for following

 Testing the fully integrated applications including external


peripherals in order to check how components interact with one another and
with the system as a whole. This is also called End to End testing scenario..

 Verify thorough testing of every input in the application to check for


desired outputs.

 Testing of the user's experience with the application.

That is a very basic description of what is involved in system testing. You need to
build detailed test cases and test suites that test each aspect of the application as
seen from the outside without looking at the actual source code.

6.3. INTEGRATION TESTING

30
Integration Testing is a level of software testing where individual
units are combined and tested as a group.

Integration testing: Testing performed to expose defects in the interfaces and in


the interactions between integrated components or systems.

Component integration testing: Testing performed to expose defects in the


interfaces and interaction between integrated components.

System integration testing: Testing the integration of systems and packages;


testing interfaces to external organizations (e.g. Electronic Data Interchange,
Internet).

6.3.1. BOTTOM-UP:

Bottom-up is an approach to Integration Testing where bottom level


units are tested first and upper level units step by step after that. This approach is
taken when bottom up development approach is followed. Test Drivers are needed
to simulate higher level units which may not be available during the initial phases.

6.3.2. TOP-DOWM:

Top-down is an approach to Integration Testing where top level units


are tested first and lower level units are tested step by step after that. This approach
is taken when top down development approach is followed. Test Stubs are needed
to simulate lower level units which may not be available during the initial phases.

6.4. BLACK BOX TESTING

Black Box Testing, also known as Behavioral Testing, is a


software testing method in which the internal structure/ design/ implementation of

31
the item being tested is not known to the tester. These tests can be functional or
non-functional, though usually functional.

Following are some techniques that can be used for designing black box

tests.

Equivalence partitioning: It is a software test design technique that involves


dividing input values into valid and invalid partitions and selecting representative
values from each partition as test data.

Boundary Value Analysis: It is a software test design technique that involves


determination of boundaries for input values and selecting values that are at the
boundaries and just inside/ outside of the boundaries as test data.

Cause Effect Graphing: It is a software test design technique that involves


identifying the cases (input conditions) and effects (output conditions), producing a
Cause-Effect Graph, and generating test cases accordingly.

6.5. WHITE BOX TESTING

White Box Testing (also known as Clear Box Testing, Open Box
Testing, Glass Box Testing, Transparent Box Testing, Code-Based Testing or
Structural Testing) is a software testing method in which the internal
structure/design/ implementation of the item being tested is known to the tester.
The tester chooses inputs to exercise paths through the code and determines the
appropriate outputs. Programming know-how and the implementation knowledge
is essential. White box testing is testing beyond the user interface and into the
nitty-gritty of a system.

32
CHAPTER 7
CONCLUSION AND FUTURE ENHANCEMENT

7.1. Conclusion

With the help of this project we can help lot of farmers who is not really
experienced to understand the disease .In this project, the deep learning models
CAE and CAE are analyse the plant leaf disease images. The PLANT VILLAGE
data is taken as input data and applied into pre-processing method. In pre-
processing method the images are resized and converted into array. Then it
processed into feature selection method, in this method the dataset is split into
training dataset and testing dataset.Then the dataset is compressed using CAE
model after training it, then the compressed images given to the CNN model to
train and classify the images into 9 classes, if the plant had any disease then we
provide the solution for the disease the plant has .

7.2. Future Enhancement

 In this project we are going to detect and give solution to a single plant ,in
future the project will be capable of detecting more number of plants.
 And creating a mobile application for detecting the diseases.
 Using Drones to scan the plants.

33
CHAPTER 8
SAMPLE COADINGS AND SAMPLE SCREEN SHOTS
import tensorflow as t
import matplotlib.pyplot as plt
from tensorflow.keras.layers
import
Input,Dense,Conv2D,MaxPooling2D,Reshape,UpSampling2D,LeakyReLU,Flatte
n,
BatchNormalization,Dropout
from tensorflow.keras.models import Model
import pathlib as ph
import PIL.Image
import numpy as np

np.random.seed(42)
t.random.set_seed(42)
bs=64
h=128
w=128
c=3
data_dir=ph.Path('D:/Final Project data/Data/Train')
#print(data_dir)
ts=list(data_dir.glob('Tomato_healthy/*'))
print(len(ts))
PIL.Image.open(str(ts[0]))
import os

34
os.environ["CUDA_VISIBLE_DEVICES"]="-1"
#%%
import numpy as
np import glob
Tomato_Bacterial_spot=glob.glob('D:/Final Project
data/Data/train/Tomato_Bacterial_spot*.*')
Tomato_Early_blight=glob.glob('D:/Final
Project data/Data/train/Tomato_Early_blight*.*')
Tomato_Late_blight=glob.glob('D:/Final
Project data/Data/train/Tomato_Late_blight/*.*')
Tomato_Leaf_Mold=glob.glob('D:/Final Project
data/Data/train/Tomato_Leaf_Mold/*.*')
Tomato_Septoria_leaf_spot=glob.glob('D:/FinalProjectdata/Data/train/Tomato_Se
ptoria_leaf_spot/*.*')
Tomato_Spider_mites_Two_spotted_spider_mite=glob.glob('D:/FinalProjectdata/
Data/train/Tomato_Spider_mites_Two_spotted_spider_mite/*.*')
Tomato Target_Spot=glob.glob('D:/Final Project
data/Data/train/Tomato Target_Spot/*.*')
Tomato Tomato_YellowLeaf Curl_Virus=glob.glob('D:/FinalProjectdata/Data/
train/Tomato Tomato_YellowLeaf Curl_Virus/*.*')
Tomato Tomato_mosaic_virus=glob.glob('D:/FinalProjectdata/Data/train/Tomat
o Tomato_mosaic_virus/*.*')
Tomato_healthy=glob.glob('D:/Final Project data/Data/train/Tomato_healthy/*.*')

data=[]
labels=[]
for i in Tomato_Bacterial_spot:

35
image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(0)

for i in Tomato_Early_blight:
image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(1)

for i in Tomato_Late_blight:
image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(2)

for i in Tomato_Leaf_Mold:
image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(3)

36
for i in Tomato_Septoria_leaf_spot:
image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(4)

for i in Tomato_Spider_mites_Two_spotted_spider_mite:
image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(5)

for i in Tomato Target_Spot:


image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(6)

for i in Tomato Tomato_YellowLeaf Curl_Virus:


image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(7)

37
for i in Tomato Tomato_mosaic_virus:
image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(8)

for i in Tomato_healthy:
image=t.keras.preprocessing.image.load_img(i, color_mode='rgb',
target_size= (h,w))
image=np.array(image)
data.append(image)
labels.append(9)
data = np.array(data)
labels = np.array(labels)

from sklearn.model_selection import train_test_split


X_train, X_test, ytrain, ytest = train_test_split(data, labels, test_size=0.3,
random_state=42)

ytrain=ytrain.reshape(-1,)
ytrain[:5]

ytest=ytest.reshape(-1,)
ytest[:5]

38
class_names=['Tomato_Bacterial_spot','Tomato_Early_blight','Tomato_Late_blig
ht',
'Tomato_Leaf_Mold','Tomato_Septoria_leaf_spot','Tomato_Spider_mites_Two_s
potted_spider_mite','Tomato Target_Spot','Tomato Tomato_YellowLeaf Cur
l_Virus','Tomato Tomato_mosaic_virus', 'Tomato_healthy']
print(class_names)

plt.figure(figsize=(15,15))

for i in range(10):
ax=plt.subplot(5,2,i+1)
plt.imshow(X_train[i], cmap=plt.get_cmap('gray'))
plt.title(class_names[ytrain[i]])
plt.axis("off")

#%%
inputs=Input(shape=(h,w,c))
#Encoder
encoder=Conv2D(128,(3,3),activation='relu',padding='same')(inputs)
encoder=MaxPooling2D(2,2)(encoder)
##
encoder=Conv2D(128,(3,3),activation='relu',padding='same')(inputs)
encoder=MaxPooling2D(2,2)(encoder)
##
encoder=enocder=Conv2D(64,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D(2,2)(encoder)

39
##
encoder=enocder=Conv2D(64,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D(2,2)(encoder)
##
encoder=Conv2D(32,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D(2,2)(encoder)
##
encoder=Conv2D(32,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D(2,2)(encoder)
##
##encoder=Conv2D(16,(3,3),activation='relu',padding='same')(encoder)
##encoder=MaxPooling2D((2,2))(encoder)
##
encoder=Conv2D(16,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D((2,2))(encoder)
print(encoder.shape)

##bottle neck
encoder=Flatten()(encoder)
u=encoder.shape[1]
print(u)
encoder=Dense(10,activation='relu')(encoder)
encoder=Dropout(0.2)(encoder)
encoder_m=Model(inputs,encoder)
encoder_m.summary()
#Decoder decoder=Dense(u,activation='relu')
(encoder)

40
decoder=Dropout(0.2)(decoder)
decoder=Reshape((2,2,16))(decoder)
##
decoder=UpSampling2D((2,2))(decoder) decoder=Conv2D(16,
(3,3),activation='relu',padding='same')(decoder) ##
decoder=UpSampling2D((2,2))(decoder) decoder=Conv2D(32,
(3,3),activation='relu',padding='same')(decoder) ##
decoder=UpSampling2D((2,2))(decoder) decoder=Conv2D(32,
(3,3),activation='relu',padding='same')(decoder) ##
decoder=UpSampling2D((2,2))(decoder) decoder=Conv2D(64,
(3,3),activation='relu',padding='same')(decoder) ##
##decoder=UpSampling2D((2,2))(decoder) ##decoder=Conv2D(64,
(3,3),activation='relu',padding='same')(decoder) ##
decoder=UpSampling2D((2,2))(decoder) decoder=Conv2D(128,
(3,3),activation='relu',padding='same')(decoder) ##
decoder=UpSampling2D((2,2))(decoder) decoder=Conv2D(3,
(3,3),activation='relu',padding='same')(decoder)
decoder_m=Model(inputs,decoder)
decoder_m.summary() #%
%
from tensorflow.keras.optimizers import Adam

41
decoder_m.compile(optimizer='adam',loss='mse',metrics=['accuracy'])
decoder_m.fit(X_train,X_train,batch_size=16,epochs=3,validation_data=(X_test,
X_test))
#%%
decoder_m.save('D:/Final Project data/Model/cae.h5') #%
%
Xtrain=decoder_m.predict(X_train,verbose=1) #%
%
Xtest=decoder_m.predict(X_test,verbose=1)
#%%
inputs=Input(shape=(h,w,c))
#Encoder
encoder=Conv2D(128,(3,3),activation='relu',padding='same')(inputs)
encoder=MaxPooling2D(2,2)(encoder)
##
encoder=Conv2D(128,(3,3),activation='relu',padding='same')(inputs)
encoder=MaxPooling2D(2,2)(encoder)
##
encoder=enocder=Conv2D(64,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D(2,2)(encoder)
##
encoder=enocder=Conv2D(64,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D(2,2)(encoder)
##
encoder=Conv2D(32,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D(2,2)(encoder)
##

42
encoder=Conv2D(32,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D(2,2)(encoder)
##
encoder=Conv2D(16,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D((2,2))(encoder)
##
encoder=Conv2D(16,(3,3),activation='relu',padding='same')(encoder)
encoder=MaxPooling2D((2,2))(encoder)
print(encoder.shape)

##bottle neck
encoder=Flatten()(encoder)
u=encoder.shape[1]
print(u)
encoder=Dense(10,activation='relu')(encoder)
encoder=Dropout(0.2)(encoder)
cnn=Dense(1000,activation='relu')(encoder)
cnn=Dropout(0.3)(cnn)
cnn=Dense(700,activation='relu')(cnn)
cnn=Dropout(0.5)(cnn)
cnn=Dense(350,activation='relu')(cnn)

cnn=Dense(10,activation='softmax')(cnn)
cnn_m=Model(inputs,cnn)
cnn_m.summary()
cnn_m.compile(optimizer='adam',loss='sparse_categorical_crossentropy',metrics=
['accuracy'])

43
cnn_m.fit(Xtrain,ytrain,batch_size=32,epochs=5,validation_split=0.2)
#%%
cnn_m.evaluate(X_test,ytest,verbose=2) #%
%
cnn_m.save('D:/Final Project data/Model/cnn.h5')
#%%
plt.plot(cnn.history['accuracy'])
plt.plot(cnn.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
#%%
plt.plot(cnn.history['loss'])
plt.plot(cnn.history['val_loss'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
#%%
y_pred=cnn_m.predict(X_test)
y_pred=np.argmax(y_pred,axis=1)
#%%
class_names=['Tomato_Bacterial_spot', 'Tomato_Early_blight',
'Tomato_Late_blight', 'Tomato_Leaf_Mold', 'Tomato_Septoria_leaf_spot',

44
'Tomato_Spider_mites_Two_spotted_spider_mite', 'Tomato Target_Spot',
'Tomato Tomato_YellowLeaf Curl_Virus', 'Tomato Tomato_mosaic_virus',
'Tomato_healthy']

if(y_pred==0)
{
print(class_names(y_pred))
print("The solution::")
print("Plowing down crop residue soon after harvest is complete will facilitate the
decomposition of crop residue and reduce spread to younger successive plantings.
In the field, fixed-copper based products are still the primary tool for managing
bacterial spot in tomato.")
}
elif(y_pred==1)
{
print(class_names(y_pred))
print("The solution::")
print("Take 1 aspirin and crush it into powder\nTake 4 cups of water and mix
them properly.\nSpray it on your plant every 2-3 weeks through the growing
season. That will help the plant to prevent tomato blight effectively.")
}
elif(y_pred==2)
{
print(class_names(y_pred))
print("The solution::")
print("one heaping tablespoon of baking soda\none teaspoon of vegetable oil;\na

45
small amount of mild soap.\nSpray the tomato plants with this solution, and
reapply it regularly to maintain its efficiency,")
}
elif(y_pred==3)
{
print(class_names(y_pred))
print("The solution::")
print("An apple-cider and vinegar mix is believed to treat the mold effectively.
Corn and garlic spray can also be used to prevent fungi outbreaks before they even
occur. ")
}
elif(y_pred==4)
{
print(class_names(y_pred))
print("The solution::")
print("Use raised beds and rotate which bed has tomatoes from year to year\
nConsider mulching the garden to prevent watersplash from soil to the lower
leaves\nIf symptoms of Septoria leaf spot appear on the lower leaves, removing
affected leaves may reduce disease. But, avoid removing too many leaves.\nFor
gardens with a history of Septoria leaf spot, fungicides with active ingredients
such as chlorothalonil, copper, or mancozeb will help reduce disease, but they
must be applied before disease ")
}
elif(y_pred==5)
{
print(class_names(y_pred))
print("The solution::")

46
print("The postharvest interval on tomatoes is seven days. • Bifenazate (Acramite,
Chemtura, 0.75 to 1 pound per acre): This is a contact poison against two-spotted
spider mites with less toxicity to predaceous mites and beneficial arthropods.
Acramite is a good knockdown product and also kills the eggs (ovicidal action).")
}
elif(y_pred==6)
{
print(class_names(y_pred))
print("The solution::")
print("Remove old plant debris at the end of the growing season; otherwise, the
spores will travel from debris to newly planted\nRotate crops and don’t plant
tomatoes in areas where other disease-prone plants have been located in the past
year\nPay careful attention to air circulation, as target spot of tomato thrives in
humid conditions. Grow the plants in full\nWater tomato plants in the morning so
the leaves have time to dry")
}
elif(y_pred==7)
{
print(class_names(y_pred))
print("The solution::")
print("Unfortunately, there is no cure for TYLCV(Tomato Yellow leaf Curl
Virus), so the only answer is removing infected plants to prevent the disease from
spreading. Inspect your plants to find the symptoms of TYLCV, and remove any
that show symptoms.")

}
elif(y_pred==8)

47
{
print(class_names(y_pred))
print("The solution::")
print("The unfortunate reality when it comes to Mosaic Viruses is that there isn’t
a cure. If you notice that your tomato, or houseplant has this infection, the best
course of action is to safely remove and destroy them. For those looking to plant
tomatoes, choose a location that does not have root debris as this type of virus
thrives in root systems")
}

elif(y_pred==9)
{
print(class_names(y_pred))
}

48
SCREEN SHOTS

49
50
51
52
53
CHAPTER 9
REFERENCE

⚫ S. Poornam, A. Francis Saviour Devaraj.” Image based Plant leaf disease


detection using Deep learning ”, May 2021.
⚫ Punam Bedi, Pushkar Gole.” Plant disease detection using hybrid model
based on convolutional autoencoder and convolutional neural network”,
May 2021.
⚫ Muhammad E.H. Chowdhury, Tawsifur Rahman,Amith Khandakar,Nabil
Ibtehaz, Aftab Ullah Khan, Muhammad Salman Khan, Nasser Al-
Emadi,Mamun Bin Ibne Reaz, Mohammad Tariqul Islam , Sawal Hamid
Md. Ali.” Tomato Leaf Diseases Detection Using Deep Learning
Technique”,April 2021.
⚫ Gang Xue,Shifeng Liu,Yicao Ma.” A hybrid deep learning-based fruit
classification using attention model and convolution autoencoder”,August
2021.
⚫ E. Moen, D. Bannon, T. Kudo, W. Graf, M. Covert, and D. Van Valen,
“Deep learning for cellular image analysis,” Nature Methods, vol. 16, no. 12,
pp. 1233–1246, 2019.
⚫ E. Mwebaze, T. Gebru, A. Frome, S. Nsumba, and J. Tusubira, “iCassava
2019 fine-grained visual categorization challenge,” 2019, arXiv:1908.02900.
[Online]. Available: https://arxiv.org/abs/1908.02900
⚫ Rao, D.R., Krishna, M., Ramakrishna, B., 2020. Smart ailment
identification system for Paddy crop using machine learning. Int. J. Innov.
Eng. Manag. Res. 9 (3), 96–100.
⚫ Chohan, M., Khan, A., Katper, S., Mahar, M., 2020. Plant disease detection

54
using deep learning. Int. J. Recent Technol. Eng. 9 (1), 909–914.
⚫ Chen, Junde, Chen, Jinxiu, Zhang, D., Sun, Y., Nanehkaran, Y.A., 2020.
Using deep transfer learning for image-based plant disease identification.
Comput. Electron. Agric. 173, 105393.

55

You might also like