You are on page 1of 57

A Project Report

on

IMPLEMENTATION OF DETECTION AND


CLASSIFICATION OF COTTON LEAF DISEASE USING A
LIGHT WEIGHT CNN ARCHITECTURE

Submitted in partial fulfillment of the requirement for the award of degree of

BACHELOR OF TECHNOLOGY
in
ELECTRONICS AND COMMUNICATION ENGINEERING

Submitted by

M.SOWMYA - 20FE1A04B1
P.SANTHISRI - 20FE1A04C4
K.GIGNESH - 20FE1A0488
K.PREMSAGAR - 20FE1A0489

Under the esteemed guidance of


G. HARISH, M.Tech., Ph.D,
Assistant Professor

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

VIGNAN’S LARA INSTITUTE OF TECHNOLOGY & SCIENCE


Approved by AICTE New Delhi & Affiliated to JNTU, Kakinada
NBA accredited (CSE, IT, ECE, EEE & MECH )
Vadlamudi-522213, Guntur Dist., Andhra Pradesh.
2019 – 2023
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

VIGNAN’S LARA INSTITUTE OF TECHNOLOGY & SCIENCE


Approved by AICTE New Delhi & Affiliated to JNTU, Kakinada
NBA accredited (CSE, IT, ECE, EEE & MECH )
VADLAMUDI-522213, GUNTUR Dist, ANDHRA PRADESH

CERTIFICATE

This is to certify that main project work entitled “IMPLEMENTATION OF


DETECTION AND CLASSIFICATION OF COTTON LEAF DISEASE USING A
LIGHT WEIGHT CNN ARCHITECTURE” is a bonafide work done by
M.SOWMYA(20FE1A04B1),P.SANTHISRI(20FE1A04C4),K.GIGNESH(20FE1A0488)
,K.PREMSAGAR(20FE1A0489)under my guidance and submitted in partial fulfillment of
requirement for award of degree of Bachelor of Technology in Electronics and
Communication Engineering by Jawaharlal Nehru Technological University, Kakinada.

Project Guide Head of the Department


G. Harish, Dr. B. Harish,
Assistant Professor Professor

External Examiner
ACKNOWLEDGEMENT
We are most thankful to our parents who stood as pillars of motivation and for the way
they influenced and molded our lives.

We are more thankful to our chairman Dr. LAVU RATHAIAH who helped us to have
a technical incubation by providing the required infrastructure.

We are very much thankful to our principal Dr. K. PHANEENDRA KUMAR who
extended a timely help at each and every step of our academic career.

We are very thankful to our Head of the department Dr. B. HARISH an amicable
person who supported us very much and helped to a maximum extent and made this project
successful.

We are very thankful to our beloved coordinators Mrs .P.V.N.LAKSHMI, Dr. E.


Suneel, and Mrs.K.REVATHI for inspiring all the way and arranging all the facilities and
resources needed for project. Their efforts in this aspect are beyond the preview of the
acknowledgement.

We are heartily thankful to our project guide Mr. G. HARISH, Assistant Professor,
the person with vibrant knowledge and amicable by nature who laid a best guide line and for
the efforts made by him to make the project a successful one.

Finally, we are thankful to each and every faculty member both technical and non-
technical, friends and all the persons who helped us directly or indirectly in making our project
a successful one.

Project Associates

M.SOWMYA (20FE1A04B1)
P.SANTHISRI (20FE1A04C4)
K.GIGNESH (20FE1A0488)
K.PREMSAGAR (20FE1A0489)
DECLARATION

We hereby declare that the work described in this project work, entitled

“IMPLEMENTATIONOF DETECTION AND CLASSIFICATION OF COTTON

LEAF DISEASE USING LIGHT WEIGHT CNN ARCITECTURE ” which is submitted

by us in partial fulfillment for the award of Bachelor of Technology (B.Tech) in the

Department of Electronics & communication Engineering to the Vignan’s Lara Institute of

Technology and science affiliated to Jawaharlal Nehru Technological University Kakinada,,

Andhra Pradesh, is the result of work done by us under the guidance of Mr. G.HARISH,

Assistant Professor, in the department ECE.

The work is original and has not been submitted for any Degree/Diploma of this or any
other university.

Signatures

M.SOWMYA (20FE1A04B1)
P.SANTHISRI (20FE1A04C4)
K.GIGNESH (20FE1A0488)
K.PREMSAGAR (20FE1A0489)

Place: Vadlamudi.

Date:
INDEX

CONTENTS I

ABSTRACT III

LIST OF FIGURES IV
LIST OF ABBREVIATION V

Chapter 1: INTRODUCTION TO LEAF DETECTION


1.1 Introduction 1
1.2 Methodology 3
Chapter 2: LITERATURE SURVEY 5

Chapter 3: SYSTEM ANALYSIS


3.1 Existing system 8
3.2 Proposed system 8
3.3 system architecture 9
3.4 Data flow diagram 10
3.5 Hardware requirements 11
3.6 Software requirements 11
3.7 Collaboration diagram 11
Chapter 4:SOFTWARE ENVIRONMENT
4.1 Install Python on Windows 13
4.2 What is python 17
4.3 Advantages of python over other language 17
4.4 Disadvantages of python 20
4.5 What is Deep learning 21
4.5.1 Types of Algorithm used in Deep learning 21

i
4.5.1.1 Convolutional Neural Network 22
4.5.1.2 Long Short Term Memory Network 22
4.5.1.3 Recurrent Neural Network 22
4.5.1.4 Generative Adversarial Network 23

4.5.1.5 Radial Basis Function Network 23

4.5.1.6 Multilayer Perceptorn 23

4.5.1.7 Self Organizing Maps 23

4.5.1.8 Deep Belief Network 24

4.5.1.9 Restricted Boltzmann Machines 24

4.5.1.10 Autoencoders 24
4.6 How Deep learning works 24
4.7 Python Development steps 26

Chapter 5: SYSTEM TEST


5.1 Types of Tests 27

Chapter 6: MODULES

6.1 Tensor flow 31


6.2 Numpy 32

6.3 Pandas 33

Chapter 7: IMPLEMENTATION
7.1 The general steps involved in leaf disease detection 36
7.2 Code Used In Python 38

Chapter 8: RESULT 41

Chapter 9: CONCLUSION 46
REFERENCES 47

ii
ABSTRACT
India is a land of agriculture and mainly known for growing variety of crops.
Around half of the population in India depend on agriculture. Diseases to the crops
may affect the livelihood of the farmers. In order to overcome this major problem, a
robot that detects the leaf disease using image processing and Machine learning is
deployed. The machine learning model with Image processing is trained with
feature extraction, Segmentation using CNN Algorithm . Android application is
used for controlling the robot. This application controls all the operation of the
robot. Diseases to the crops may affect the livelihood of the farmers. In order to
overcome this major problem, a robot that detects the leaf disease using image
processing and Machine learning is deployed. The machine learning model with
Image processing is trained with feature extraction, Segmentation using CNN
Algorithm.

iii
LIST OF FIGURES

Figure1.1. Sample images from Cotton Village dataset for types of leaf

diseases. 2
Figure 1.2. Cotton leaf detection and disease recognition methodology 3
Figure3.1 system architecture for leaf disease detection 9
Figure 3.2 .Data flow diagram for user to end process 10
Figure 3.3.Data transferring from user to database 11
Figure4.1. Installation of python 14
Figure 4.2 Optional features of python 14
Figure 4.3 Advanced options of python 15
Figure 4.4 Successful installation of python 16
Figure 8.1 output at the python 41
Figure 8.2 prediction of Leaf disease photo uploadation 42
Figure 8.3 Detected cotton yellow leaf curl virus disease 42
Figure 8.4 Detected Septoria leaf spot disease 43
Figure 8.5 Detected Bacteria spot disease 43
Figure 8.6 Detected Target spot disease 44
Figure 8.7 Detected Early Blight disease 44
Figure 8.8 Detected Healthy and fresh leaf 45

iv
LIST OF ABBREVIATION

S.NO ABBREVIATION EXPLANATION


1 Convolutional Neural Network
CNN
2 Artificial Neural Network
ANN
Deep Convolutional Neural
3 DCNN
Network
4 DFD Data Flow Diagram

5 SVM Support Vector Machines

6 KNN K-Nearest Neighbours

7 DBN Deep Belief Network

8 LSTM Long Short Term Memory Network

9 RNN Recurrent Neural Network

10 GAN Generative Adversarial Network

11 RBFN Radial Basis Function Network

12 MLP Multilayer Perceptrons

13 SOM Self Organizing Map

14 RBM Restricted Boltzmann Machines

v
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

CHAPTER 1
INTRODUCTION
1.1 Overview

Early cotton disease detection plays a significant role in efficient crop yield. Cotton
diseases like black measles, black rot, bacterial spot, etc. affect the growth, crop quality
of cottons and economic impacts in the agricultureindustry. To avoid the impact of
these diseases, expensive approaches and the use of pesticides are some solutions the
farmers usually implement. The use of chemical means damages the cotton and
the surrounding environment. In addition, this kind of approach intensifies the cost of
production and majormonetary loss to farmers.

Early discovery of diseases as they occur is the most important period for efficient
disease management. Manual disease detection through human experts to identify and
recognize cotton diseases is a usual practice in agriculture . With the improvements in
technology, automatic detection of cotton diseases from raw images is possible through
computer vision and artificial intelligence researches . In this study, the researchers
were able to investigate cotton diseases and pest’s infestation that affects the leaves of
the cottons.

Image processing techniques are now commonly employed in agriculture and it is


applied for the detection and recognition of weeds, fruit-grading, identifying and
calculating disease infestations of cottons ,and cotton genomics. Currently, the
introduction of deep learning methods turns out to be popular.Deep learning is the
advanced methods of machine learning that uses neural networks that works like the
human brain Traditional methods involve the use of semantic features as the
classification method. A convolutional neural network (CNN) is a deep learning model
that is widely used in image processing.

The work of Lee et al. presents a hybrid model to obtain characteristics of leaves using
CNN and classify the extracted features of leaves. The methodology in the study
involves three key stages: acquisition of data, pre- processing of data and image
classification. The study utilized dataset from Cotton village dataset that contains
cotton varieties of apple, corn, grapes, potato, sugarcane, and cotton. There are 11 types
of cotton diseases identified in the study including healthy images of identified cottons.

ECE, VLITS 1
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Image pre- processing involves re-sized images and enhancement before supplying it
for the classification model. CONVULUTIONAL NEURAL NETWORK Deep
learning is a subsection of Artificial Intelligence and machine learning that uses
Artificial neural networks (ANN). Training the deep learning models divides the
feature extraction and extracts its features for classification. There are several
applications of deep learning which include computer vision, image classification,
restoration, speech, video analysis, etc. A convolutional neural network with nominal
process can simply detect and categorize. It is efficient in evaluating graphical images
and extracts the essential features through its multi-layered structure. As shown in
Figure 1.1, the CNN involves our layers, that is: input image, convolutional layer and
pooling layer, fully connected layers, and output.

Figure1.1. Sample images from Cotton Village dataset for types of

Leafdiseases

CNN deep-learning models are popular for image-based research. They are efficient in
learning low-level complex features from images. However, deep CNN layers are
difficult to train as this process is computationally expensive. To solve such issues,
transfer learning-based models have been proposed by various researchers. These
models are trained with the ImageNet dataset, which consists of multiple classes. Such

ECE, VLITS 2
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

models can be used for training with any dataset as the features of the images. Hence,
the transfer learning approach has been found to be the most suitable and robust model
for image classification. Further, transfer learning can improve learning even when
there is a smaller dataset.
1.2 Methodology
A block diagram presented in Figure 1.2 shows the Input Dataset, Image Acquisition,
Image pre-processing and Classification

Data set

Image Acquisition

Image pre-processing

Classification

Figure 1.2. Cotton leaf detection and disease recognition methodology

Image Acquisition
Image dataset used for training the model was acquired in the Cotton Village repository.
A python script was used to download images of the cotton diseases from the repository.
The acquired dataset consists of approximately 35,000images with 32 different classes
cotton varieties and diseases.

ECE, VLITS 3
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Image Pre-processing
Pre-processed images are reduced image size and image crop to a given input. It
processes and enhances the image to its needed colour scale. The study uses coloured
and resized images to 96x96 resolution for processing.

Classification
Classification uses a fully connected layers and for feature extraction it uses
convolutional and pooling layers. The classification process classifies thecotton leaf if
it is infected with the disease or not, identifies the type ofcotton disease and recognize
the cotton variety.
1.3 Advantages
The advantages of the proposed system are it increases the crop productivity, instant
and accurate results, automatically predicts the remedy for the disease, saves a lot of
time, protects the environment by limiting the usage of pesticides through early disease
detection, allow us to take the live sample of the leaves through digital camera.
1.4 Limitations
In addition to the above advantages the system has certain limitations of its usage,
that is while we are taking the live image through camera proper lighting conditions are
required, if not accurate results may not be acquired

ECE, VLITS 4
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

CHAPTER 2
LITERATURE SURVEY
2.1 A survey of image processing techniques for agriculture
AUTHORS: Lalit P. Saxena and Leisa J. Armstrong

ABSTRACT: Computer technologies have been shown to improve


agricultural productivity in a number of ways. One technique which is emerging as a
useful tool is image processing. This paper presents a short survey on using image
processing techniques to assist researchers and farmers to improve agricultural
practices. Image processing has been used to assist with precision agriculture practices,
weed and herbicide technologies, monitoring cotton growth and cotton nutrition
management. This paper highlights the future potential for image processing for
different agricultural industry contexts.

2.2 Imagenet classification with deep convolutional neural


networks

AUTHORS: A. Krizhevsky, I. Sutskever and G. E. Hinton,

ABSTRACT: We trained a large, deep convolutional neural network to classify


the 1.2 million high-resolution images in the ImageNet LSVRC-2010 contest into the
1000 different classes. On the test data, we achieved top-1 and top-5 error rates
of 37.5% and 17.0% which is considerably better than the previous state-of-the-art.
The neural network, which has 60 million parameters and 650,000 neurons, consists
of five convolutional layers, some of which are followed by max-pooling layers, and
three fully-connected layers with a final 1000-way softmax. To make training faster,
we used non- saturating neurons and a very efficient GPU implementation of the
convolution operation. To reduce overriding in the fully-connected layers we employed
a recently-developed regularization method called "dropout" that proved to be very
effective. We also entered a variant of this model in the ILSVRC-2012 competition and
achieved a winning top-5 test error rate of 15.3%

ECE, VLITS 5
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

2.3 Integrating soms and a bayesian classifier for segmenting diseased


cottons in uncontrolled environments

AUTHORS: D. L. Hernández-Rabadán, F. Ramos-


Quintana and J. Guerrero Juk

ABSTRACT: This work presents a methodology that integrates a


nonsupervised learning approach (self-organizing map (SOM)) and a
supervised one (a Bayesian classifier) for segmenting diseased cottons that
grow in uncontrolled environments such as greenhouses, wherein the lack
of control of illumination and presence of background bring about serious
drawbacks. During the tr aining phase two SOMs are used: one that creates
color groups of images, which are classified into two groups using K -
means and labeled as vegetation and nonvegetation by using rules, and a
second SOM that corrects classification errors made by the first SOM. Two
color histograms are generated from the two color classes and used to estimate
the conditional probabilities of the Bayesian classifier. During the testing
phase an input image is segmented by the Bayesian classifier and then it is
converted into a binary image, wherein contours are extracted and analyzed to
recover diseased areas that were incorrectly classified as nonvegetation. The
experimental results using the proposed methodology showed better
performance than two of the most used color index methods.

2.4 Visible-near infrared spectroscopy for detection of


Huanglongbing in citrus orchards

AUTHORS: S. Sankaran, A. Mishra, J. M. Maja and R. Ehsani

ABSTRACT : This paper evaluates the feasibility of applying visible-near infrared


spectroscopy for in-field detection of Huanglongbing (HLB) in citrus orchards.
Spectral reflectance data from the wavelength range of 350–2500nm with 989
spectral features were collected from 100 healthy and 93 HLB infected citrus trees
using a visible near infrared spectroradiometer. During data preprocessing, the
spectral data were normalized and averaged every 25nm to reduce the spectral

ECE, VLITS 6
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

features from 989 to 86. Three datasets were generated from the preprocessed raw
data: first derivatives, second derivatives, and a combined dataset (generated by
integrating preprocessed raw data, first derivatives and second derivatives). The
preprocessed datasets were analyzed using principal component analysis (PCA) to
further reduce the number of features used as inputs in the classification algorithm.
The dataset consisting of principal components were randomized and separated into
training and testing datasets such that 75% of the dataset was used for training;
while 25% of the dataset was used for testing the classification algorithms. The
number of samples in the training and testing datasets was145 and 48,
respectively. The classification algorithms tested were: linear discriminant analysis,
quadratic discriminant analysis (QDA), k-nearest neighbor, and soft independent
modeling of classification analogies (SIMCA). Thereported classification accuracies
of the algorithms are an average of three runs. When the second derivatives dataset
were analyzed, the QDA-based classification algorithm yielded the highest overall
average classification accuracies of about 95%, with HLB-class classification
accuracies of about 98%. In the combined dataset, SIMCA-based algorithms
resulted in high overall classification accuracies of about 92% with low false
negatives (less than 3%).

2.5 Rethinking the inception architecture for computer vision

AUTHORS: Christian Szegedy, Vincent Vanhoucke, Sergey


Ioffe,

ABSTRACT: Convolutional networks are at the core of most state-of-the-art


computer vision solutions for a wide variety of tasks. Since 2014 very deep
convolutional networks started to become mainstream, yielding substantial gains in
various benchmarks. Although increased model size and computational cost tend to
translate to immediate quality gains for most tasks (as long as enough labeled data is
provided for training), computational efficiency and low parameter count are still
enabling factors for various use cases such as mobile vision and big-data scenarios.
Here we explore ways to scale up networks in ways that aim at utilizing the added
computation as efficiently as possible by suitably factorized convolutions and
aggressive regularization. We benchmark our methods on the ILSVRC 2012
classification challenge validation set demonstrate substantial gains over the state of the
art: 21.2% top-1 and 5.6% top-5 error for single frame evaluation using a network with
a computational cost of 5 billion multiply-adds per inference and with using less than 25
million parameters. With an ensemble of 4 models and multi-crop evaluation.

ECE, VLITS 7
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

CHAPTER 3
SYSTEM ANALYSIS

Leaf disease detection using deep learning is a popular area of research that involves
developing computer algorithms capable of detecting and classifying cotton diseases
from digital images of cotton leaves. This technology has the potential to revolutionize
agriculture by allowing farmers to quickly and accurately identify and treat diseased
cottons, thereby reducing crop losses and increasing yields.

3.1 Existing system

The current approach for detecting cotton disease is simple naked eye observation by
cotton experts, which can be used to detect and identify cotton diseases. In these
circumstances, the suggested technique is useful for tracking vast fields of crops.
Furthermore, in some nations, farmers lack adequate facilities or are unaware that they
can contact experts. As a result, consulting experts is not only more expensive but also
more time consuming. In those circumstances, the suggested technique for tracking a
large number of cottons would be useful.

3.2 Proposed system

This study is focused on the identification of cotton diseases. The


segmentation, feature extraction, and classification techniques are used to
detect cotton diseases. Photos of leaves from various cottons are taken with a
digital camera or similar unit, and the images are used to classify the affected
region in the leaves. To detect cotton disease, we use a Convolution neural
network and a Deep neural network in the proposed framework. This paper
proposes a framework that employs low-cost, open-source software to achieve
the task of reliably detecting cotton disease.

ECE, VLITS 8
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

3.3 SYSTEM ARCHITECTURE

Dataset Creation
CNN Design Pre-processing
Train, test, validation

Pre-process input
Training -model Load model-test
image

clasification

Figure3.3 system architecture for leaf disease detection using deep learning

Image Acquisition: The first component of the system is the acquisition of


leaf images. This can be done using a camera or mobile device, and the
images are typically captured under natural lighting conditions.
Pre-processing: The second component of the system is pre-processing the
images to enhance features and remove noise. This involves techniques
such as image resizing, cropping, and filtering.
Feature Extraction: The third component of the system is feature
extraction. In this step, the deep learning model extracts relevant
features from the pre- processed images. This is typically done using
Convolutional Neural Networks (CNNs) or Deep Convolutional
Neural Networks (DCNNs).

Training: The fourth component of the system is training the deep


learning model using a large dataset of labeled images. The model is

ECE, VLITS 9
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

trained to distinguish between healthy and diseased cottons based on


the extracted features.

Validation: The fifth component of the system is validating the


trained model using a separate set of images. This is done to ensure
that the model is accurate and can generalize well to new images.

Classification: The final component of the system is classification.


Once the model has been trained and validated, it can be used to
classify new images of cotton leaves as healthy or diseased.

3.4 DATA FLOW DIAGRAM

user

yes
No Unauthorized user
check

Upload cotton Image

Logout

END PROCESS

Figure 3.2 .Data flow diagram for user to end process

1. DFD is also called as bubble chart. It is a simple graphical formalism that can be
used to represent a system in terms of input data to the system, various processing
carried out on this data, and the output data is generated by this system.

2. The data flow diagram (DFD) is one of the most important modeling tools. It is
used to model the system components. These components are the system process,
the data used by the process, an external entity that interacts with the system and
the information flows in the system.

3. DFD shows how the information moves through the system and how it is modified

ECE, VLITS 10
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

by a series of transformations. It is a graphical technique that depicts information


flow and the transformations that are applied as data moves from input to output.

4. DFD is also known as bubble chart. A DFD may be used to represent a system at
any level of abstraction. DFD may be partitioned into levels that represent
increasing information flow and functional detail
3.5HARDWARE REQUIREMENTS

• System : 64-bit operating system, x64-based


processor
• Hard Disk : 50Gb
• Monitor : virtual display terminal
• Mouse : dell
• Ram : 8Gb

3.6 SOFTWARE REQUIREMENTS

• Operating System: Windows

• Coding Language: Python 3.10.10

3.7 Collaboration diagram


A collaboration diagram groups together the interactions betwe e n
different objects. The interactions are listed as numbered interact i o ns
that help to trace the sequence of the interactions. The collaborat i o n
diagram helps to identify all the possible interactions that each object
has with other objects.

Figure 3.3.Collaboration diagram from user to database

The advent of machine learning and deep learning techniques, the progress made in
cotton disease recognition has been enormous and represents a massive breakthrough

ECE, VLITS 11
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

in research. This has made it easy for automatic classification and feature extraction to
express the original characteristics of an image. Furthermore, the availability of
datasets, GPU machines, and software supporting complex deep-learning architectures
with lower complexity has made it feasible to switch from traditional methods to the
deep- learning platform.

Convolutional Neural Networks (CNNs): CNNs are a type of deep learning algorithm
that have been very successful in image recognition tasks. They can be trained to detect
patterns in images that are indicative of leaf diseases.

Support Vector Machines (SVMs): SVMs are a type of machine learning algorithm that
are used for classification tasks. They work by finding the hyperplane that best
separates the different classes of data.

Random Forest: Random Forest is an ensemble learning algorithm that combines


multiple decision trees to make predictions. It can be used for both classification and
regression tasks.

K-Nearest Neighbors (KNN): KNN is a simple machine learning algorithm that can be
used for classification tasks. It works by finding the k nearest neighbors to a given data
point, and classifying the point based on the majority class of its neighbors.

Deep Belief Networks (DBNs): DBNs are a type of deep learning algorithm that are
used for unsupervised learning tasks, such as feature extraction. They can be used
to extract features from leaf images that are then fed into a classifier.

The choice of algorithm will depend on the specific requirements of the leaf disease
detection task, such as the size of the dataset, the complexity of the images, and the
desired level of accuracy.

ECE, VLITS 12
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

CHAPTER 4
SOFTWARE ENVIRONMENT

4.1 Install Python on Windows

The Python programming language is an increasingly popular choice for both


beginners and experienced developers. Flexible and versatile, Python has strengths in
scripting, automation, data analysis, machine learning, and back-end development.

STEP-1 DOWNLOADING THE PYTHON INSTALLER

1. Go to the official Python download page for Windows


2. Find a stable Python 3 release. This tutorial was tested
with Python version 3.10.10
3. Click the appropriate link for your system to download the
executable file: Windows installer (64-bit) or Windows
installer (32-bit).

STEP-2 RUNNING THE EXECUTABLE INSTALLER

1. After the installer is downloaded, double-click the .exe


file, for example python3.10.10-amd64.exe, to run the
Python installer.
2. Select the Install launcher for all users checkbox,
which enables all users of the computer to access the
Python launcher application.
3. Select the Add python.exe to PATH checkbox, which
enables users to launch Python from the command line.

4. If you’re just getting started with Python and you want to


install it with default features as described in the dialog,
then click Install Now and go to Step 4 - Verify the Python
Installation. To install other optional and advanced
features, click Customize installation and continue.

ECE, VLITS 13
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Figure4.1. Installation of python

5. The Optional Features include common tools and resources


for Python and you can install all of them, even if you don’t
plan to use them.

Figure 4.2 Optional features of python

ECE, VLITS 14
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Select some or all of the following options


1.Documentation: recommended
2.o pip: recommended if you want to install other Python packages, such
as NumPy or pandas
3.tcl/tk and IDLE: recommended if you plan to use IDLE or follow
tutorials that use it
4.Python test suite: recommended for testing and learning
5.py launcher and for all users: recommended to enable users to launch
Python from the command line.
6. Click Next.
7.The Advanced Options dialog displays

Figure 4.3 Advanced options of python

Select the options that suit your requirements:

1.Install for all users: recommended if you’re not the only user on this computer.
2.Associate files with Python: recommended, because this option associates all
the Python file types with the launcher or editor.
3. Create shortcuts for installed applications: recommended to enable shortcuts
for Python applications.

ECE, VLITS 15
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

4. Add Python to environment variables: recommended to enable launching


Python.
5. Precompile standard library: not required, it might down the installation.
6. Download debugging symbols and Download debug binaries:
recommended only if you plan to create C or C++ extensions.
7.Make note of the Python installation directory in case you need to reference it later.
8.Click Install to start the installation.
9.After the installation is complete, a Setup was successful message displays.

Figure 4.4 Successful installation of python

STEP-3 VERIFY THE PYTHON INSTALLATION

You can verify whether the Python installation is successful either through
the command line or through the Integrated Development Environment (IDLE)
application, if you chose to install it.
Go to Start and enter cmd in the search bar. Click Command Prompt.
Enter the following command in the command prompt:

Python--version

ECE, VLITS 16
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

An example of the output is

Output python 3.10.10

You’ve installed Python on your Windows 10 computer

4.2What is Python

Python is currently the most widely used multi-purpose, high-level programming


language.

Python allows programming in Object-Oriented and Procedural paradigms. Python


programs generally are smaller than other programming languages like Java.

Programmers have to type relatively less and indentation requirement of the language,
makes them readable all the time.

Python language is being used by almost all tech-giant companies like


– Google, Amazon, Facebook, Instagram, Dropbox, Uber… etc.
The biggest strength of Python is huge collection of standard library which can
be used for the following

• Machine Learning
• GUI Applications (like Kivy, Tkinter, PyQt etc. )
• Web frameworks like Django (used by YouTube, Instagram, Dropbox)
• Image processing (like Opencv, Pillow)
• Web scraping (like Scrapy, BeautifulSoup, Selenium)
• Test frameworks
• Multimedia
Advantages of Python :-
Let’s see how Python dominates over other languages.

1.Extensive Libraries
Python downloads with an extensive library and it contain code for various purposes
like regular expressions, documentation-generation, unit- testing, web browsers,
threading, databases, CGI, email, image manipulation, and more. So, we don’t have to
write the complete code for that manually.

ECE, VLITS 17
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

2.Extensible
As we have seen earlier, Python can be extended to other languages. You can write
some of your code in languages like C++ or C. This comes in handy, especially in
projects.

3.Embeddable
Complimentary to extensibility, Python is embeddable as well. You can put your
Python code in your source code of a different language, like C++. This lets us add
scripting capabilities to our code in the other language.

4.Improved Productivity
The language’s simplicity and extensive libraries render programmers more
productive than languages like Java and C++ do. Also, the fact that you need to
write less and get more things done.

5.IOT Opportunities
Since Python forms the basis of new platforms like Raspberry Pi, it finds the
future bright for the Internet Of Things. This is a way to connect the language with the
real world.

6.Simple and Easy


When working with Java, you may have to create a class to print ‘Hello World’.
But in Python, just a print statement will do. It is also quite easy to learn, understand,
and code. This is why when people pick up Python, they have a hard time adjusting to
other more verbose languages like Java.

7.Readable
Because it is not such a verbose language, reading Python is much like reading
English. This is the reason why it is so easy to learn, understand, and code. It also
does not need curly braces to define blocks, and indentation is mandatory.
This further aids the readability of the code.

8.Object-Oriented
This language supports both the procedural and object- oriented
programming paradigms. While functions help us with code reusability, classes and

ECE, VLITS 18
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

objects let us model the real world. A class allows the encapsulation of data and
functions into one.

9.Free and Open-Source


Like we said earlier, Python is freely available. But not only can
you download Python for free, but you can also download its source code,
make changes to it, and even distribute it. It downloads with an extensive
collection of libraries to help you with your tasks.

10.Portable
When you code your project in a language like C++, you may need to make
some changes to it if you want to run it on another platform. But it isn’t
the same with Python. Here, you need to code only once, and you can run
it anywhere. This is called Write Once Run Anywhere (WORA). Howe ver ,
you need to be careful enough not to include any system- dependent features.

11.Interpreted
Lastly, we will say that it is an interpreted language. Since statements
are executed one by one, debugging is easier than in compiled languages.

4.3 Advantages of Python Over Other Languages

1.Less Coding

Almost all of the tasks done in Python requires less coding when the
same task is done in other languages. Python also has an awesome standard
library support, so you don’t have to search for any third-party libraries to
get your job done. This is the reason that many people suggest learning
Python to beginners.

2.Affordable
Python is free therefore individuals, small companies or big organizati ons
can leverage the free available resources to build applications. Python is
popular and widely used so it gives you better community support .

ECE, VLITS 19
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

The 2019 Github annual survey showed us that Python has


overtaken Java in the most popular programming language
category.

3.Python is for Everyone


Python code can run on any machine whether it is Linux, Mac or
Windows. Programmers need to learn different languages for different jobs but
with Python, you can professionally build web apps, perform data analysis
and machine learning, automate things, do web scraping and also build
games and powerful visualizations. It is an all-rounder programming
language.

4.4Disadvantages of Python
So far, we’ve seen why Python is a great choice for your project. But if you
choose it, you should be aware of its consequences as well. Let’s now see the downsides
of choosing Python over another language.

1.Speed Limitations
We have seen that Python code is executed line by line. But since
Python is interpreted, it often results in slow execution. This, however, isn’t a problem
unless speed is a focal point for the project. In other words, unless high speed is a
requirement, the benefits offered by Python are enough to distract us from its speed
limitations.

2.Weak in Mobile Computing and Browsers


While it serves as an excellent server-side language, Python is much rarely seen
on the client-side. Besides that, it is rarely ever used to implement smartphone-based
applications. One such application is called Carbonnelle.

The reason it is not so famous despite the existence of Brython is that it


isn’t that secure.
3.Design Restrictions
As you know, Python is dynamically-typed. This means that you don’t need to
declare the type of variable while writing the code. It uses duck-typing. But wait,
what’s that? Well, it just means that if it looks like a duck, it must be a duck. While this
is easy on the programmers during coding, it can raise run-time errors.

ECE, VLITS 20
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

4.Underdeveloped Database Access Layers


Compared to more widely used technologies like JDBC (Java DataBase
Connectivity) and ODBC (Open DataBase Connectivity), Python’s database access
layers are a bit underdeveloped. Consequently, it is less often applied in huge
enterprises.

5.Simple
No, we’re not kidding. Python’s simplicity can indeed be a problem. Take my
example. I don’t do Java, I’m more of a Python person. To me, its syntax is so simple
that the verbosity of Java code seems unnecessary.

4.5 What is Deep learning?


Deep learning is a machine learning technique that teaches computers to do
what comes naturally to humans: learn by example. Deep learning is a key technology
behind driverless cars, enabling them to recognize a stop sign, or to distinguish a
pedestrian from a lamppost. It is the key to voice control in consumer devices like
phones, tablets, TVs, and hands-free speakers. Deep learning is getting lots of attention
lately and for good reason. It’s achieving results that were not possible before.

In deep learning, a computer model learns to perform classification tasks


directly from images, text, or sound. Deep learning models can achieve state-of-the-art
accuracy, sometimes exceeding human-level performance. Models are trained by using
a large set of labeled data and neural network architectures that contain many layers.

4.5.1 Types of Algorithms used in Deep Learning

1.Convolutional Neural Networks (CNNs)

2. Long Short Term Memory Networks (LSTMs)

3.Recurrent Neural Networks (RNNs)

4.Generative Adversarial Networks (GANs)

5.Radial Basis Function Networks (RBFNs)

6.Multilayer Perceptrons (MLPs)

ECE, VLITS 21
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

7.Self Organizing Maps (SOMs)

8.Deep Belief Networks (DBNs)

9. Restricted Boltzmann Machines( RBMs)

10. Autoencoders

4.5.1.1Convolutional Neural Network

Convolutional Neural Networks, also known as CNN or ConvNet, come under the
category of the artificial neural networks used for image processing and visualizing.
Artificial intelligence uses deep learning to perform the task. Neural networks are
either hardware or software programmed as neurons in the human brain. The traditional
neural network takes only images of reduced resolution as inputs. CNN solves that
problem by arranging their neurons as the frontal lobe of human brains. Pre-
processing on CNN is very less when compared to other algorithms. Convolution, a
linear mathematical operation, is employed on CNN. It uses convolution instead of
general matrix multiplication in one of its layers.

4.5.1.2 Long Short Term Memory Networks (LSTMs)


LSTMs are a type of Recurrent Neural Network (RNN) that can learn and
memorize long-term dependencies. Recalling past information for long periods is the
default behavior.

LSTMs retain information over time. They are useful in time-series prediction because
they remember previous inputs. LSTMs have a chain-like structure where four
interacting layers communicate in a unique way. Besides time- series predictions,
LSTMs are typically used for speech recognition, music composition, and
pharmaceutical development.

4.5.1.3 Recurrent Neural Networks (RNNs)


RNN’s have connections that form directed cycles, which allow the outputs from
the LSTM to be fed as inputs to the current phase.

The output from the LSTM becomes an input to the current phase and can memorize
previous inputs due to its internal memory. RNNs are commonly used for image

ECE, VLITS 22
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

captioning, time-series analysis, natural-language processing, handwriting recognition,


and machine translation.

4.5.1.4 Generative Adversarial Networks (GANs)


GAN’s are generative deep learning algorithms that create new data instances that
resemble the training data. GAN has two components: a generator, which learns to
generate fake data, and a discriminator, which learns from that false information.

The usage of GANs has increased over a period of time. They can be used to improve
astronomical images and simulate gravitational lensing for dark- matter research. Video
game developers use GANs to upscale low-resolution, 2D textures in old video games
by recreating them in 4K or higher resolutions via image training.

GANs help generate realistic images and cartoon characters, create photographs of
human faces, and render 3D objects.

4.5.1.5 Radial Basis Function Networks (RBFNs)


RBFNs are special types of feedforward neural networks that use radial basis
functions as activation functions. They have an input layer, a hidden layer, and an
output layer and are mostly used for classification, regression, and time-series
prediction.

4.5.1.6 Multilayer Perceptrons (MLPs)


MLPs are an excellent place to start learning about deep learning technology. MLPs
belong to the class of feedforward neural networks with multiple layers of perceptrons
that have activation functions. MLPs consist of an input layer and an output layer that
are fully connected. They have the same number of input and output layers but may
have multiple hidden layers and can be used to build speech-recognition, image-
recognition, and machine-translation software.

4.5.1.7 Self Organizing Maps (SOMs)


Professor Teuvo Kohonen invented SOMs, which enable data visualization to reduce
the dimensions of data through self-organizing artificial neural networks.

Data visualization attempts to solve the problem that humans cannot easily visualize
high-dimensional data. SOMs are created to help users understand this high-
dimensional information.

ECE, VLITS 23
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

4.5.1.8 Deep Belief Networks (DBNs)


DBNs are generative models that consist of multiple layers of stochastic, latent
variables. The latent variables have binary values and are often called hidden units.

DBNs are a stack of Boltzmann Machines with connections between the layers, and
each RBM layer communicates with both the previous and subsequent layers. Deep
Belief Networks (DBNs) are used for image- recognition, video-recognition, and
motion-capture data.

4.5.1.9Restricted Boltzmann Machines (RBMs)


Developed by Geoffrey Hinton, RBMs are stochastic neural networks that can learn
from a probability distribution over a set of inputs.

This deep learning algorithm is used for dimensionality reduction, classification,


regression, collaborative filtering, feature learning, and topic modeling. RBMs
constitute the building blocks of DBNs.

RBMs consist of two layers:-


1.Visible units

2.Hidden unit

Each visible unit is connected to all hidden units. RBMs have a bias unit that is
connected to all the visible units and the hidden units, and they have no output nodes.

4.5.1.10 Autoencoders
Autoencoders are a specific type of feedforward neural network in which the input
and output are identical. Geoffrey Hinton designed autoencoders in the 1980s to solve
unsupervised learning problems. They are trained neural networks that replicate the
data from the input layer to the output layer. Autoencoders are used for purposes such
as pharmaceutical discovery, popularity prediction, and image processing.

4.6 How Deep Learning works?


Most deep learning methods use neural network architectures, which is why deep
learning models are often referred to as deep neural networks.

The term “deep” usually refers to the number of hidden layers in the neural network.
only contain 2-3 hidden layers, while deep networks can have as many as 150.

ECE, VLITS 24
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Deep learning models are trained by using large sets of labeled data and neural network
architectures that learn features directly from the data without the need for manual
feature extraction.

One of the most popular types of deep neural networks is known as


convolutional neural networks (CNN or ConvNet). A CNN convolves learned
features with input data, and uses 2D convolutional layers, making this architecture
well suited to processing 2D data, such as images.
CNNs eliminate the need for manual feature extraction, so you do not need to identify
features used to classify images. The CNN works by extracting features directly from
images. The relevant features are not pretrained; they are learned while the network
trains on a collection of images. This automated feature extraction makes deep learning
models highly accurate for computer vision tasks such as object classification.

What's the Difference Between Machine Learning and Deep Learning?


Deep learning is a specialized form of machine learning. A machine learning
workflow starts with relevant features being manually extracted from images. The
features are then used to create a model that categorizes the objects in the image. With
a deep learning workflow, relevant features are automatically extracted from images. In
addition, deep learning performs “end-to-end learning” – where a network is given raw
data and a task to perform, such as classification, and it learns how to do this
automatically.

Another key difference is deep learning algorithms scale with data, whereas shallow
learning converges. Shallow learning refers to machine learning methods that plateau
at a certain level of performance when you add more examples and training data to the
network.

A key advantage of deep learning networks is that they often continue to improve as
the size of your data increases.

Applications of Deep learning


• Virtual Assistants
• News Aggregation and Fake News Detection
• Image Coloring
• Image Captioning

ECE, VLITS 25
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

• Self Driving Cars


• Natural Language Processing
• Visual Recognition

4.5 Python Development Steps


Guido Van Rossum published the first version of Python code (version 0.9.0) at
alt.sources in February 1991. This release included already exception handling,
functions, and the core data types of list, dict, str and others. It was also object
oriented and had a module system. Python version 1.0 was released in
January 1994. The major new features included in this release were the functional
programming tools lambda, map, filter and reduce, which Guido Van Rossum never
liked.Six and a half years later in October 2000, Python 2.0 was introduced. This release
included list comprehensions, a full garbage collector and it was supporting
unicode.Python flourished for another 8 years in the versions 2.x before the next major
release as Python 3.0 (also known as "Python 3000" and "Py3K") was released. Python
3 is not backwards compatible with Python 2.x. The emphasis in Python 3 had been on
the removal of duplicate programming constructs and modules, thus fulfilling or
coming close to fulfilling the 13th law of the Zen of Python: "There should be one --
and preferably only one -- obvious way to do it."Some changes in Python 7.3:

• Print is now a function


• Views and iterators instead of lists
• The rules for ordering comparisons have been simplified. E.g. a heterogeneous list
cannot be sorted, because all the elements of a list must be comparable to each other.

• There is only one integer type left, i.e. int. long is int as well.
• The division of two integers returns a float instead of an integer. "//" can be used to
have the "old" behaviour.

• Text Vs. Data Instead Of Unicode Vs. 8-bit

Purpose :-

We demonstrated that our approach enables successful segmentation of intra-retinal


layers—even with low-quality images containing speckle noise, low contrast, and
different intensity ranges throughout—with the assistance of the ANIS feature.

ECE, VLITS 26
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

CHAPTER 5
SYSTEM TEST

The purpose of testing is to discover errors. Testing is the process of trying to discover
every conceivable fault or weakness in a work product. It provides a way to check the
functionality of components, sub assemblies, assemblies and/or a finished product It is
the process of exercising software with the intent of ensuring that the Software system
meets its requirements and user expectations and does not fail in an unacceptable
manner. There are various types of test. Each test type addresses a specific testing
requirement.

5.1 TYPES OF TESTS


Unit testing
Unit testing involves the design of test cases that validate that the internal program logic
is functioning properly, and that program inputs produce valid outputs. All decision
branches and internal code flow should be validated. It is the testing of individual
software units of the application .it is done after the completion of an individual unit
before integration. This is a structural testing, that relies on knowledge of its
construction and is invasive. Unit tests perform basic tests at component level and test
a specific business process, application, and/or system configuration. Unit tests ensure
that each unique path of a business process performs accurately to the documented
specifications and contains clearly defined inputs and expected results.

Integration testing
Integration tests are designed to test integrated software components to determine if
they actually run as one program. Testing is event driven and is more concerned with
the basic outcome of screens or fields. Integration tests demonstrate that although the
components were individually satisfaction, as shown by successfully unit testing, the
combination of components is correct and consistent. Integration testing is specifically
aimed at exposing the problems that arise from the combination of components.

ECE, VLITS 27
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Functional test
Functional tests provide systematic demonstrations that functions tested are available
as specified by the business and technical requirements, system documentation, and
user manuals.

Functional testing is centered on the following items:

Valid Input : identified classes of valid input must be accepted.

Invalid Input : identified classes of invalid input must be rejected.

Functions : identified functions must be exercised.

Output : identified classes of application outputs must be


exercised.
Systems/Procedures : interfacing systems or procedures must be
invoked.

Organization and preparation of functional tests is focused on requirements, key


functions, or special test cases. In addition, systematic coverage pertaining to identify
Business process flows; data fields, predefined processes, and successive processes
must be considered for testing. Before functional testing is complete, additional tests
are identified and the effective value of current tests is determined.

System Test
System testing ensures that the entire integrated software system meets requirements. It tests a
configuration to ensure known and predictable results. An example of system testing is the
configuration oriented system integration test. System testing is based on process descriptions
and flows, emphasizing pre-driven process links and integration points.

White Box Testing


White Box Testing is a testing in which in which the software tester has knowledge of
the inner workings, structure and language of the software, or at least its purpose. It
is purpose. It is used to test areas that cannot be reached from a black box level.

Black Box Testing


Black Box Testing is testing the software without any knowledge of the inner workings,
structure or language of the module being tested. Black box tests, as most other kinds

ECE, VLITS 28
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

of tests, must be written from a definitive source document, such as specification or


requirements document, such as specification or requirements document. It is a testing
in which the software under test is treated, as a black box .you cannot “see” into it. The
test provides inputs and responds to outputs without considering how the software
works.

Unit Testing

Unit testing is usually conducted as part of a combined code and unit test phase of the
software lifecycle, although it is not uncommon for coding and unit testing to be
conducted as two distinct phases.

Test strategy and approach


Field testing will be performed manually and functional tests will be written in detail.

Test objectives
• All field entries must work properly.
• Pages must be activated from the identified link.
• The entry screen, messages and responses must not be delayed.

Features to be tested
• Verify that the entries are of the correct format
• No duplicate entries should be allowed
• All links should take the user to the correct page.
Integration Testing
Software integration testing is the incremental integration testing of two or more
integrated software components on a single platform to produce failures caused by
interface defects.

The task of the integration test is to check that components or software applications,
e.g. components in a software system or – one step up – software applications at the
company level – interact without error.

Test Results: All the test cases mentioned above passed successfully. No defects
encountered.

ECE, VLITS 29
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Acceptance Testing
User Acceptance Testing is a critical phase of any project and requires significant
participation by the end user. It also ensures that the system meets the functional
requirements.

Test Results: All the test cases mentioned above passed successfully. No
defects encountered.

ECE, VLITS 30
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

CHAPTER 6
Modules

The proposed system consists of following modules

1. Tensor flow
2. Numpy
3. Pandas

6.1 Tensorflow

TensorFlow was developed by the Google Brain team for internal Google use. It was
released under the Apache 2.0 open-source license on November 9, 2015. TensorFlow
is an open source framework developed by Google researchers to run machine learning,
deep learning and other statistical and predictive analytics workloads. Like similar
platforms, it's designed to streamline the process of developing and executing advanced
analytics applications for users such as data scientists, statisticians and predictive
modelers.

The TensorFlow software handles data sets that are arrayed as computational nodes in
graph form. The edges that connect the nodes in a graph can represent multidimensional
vectors or matrices, creating what are known as tensors. Because TensorFlow programs
use a data flow architecture that works with generalized intermediate results of the
computations, they are especially open to very large-scale parallel processing
applications, with neural networks being a common example.

The framework includes sets of both high-level and low-level APIs. Google
recommends using the high-level ones when possible to simplify data pipeline
development and application programming. However, knowing how to use the low-
level APIs -- called TensorFlow Core -- can be valuable for experimentation and
debugging of applications, the company says; it also gives users a "mental model" of
the machine learning technology's inner workings, in Google's words.

TensorFlow applications can run on either conventional CPUs or higher- performance


graphics processing units (GPUs), as well as Google's own tensor processing units
(TPUs), which are custom devices expressly designed to speed up TensorFlow jobs.

ECE, VLITS 31
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Google's first TPUs, detailed publicly in 2016, were used internally in conjunction with
TensorFlow to power some of the company's applications and online services,
including its RankBrain search algorithm and Street View mapping technology.

In early 2018, Google furthered its external TensorFlow efforts by making the second
generation of TPUs available to Google Cloud Platform users for training and running
their own machine learning models. TensorFlow-based workloads are billed on a per-
second basis; the Cloud TPU service initially was launched as a beta program with
only "limited quantities" of the devices available for use, according to Google

Applications of TensorFlow
For the most part, TensorFlow applications are advanced and large-scale AI
undertakings in the realms of machine learning and deep learning. In powering Google's
Rank Brain machine learning system, TensorFlow has been employed to improve the
information retrieval capabilities of the company's flagship search engine.

Google has also used the framework for applications that include automatic email
response generation, image classification and optical character recognition, as well as a
drug-discovery application that the company worked on with researchers from Stanford
University. Other companies listed on the TensorFlow website as users of the
framework include Airbnb, Coca-Cola, eBay, Intel, Qualcomm, SAP, Twitter, Uber
and Snapchat developer Snap Inc. Another user is STATS LLC.

TensorFlow-based deep learning has also been a part of experiments and tests
involving one of the larger-scaled proposed innovations today, that is self-
driving cars.Some smaller-scale uses have been found, too. For example, a
small Japanese farm uses TensorFlow to sort cucumbers based on their
textures.

6.2 Numpy

NumPy is a general-purpose array-processing package. It provides a high-


performance multidimensional array object, and tools for working with these arrays. It

ECE, VLITS 32
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

is the fundamental package for scientific computing with Python. It is open-source


software. It contains various features including these important ones:
• A powerful N-dimensional array object
• Sophisticated (broadcasting) functions
• Tools for integrating C/C++ and Fortran code
• Useful linear algebra, Fourier transform, and random number capabilities
Besides its obvious scientific uses, NumPy can also be used as an efficient multi-
dimensional container of generic data. Arbitrary data-types can be defined using
Numpy which allows NumPy to seamlessly and speedily integrate with a wide variety
of databases.
Installation: Mac and Linux users can install NumPy via pip command: pip install
• Windows does not have any package manager analogous to that in linux or mac.
Please download the pre-built windows installer for NumPy from here (according
to your system configuration and Python version). And then install the packages
manually.
Note: All the examples discussed below will not run on an online IDE. 1. Arrays in
NumPy: NumPy’s main object is the homogeneous multidimensional array.
• It is a table of elements (usually numbers), all of the same type, indexed by a
tuple of positive integers.
• In NumPy dimensions are called axes. The number of axes is rank.
• NumPy’s array class is called ndarray. It is also known by t he alias
array
NumPy, which stands for Numerical Python, is a library consisting of
multidimensional array objects and a collection of routines for processing those
arrays. Using NumPy, mathematical and logical operations on arrays can be
performed. This tutorial explains the basics of NumPy such as its architecture and
environment. It also discusses the various array functions, types of indexing, etc.
An introduction to Matplotlib is also provided.
6.3 Pandas

pandas is a Python package providing fast, flexible, and expressive data structures
designed to make working with “relational” or “labeled” data both easy and intuitive. It
aims to be the fundamental high-level building block for doing practical, real-world
data analysis in Python. Additionally, it has the broader goal of becoming the most

ECE, VLITS 33
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

powerful and flexible open source data analysis/manipulation tool available in any
language. It is already well on its way toward this goal.
pandas is well suited for many different kinds of data:

• Tabular data with heterogeneously-typed columns, as in an SQL table or Excel


spreadsheet
• Ordered and unordered (not necessarily fixed-frequency) time series data.
• Arbitrary matrix data (homogeneously typed or heterogeneous) with row and column
labels
• Any other form of observational / statistical data sets. The data need not be
labeled at all to be placed into a pandas data structure
he two primary data structures of pandas, Series (1-dimensional) and
DataFrame (2-dimensional), handle the vast majority of typical use cases in finance,
statistics, social science, and many areas of engineering. For R users, DataFrame
provides everything that R’s data.frame provides and much more. pandas is built
on top of NumPy and is intended to integrate well within a scientific computing
environment with many other 3rd party libraries.
Here are just a few of the things that pandas does well:

• Easy handling of missing data (represented as NaN) in floating point as well as non-
floating point data
• Size mutability: columns can be inserted and deleted from DataFrame and higher
dimensional objects
• Automatic and explicit data alignment: objects can be explicitly aligned to a set of
labels, or the user can simply ignore the labels and let Series, DataFrame, etc.
automatically align the data for you in computations
• Powerful, flexible group by functionality to perform split-apply-combine operations on
data sets, for both aggregating and transforming data
• Make it easy to convert ragged, differently-indexed data in other Python and NumPy
data structures into DataFrame objects
• Intelligent label-based slicing, fancy indexing, and subsetting of large data sets

• Intuitive merging and joining data sets


• Flexible reshaping and pivoting of data sets
• Hierarchical labeling of axes (possible to have multiple labels per tick)

ECE, VLITS 34
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

• Robust IO tools for loading data from flat files (CSV and delimited), Excel files,
databases, and saving / loading data from the ultrafast HDF5 format
• Time series-specific functionality: date range generation and frequency conversion,
moving window statistics, date shifting, and lagging.
Many of these principles are here to address the shortcomings frequently experienced
using other languages / scientific research environments. For data scientists, working
with data is typically divided into multiple stages: munging and cleaning data,
analyzing / modeling it, then organizing the results of the analysis into a form suitable
for plotting or tabular display. pandas is the ideal tool for all of these tasks.
Some other notes

• pandas is fast. Many of the low-level algorithmic bits have been extensivel y
tweaked in Cython code. However, as with anything else generalization usually
sacrifices performance. So if you focus on one feature for your application you
may be able to create a faster specialized tool.
• pandas is a dependency of statsmodels, making it an important part of the
statistical computing ecosystem in Python.
• pandas has been used extensively in production in financial applications.

ECE, VLITS 35
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

CHAPTER 7
IMPLEMENTATION

Leaf disease detection using deep learning is a popular area of research that involves
developing computer algorithms capable of detecting and classifying cotton diseases
from digital images of cotton leaves. This technology has the potential to revolutionize
agriculture by allowing farmers to quickly and accurately identify and treat diseased
cottons, thereby reducing crop losses and increasing yields.

Deep learning is a subset of machine learning that utilizes artificial neural networks
with multiple layers to process and analyze large datasets. In the case of leaf disease
detection, deep learning algorithms are trained using thousands of images of healthy
and diseased cottons to learn the features that distinguish healthy cottons from those
affected by disease. Once trained, these algorithms can be used to classify new images
of cotton leaves as either healthyor diseased.

There are several deep learning models that can be used for leaf disease detection,
including Convolutional Neural Networks (CNNs) and Deep Convolutional Neural
Networks (DCNNs). These models have been used successfully to detect a wide range
of cotton diseases, including cotton leaf mold, citrus greening, and apple scab.

To develop an effective leaf disease detection system, several steps must be followed.
These include collecting a large dataset of cotton images, pre- processing the images to
remove noise and enhance features, training the deep learning model on the pre-
processed images, and validating the model using a separate set of images. Once
the model has been validated, it can be used to classify new images of cotton
leaves as either healthy or diseased.
Overall, leaf disease detection using deep learning has the potential to
significantly improve agricultural practices by allowing farmers to quickly and

accurately identify and treat diseased cottons, thereby increasing crop yields
and reducing losses.

ECE, VLITS 36
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

7.1 The general steps involved in leaf disease detection

Data collection:
The first step is to collect a dataset of images of leaves affected by different
diseases, as well as images of healthy leaves. The dataset should be diverse,
containing leaves from different cotton species, different lighting
conditions, angles, and backgrounds.

Data pre-processing:
The collected dataset needs to be pre-processed to ensure that the images
are of the same size and format. Pre-processing may also involve data
augmentation techniques such as flipping, rotating, and scaling the images
to increase the diversity of the dataset.

Model selection:
The next step is to select a deep learning model suitable for image
classification. Popular models for this task include Convolutional Neural
Networks (CNNs) such as VGG, ResNet, and Inception.

Model training:
The selected model is then trained on the preprocessed dataset. The training
involves feeding the model with input images and their corresponding labels
(disease or healthy). The model then learns to classify the images based on
the patterns and features it learns from the dataset.

Model evaluation:
The trained model is then evaluated on a separate dataset to assess its
performance. The evaluation metrics used may include accuracy, precision,
recall, and F1 score.

Deployment:
The final step is to deploy the trained model to a production environment where it can
be used for real-time disease detection. This can be done by integrating the model into
an application or web-based system that can process images of leaves and provide a
diagnosis.

ECE, VLITS 37
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

7.2Code Used In Python

#Import necessary libraries


from flask import Flask, render_template, request

import numpy as np import os

from tensorflow.keras.preprocessing.image import load_img from


tensorflow.keras.preprocessing.image import img_to_array from
tensorflow.keras.models import load_model

filepath = 'C:\\Users\\navee\\OneDrive\\Desktop\\Cotton-Leaf- Disease-


Prediction-main\\model.h5'
model = load_model(filepath) print(model)

print("Model Loaded Successfully")

def pred_cotton_dieas(cotton_cotton):
test_image = load_img(cotton_cotton, target_size = (128, 128)) # load image
print("@@ Got Image for prediction")

test_image = img_to_array(test_image)/255 # convert image to np array and


normalize
test_image = np.expand_dims(test_image, axis = 0) # change dimention 3D to 4D
result = model.predict(test_image) # predict diseased palnt or not print('@@ Raw
result = ', result)

pred = np.argmax(result, axis=1) print(pred)


if pred==0:
return "Cotton - Bacteria Spot Disease", 'Cotton-Bacteria Spot.html'

elif pred==1:
return "Cotton - Early Blight Disease", 'Cotton-Early_Blight.html'

elif pred==2:
return "Cotton - Healthy and Fresh", 'Cotton-Healthy.html'

ECE, VLITS 38
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

elif pred==3:
return "Cotton - Late Blight Disease", 'Cotton - Late_blight.html'

elif pred==4:
return "Cotton - Leaf Mold Disease", 'Cotton - Leaf_Mold.html'

elif pred==5:
return"Cotton-Septoria Leaf SpotDisease",'Cotton - Septoria_leaf_spot.html'
elif pred==6:
return "Cotton - Target Spot Disease", 'Cotton - Target_Spot.html'

elif pred==7:
return "Cotton - Tomoato Yellow Leaf Curl Virus Disease", 'Cotton -
Cotton_Yellow_Leaf_Curl_Virus.html'
elif pred==8:
return"Cotton- Cotton MosaicVirus Disease", 'Cotton - Cotton_mosaic_virus.html'
elif pred==9:
return "Cotton - Two Spotted Spider Mite Disease", 'Cotton - Two-
spotted_spider_mite.html'
# Create flask instance app = Flask( name )

# render index.html page


@app.route("/", methods=['GET', 'POST'])
def home():
return render_template('index.html')

# get input image from client then predict class and render respective .html page
for solution
@app.route("/predict", methods = ['GET','POST'])
def predict():
if request.method == 'POST':
file = request.files['image'] # fet input
filename = file.filename
print("@@ Input posted = ", filename)

ECE, VLITS 39
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

file_path = os.path.join('C:/Users/navee/OneDrive/Desktop/Cotton-
Leaf-Disease-Prediction-main/static/upload/', filename)
file.save(file_path)

print("@@ Predicting class……….")


pred, output_page = pred_cotton_dieas(cotton_cotton=file_path)

return render_template(output_page, pred_output = pred, user_image =


file_path)

# For local system & cloud if name == " main ":


app.run(threaded=False,port=8081)

ECE, VLITS 40
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

CHAPTER 8
RESULTS
Leaf disease detection using deep learning has shown promising results in recent years.
The use of deep learning models, such as Convolutional Neural Networks (CNNs), has
significantly improved the accuracy of leaf disease detection systems.

One of the most widely used datasets for leaf disease detection is the CottonVillage
dataset, which contains images of healthy and diseased leaves from various cotton
species. Researchers have used this dataset to train deep learning models, such as
CNNs, to accurately identify different types of leaf diseases.

The performance of these models varies depending on the architecture and training
parameters used. However, some studies have reported very high accuracy rates for leaf
disease detection. For example, a study published in the journal Computers and
Electronics in Agriculture reported an accuracy rate of 99.53% for cotton leaf disease
detection using a deep learning model based on the Inception-v3 architecture.

Overall, leaf disease detection using deep learning has shown great potential for
improving crop yield and reducing crop loss due to diseases. With further research and
development, it is likely that we will see even more accurate and efficient systems for
detecting and diagnosing leaf diseases in the future.

Figure 8.1 output at the python

To get our application we can use the IP address in the google

ECE, VLITS 41
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Figure 8.2 prediction of Leaf disease photo uploadation

figure 8.3 Detected cotton yellow leaf curl virus disease

ECE, VLITS 42
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Figure 8.4 Detected Septoria leaf spot disease

Figure 8.5 Detected Bacteria spot disease

ECE, VLITS 43
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Figure 8.6 Detected Target spot disease

Figure 8.7 Detected Early Blight disease

ECE, VLITS 44
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

Figure 8.7 Detected Healthy and fresh leaf

ECE, VLITS 45
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

CHAPTER 8
CONCLUSION
This project presents an automated, low cost and easy to use end-to- end
solution to one of the biggest challenges in the agricultural domain for farmers –
precise, instant and early diagnosis of crop diseases and knowledge of disease
outbreaks - which would be helpful in quick decision making for measures to be
adopted for disease control. This proposal innovates on known prior art with the
application of deep Convolutional Neural Networks (CNNs) for disease classification,
introduction of social collaborative platform for progressively improved accuracy,
usage of geocoded images for disease density maps and expert interface for analytics.

High performing deep CNN model “Inception” enables real time classification of
diseases in the Cloud platform via a user facing mobile app. Collaborative model
enables continuous improvement in disease classification accuracy by automatically
growing the Cloud based training dataset with user added images for retraining the
CNN model. User added images in the Cloud repository also enable rendering of
disease density maps based on collective disease classification data and availability of
geolocation information within the images.

Overall, the results of our experiments demonstrate that the proposal has significant
potential for practical deployment due to multiple dimensions the Cloud based
infrastructure is highly scalable and the underlying algorithm works accurately even
with large number of disease categories, performs better with high fidelity real -life
training data, improves accuracy with increase in the training dataset, is capable of
detecting early symptoms of diseases and is able to successfully differentiate between
diseases of the same family.

ECE, VLITS 46
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

REFERENCES
1. Liu, Bin, "Identification of apple leaf diseases based on deep convolutional neural
networks
2. Jeon, Wang-Su, and Sang-Yong Rhee. "Cotton leaf recognition using a convolution
neural network." International Journal of Fuzzy Logic and Intelligent Systems 17.1
(2017): 26-34.
3. Amara, Jihen, Bassem Bouaziz, and Alsayed Algergawy. "A Deep Learning-based
Approach for Banana Leaf Diseases Classification." BTW (Workshops). 2017.
4. Lee, Sue Han, et al. "How deep learning extracts and learns leaf features for cotton
classification." Pattern Recognition 71 (2017): 1-13.
5. Sladojevic, Srdjan, et al. "Deep neural networks-based recognition of cotton diseases
by leaf image classification." Computational intelligence and neuroscience 2016
(2016).
6. Lee, Sue Han, et al. "Cotton Identification System based on a Convolutional Neural
Network for the LifeClef 2016 Cotton ClassificationTask." CLEF (Working Notes).
2016.
7. He, Kaiming, et al. "Deep residual learning for image recognition." Proceedings of the
IEEE conference.
8. K.Padmavathi, and K.Thangadurai,“Implementation of RGB and Gray scale images in
cotton leaves disease detection –comparative study,”
9. Kiran R. Gavhale, and U. Gawande, “An Overview of the Research on Cotton Leaves
International Journal of Pure and Applied Mathematics Special Issue 882Disease
detection using Image Processing Techniques,” IOSR J. of Compu. Eng.
10. Y. Q. Xia, Y. Li, and C. Li, “Intelligent Diagnose System of Wheat
Diseases Based on Android Phone,” J. of Infor. & Compu. Sci., vol. 12,
pp. 6845-6852, Dec. 2015.

ECE, VLITS 47
IMPLEMENTATION OF DETECTION AND CLASSIFICATION OF COTTON LEAF
DISEASE USING LIGHT WEIGHT CNN ARCHITECTURE

ECE, VLITS 48

You might also like