You are on page 1of 44

A FLOWER RECOGNITION SYSTEM BASED ON

IMAGE PROCESSING AND NEURAL NETWORK

A PROJECT REPORT

Submitted by
AMUTHAPRIYA.K
MARILAKSHMI.P

In a partial fulfillment for the award of the degree


Of
BACHELOR OF ENGINEERING
In
ELECTRONICS AND COMMUNICATION ENGINEERING

SREE SOWDAMBIKA COLLEGE OF ENGINEERING

ANNA UNIVERSITY::CHENNAI 600 025

JUNE 2022
ANNA UNIVERSITY:CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this project report “FLOWER RECOGNITION SYSTEM


BASED ON IMAGEPROCESSING AND NEURAL NETWORK” is the
bonafide work of “AMUTHAPRIYA K(921818106001), MARILAKSHMI
P(921818106015)” who carried out the project work under mysupervision.

SIGNATURE SIGNATURE
Mr.ELAYARAJA M.E., Mr.S.ARAVIND M.E.,
HEAD OF THE DEPARTMENT SUPERVISOR
Associate Professor, Assistant Professor,
Department of Electronics and Department of Electronics and
Communication Engineering Communication Engineering
Sree Sowdambika College Sree Sowdambika College
of Engineering, of Engineering,
Aruppukottai. Aruppukottai.

Submitted for the Project VIVA-VOCE held on ………………………..at

Sree Sowdambika College of Engineering, Aruppukottai.

INTERNAL EXAMINER EXTERNAL EXAMINER


ABSTRACT

Recognition is one of computer vision high level processing, the


recognition process is mainly based on classifying object by obtaining and
analyzing their main distinguishable features. In this paper and as a benchmark
dataset we have used Oxford 102 flowers dataset, as it consists of 8189 flowers
images that belong to 102 flower species, each species contains 40 to 251 images
that has been gathered using internet searching or directly from photographers.
we are introducing a flower recognition system for the Oxford 102 flowers dataset
using image processing techniques, combined with Convolutional neural
networks (CNN), based on our proposed methodology, this paper will be divided
into 4 main steps; starting with image enhancement, cropping of images used to
modify dataset images to create more suitable dataset for next stage. Then image
segmentation introduced to separate the foreground (the flower object) from the
background (rest of image) where chan-vese active contour has been used, and
for the features extraction, all of color, texture and shape have been used. Finally;
the classification process where Back-Propagation Convolutional Neural
Network (CNN) used. We have achieved (91%) as an accuracy rate.
Table of Contents
ABSTRACT

CHAPTER 1 ...............................................................................................................................................7
INTRODUCTION ........................................................................................................................................7
1.1 IMAGE PROCESSING ...........................................................................................................9
1.2 FUNDAMENTAL STEPS ..........................................................................................................10
1.2.1 IMAGE ACQUISITION ......................................................................................................10
1.2.2 IMAGE PRE-PROCESSING ...............................................................................................10
1.2.3.TRAINING PHASE ............................................................................................................11
1.2.4.VALIDATION PHASE .......................................................................................................11
1.2.5.OUTPUT PREDICTION .....................................................................................................11
1.3 IMAGE PROCESSING GOAL ...................................................................................................12
1.4 IMAGE ENHANCEMENT .........................................................................................................12
1.5 IMAGE RESTORATION ...........................................................................................................12
1.6 IMAGE ANALYSIS ...................................................................................................................13
1.7 FEATURE EXTRACTION .........................................................................................................13
1.8 DEEP LEARNING ......................................................................................................................13
1.9 DEEP LEARNING METHODS..................................................................................................14
1.10 CONVOLUTIONAL NEURAL NETWORK .......................................................................................14
1.11 ARCHITECTURE...........................................................................................................................15
1.11.1 CONVOLUTIONAL LAYERS .........................................................................................16
1.11.2 POOLING LAYERS ..........................................................................................................17
1.11.3 FULLY CONNECTED LAYERS ......................................................................................17
1.11.4 RECEPTIVE FIELD ..........................................................................................................17
1.11.5 WEIGHTS ..........................................................................................................................18
1.12 DISTINGUISHING FEATURE ................................................................................................19
1.13 LITERATURE SURVEY ..........................................................................................................20
1.14 EXISTING METHOD ...............................................................................................................25
1.14.1 CONVOLUTIONAL NEURAL NETWORKS .................................................................25
1.14.2 ARCHITECTURE ..............................................................................................................25
1.14.3 PYCHARM.........................................................................................................................26
1.14.4 MACHINE LEARNING ALGORITHM ...........................................................................26
CHAPTER 2 ..........................................................................................................................................28
PROPOSED METHOD .....................................................................................................................28
2.1 BLOCK DIAGRAM ....................................................................................................................29
2.2 FUNCTIONAL BLOCKS ...........................................................................................................29
2.3 SOFTWARE REQUIREMENTS ................................................................................................29
2.4 ARCHITECTURE .......................................................................................................................29
2.4.1 CONVOLUTIONAL LAYER..............................................................................................30
2.4.2 GLOBAL POOLING LAYER .............................................................................................30
2.4.3 FLATTENING LAYER .......................................................................................................31
2.4.4 FULLY CONNECTED LAYER ..........................................................................................31
2.4.5 SOFTMAX LAYER .............................................................................................................31
2.5 PRE-PROCESSING ....................................................................................................................32
2.6 TRANSFER LEARNING ...........................................................................................................32
2.7 IMPLEMENTATION.................................................................................................................33
2.7.1 PYTHON TKINTER PACKAGE ........................................................................................33
2.7.3 PYCHARM...........................................................................................................................33
2.7.4 DATASETS ..........................................................................................................................33
2.7.5 PYTHON ..............................................................................................................................33
2.8 MACHINE LEARINING LIBRARIES ......................................................................................35
2.8.1 NUMBY ..............................................................................................................................35
2.8.2 PYTORCH ............................................................................................................................35
2.9 MODULES .................................................................................................................................35
2.10 OUTPUT....................................................................................................................................38
CHAPTER 3 .........................................................................................................................................40
CONCLUSION..................................................................................................................................40
CONCLUSION..................................................................................................................................41
FUTUURE SCOPE ...........................................................................................................................42
REFERENCES ..................................................................................................................................43
LIST OF FIGURES

Figure 1 Biological Neuraon & Artificial neuron..................................................................................15


Figure 2 CNN layers arranged in 3 dimensions....................................................................................19
Figure 3 Existing Method ......................................................................................................................25
Figure 4 Proposed Method.....................................................................................................................29
Figure 5 Training accuracy & Validation accuracy ...............................................................................38
Figure 6 Recognize the flower name .....................................................................................................38
Figure 7 Recognize the flower name & save it new folder ..................................................................39
CHAPTER 1

INTRODUCTION
INTRODUCTION

Image is most probably used metric to recognize images , in recent


years , Image recognition has gained massive consideration from researches for
the reason that human actions by many different applications of security. It is also
represented that human actions by many different applications of security. It is
also represented as an Artificial Intelligence based application which is used to
identify a person by analyzing patterns based on the person’s facial texures and
shape. Image metrics can be non-intrusive compared with other metric features
alike size, colour,contrast,etc… Images arre taken even beyond users ability and
then can be used for security related applications like criminal detection, face
tracking,airport security and forensic survillence systems.

Flower recognition is an AI system which is used to identifying or


verifying a flower captured from images. Then they are compared with the
previously saved database. Flower metrice embodies known training images,
categorize those images with known different classes and then they are stored in
the database,when a test image is given to the system it is classified and compared
with stored training database.

The Flower recognition problem can be divided into two main


stages:flower verification and flower identification. The detection stage is the
first stage;it includes identifying and locating a features in an flower.

The recognition stage is the second stage; it includes feature


extraction,where important information for discrimination is saved , and the
matching, where the recognition result is given with the aid of a flower database.
1.1 IMAGE PROCESSING
Image processing is a method to perform some operations on an
image, in order to get an enhanced image or to extract some useful information
from it. It is a type of signal processing in which input is an image and output
may be image or characteristics/features associated with that image. Nowadays,
image processing is among rapidly growing technologies. It forms core research
area within engineering and computer science disciplines too. There are two types
of methods used for image processing namely, analogue and digital image
processing.

Analogue image processing can be used for the hard copies like
printouts and photographs. Image analysts use various fundamentals of
interpretation while using these visual techniques. Digital image processing
techniques help in manipulation of the digital images by using computers. The
three general phases that all types of data have to undergo while using digital
technique are pre processing, enhancement, and display and information
extraction. Digital Image Processing refers to processing of the image in digital
form.

Modern cameras may directly take the image in digital form but
generally images are originated in optical form. They are captured by video
cameras and digitalized. The digitalization process includes sampling,
quantization. Then these images are processed by the five fundamental processes,
at least any one of them, not necessarily all of them.

Image processing basically includes the following three steps:

• Importing the image via image acquisition tools


• Analysing and manipulating the image.
• Output in which result can be altered image or report that is based on
image analysis.
1.2 FUNDAMENTAL STEPS
• Image Acquisition
• Image Pre-processing
• Training phase
• Validation phase
• Output prediction

1.2.1 IMAGE ACQUISITION

Image acquisition in Image Processing can be broadly defined as the action


of retrieving an image from some source, conventionally a hardware-predicated
source, so it can be passed through whatever processes need to occur afterward.
Performing image acquisition in image processing is always the first step in the
workflow sequence because, without an image, no processing is possible.

1.2.2 IMAGE PRE-PROCESSING

In imaging science, image processing is processing of images utilizing


mathematical operations by utilizing any form of signal processing for which
the input is an image, a series of images, or a video, such as a photograph or
video frame; the output of image processing may be either an image or a set of
characteristics or parameters cognate to the image. Most image-processing
techniques involve treating the image as a two-dimensional signal and applying
major image processing task.
1.2.3.TRAINING PHASE

This the step where the actual training of the model takes place. In this
phase the model extracts features such as color and shape of the flower used for
training. Each of the training images will be passed through a stack pf layers
which includes convolutional layer , relu layer,pooling layer and fully connected
layer.

1.2.4.VALIDATION PHASE

Once the model completes its training from the training set it tries to
improve itself by tuning its weight values . The loss function used is categorical
cross entropy and the optimizer used is stochastic gradient descent.

1.2.5.OUTPUT PREDICTION

Once the validation phase is over, the model is ready to take an unknown
image of a flower and predict its name from the knowledge it gained during traing
and validation phase. Once the classification is done by the model,it displays the
common name of that flower.
1.3 IMAGE PROCESSING GOAL

In virtually all image processing applications, however, the goal is to


extract information-from the image data. Obtaining the information desired may
require filtering, transforming, coloring, interactive analysis, or any number of
other methods.

1.4 IMAGE ENHANCEMENT

Image enhancement techniques have been widely utilized in many


applications of image processing where the subjective quality of images is
consequential for human interpretation. Contrast is a paramount factor in any
subjective evaluation of image quality. Contrast is engendered by the difference
in luminance reflected from two adjacent surfaces. In other words, contrast is the
difference in visual properties that makes an object distinguishable from other
objects and the background. Image enhancement types of operations include
contrast adjustment, noise suppression filtering, application of pseudo color, edge
enhancement, and many others.

1.5 IMAGE RESTORATION

The purpose of image restoration is to "compensate for" or "undo" defects


which degrade an image. Degradation comes in many forms such as motion blur.
noise, and camera miscues. In cases like motion blur, it is possible to come up
with a very good estimate of the actual blurring function and "undo" the blur to
restore the original image. In cases where the image is corrupted by noise, the
best we may hope to do is to compensate for the degradation it caused.
1.6 IMAGE ANALYSIS

Image analysis is the extraction of meaningful information from


images. Image analysis operations produce numerical or graphical information
based on characteristics of the original image. They break into objects and then
classify them. They depend on the image statistics. Common operations are
extraction and description of scene and image features, automated measurements,
and object classification. Image analyze are mainly used in machine vision
applications.

1.7 FEATURE EXTRACTION

Feature extraction involves simplifying the amount of resources


required to describe a large set of data accurately. When performing analysis of
complex data one of the major problems stems from the number of variables
involved. Analysis with a large number of variables generally requires a large
amount of memory and computation power. Feature extraction is a general term
for methods of constructing combinations of the variables to get around these
problems while still describing the data with sufficient accuracy.

1.8 DEEP LEARNING

In deep learning, a convolutional neural network (CNN, or ConvNet) is a


class of deep neural networks, most commonly applied to analyzing visual
imagery. They are also known as shift invariant or space invariant artificial neural
networks (SIANN), based on the shared-weight architecture of the convolution
kernels that shift over input features and provide translation equivariant
responses. Counter-intuitively, most convolutional neural networks are only
equivariant, as opposed to invariant, to translation. They have applications in
image and video recognition, recommender systems, image classification, Image
segmentation, medical image analysis, natural language processing, brain-
computer interfaces, and financial time series.

1.9 DEEP LEARNING METHODS

There are five types of deep learning methods are,

• ANN
• CNN
• RNN
• Deep Q-networks
• Deep belief network

1.10 CONVOLUTIONAL NEURAL NETWORK

CNNs are regularized versions of multilayer perceptron's. Multilayer


perceptron's usually mean fully connected networks, that is, each neuron in one
layer is connected to all neurons in the next layer. The "full connectivity" of these
networks make them prone to overfitting data.

Typical ways of regularization, or preventing overfitting, include:


penalizing parameters during training (such as weight decay) or trimming
connectivity (skipped connections, dropout, etc.) CNNs take a different approach
towards regularization: they take advantage of the hierarchical pattern in data and
assemble patterns of increasing complexity using smaller and simpler patterns
embossed in their filters. Therefore, on a scale of connectivity and complexity,
CNNS are on the lower were inspired by biological processes in extreme. that
Convolutional the networks connectivity pattern between neurons resembles the
organization of the animal visual cortex. Individual cortical neurons respond to
stimuli only in a restricted region of the visual field known as the receptive field.
The receptive fields of different neurons partially overlap such that they cover the
entire visual field.
Figure 1 Biological Neuraon & Artificial neuron
CNNs use relatively little pre-processing compared to other image
classification algorithms. This means that the network learns to optimize the
filters (or kernels) through automated learning, whereas in traditional algorithms
these filters are hand-engineered. This independence from prior knowledge and
human intervention in feature extraction is a major advantage.

1.11 ARCHITECTURE

A Convolutional neural network consists of an input layer, hidden layers


and an output layer. In any feed-forward neural network, any middle layers are
called hidden because their inputs and outputs are masked by the activation
function and final convolution. In a convolutional neural network, the hidden
layers
include layers that perform convolutions. Typically this includes a layer that does
multiplication or other dot product, and its activation function is commonly
ReLU. This is followed by other layers such as pooling layers, fully connected
layers, and normalization layers.

1.11.1 CONVOLUTIONAL LAYERS

In a CNN, the input is a tensor with a shape: (number of inputs) x


(input height) x (input width) x (input channels). After passing through a
convolutional layer, the image becomes abstracted to a feature map, also called
an activation map, with shape: (number of inputs) x (feature map height) x
(feature map width) x (feature map channels). A convolutional layer within a
CNN generally has the following attributes:

• Convolutional filters/kernels defined by a width and height (hyper-


parameters).
• The number of input channels and output channels (hyper-parameters).
One layer's input channels must equal the number of output channels (also
called depth) of its input.
• Additional hyperparameters of the convolution operation, such as:
padding, stride, and dilation.

Convolutional layers convolve the input and pass its result to the next
layer. This is similar to the response of a neuron in the visual cortex to a specific
stimulus. Each convolutional neuron processes data only for its receptive field.
Although fully connected feedforward neural networks can be used to learn
features and classify data, this architecture is generally impractical for larger
inputs such as high resolution images. It would require a very high number of
neurons, even in a shallow architecture, due to the large input size of images,
where each pixel is a relevant input feature. For instance, a fully connected layer
for a (small) image of size 100 x 100 has 10,000 weights for each neuron in the
second layer. Instead, convolution reduces the number of free parameters allows
the network to be deeper. For example, regardless of image size, using a 5 x 5
tiling region, each with the same shared weights, requires only 25 learnable
parameters. Using regularized weights over fewer parameters avoids the
vanishing gradients and exploding gradients problems seen during
backpropagation in traditional neural networks. Furthermore, convolutional
neural networks are ideal for data with a grid-like topology (such as images) as
spatial relations between separate features are taken into account during
convolution and/or pooling.

1.11.2 POOLING LAYERS

Convolutional networks may include local and/or global pooling


layers along with traditional convolutional layers. Pooling layers reduce the
dimensions of data by combining the outputs of neuron clusters at one layer into
a single neuron in the next layer. Local pooling combines small clusters, tiling
sizes such as 2 x 2 are commonly used. Global pooling acts on all the neurons of
the feature map. There are two common types of pooling in popular use: max and
average. Max pooling uses the maximum value of each local cluster of neurons
in the feature map, while average pooling takes the average value.

1.11.3 FULLY CONNECTED LAYERS

Fully connected layers connect every neuron in one layer to every


neuron in another layer. It is the same as a traditional multi-layer perceptron
neural network (MLP). The flattened matrix goes through a fully connected layer
to classify the image.

1.11.4 RECEPTIVE FIELD

In neural networks, each neuron receives input from some number of


locations in the previous layer. In a convolutional layer, each neuron receives
input from only a restricted area of the previous layer called the neuron's receptive
field. Typically the area is a square. Whereas, in a fully connected layer, the field
is the entire previous layer. Thus, in each Convolutional layer, each neuron takes
input from a larger area in the input than previous layers. This is due to applying
the convolution over and over, which takes into account the value of a pixel, as
well as its surrounding pixels. When using dilated layers, the number of pixels in
receptive field remains constant, dimensions combining effect of several layers.

1.11.5 WEIGHTS
Each neuron in a neural network computes an output value by applying
a specific function to the input values received from the receptive field in the
previous layer. The function that is applied to the input values is determined by a
vector of weights and a bias (typically real numbers). Learning consists of
iteratively adjusting these biases and weights.

The vector of weights and the bias are called filters and represent
particular features of the input (e.g., a particular shape). A distinguishing feature
of CNNs is that many neurons can share the same filter. This reduces the memory
footprint because a single bias and a single vector of weights are used across all
receptive fields that share that filter, as opposed to each receptive field having its
own bias and vector weighting.
1.12 DISTINGUISHING FEATURE

In the past, traditional multilayer perceptron (MLP) models were used


for image recognition. However, the full connectivity between nodes caused the
curse of dimensionality, and was computationally intractable with higher
resolution images. A 1000x1000-pixel image with RGB color channels has 3
million weights, which is too high to feasibly process efficiently at scale with full
connectivity.

Figure 2 CNN layers arranged in 3 dimensions


For example, in CIFAR-10, images are only of size 32x32x3, so a single fully
connected neuron in the first hidden layer of a regular neural network would have
32*32*3=3,072 weights. A 200×200 image, however, would lead to neurons that
have 200*200*3=120,000 weights.Also, such network architecture does not take
into account the spatial structure of data, treating input pixels which are far apart
in the same way as pixels that are close together. This ignores locality of reference
in data with a grid-topology, both computationally and semantically. Thus, full
connectivity of neurons is wasteful for purposes such as image recognition that
are dominated by spatially local input patterns.
1.13 LITERATURE SURVEY

Here we have presented the review of our working related area of


flower classification and also present the methods used for to classify the flower
images.

1.Fadzilah Siraj, Muhammad Ashraq Salahuddin and Shahrul Azmi Mohd Yusof
proposed the system for classification of Malaysian blooming flower[4]. In this
paper they presents the application of NN and on image processing particularly
for understanding flower image features. For predictive analysis, they have used
two techniques namely, Neural Network (NN) and Logistic regression. The study
shows that NN obtains the higher percentage of accuracy among two techniques.
The Otsus method was applied in order to compute a global threshold.The image
is then converted to RGB color space again. In color extraction, the images were
transformed from RGB color space to HSV color space the image texture is
calculated based on gray-level co-occurrence matrix (GLCM) to obtain the
contrast, correlation, energy and homogeneity of the image.The prediction
accuracy of logistic regression is 26.8%. Therefore based on 1800 samples of
Malaysian flower images, NN has shown a higher average prediction results vs.
logistic regression.

However this paper cannot present recognition of flower type, its only
recognize flower features so in future studies can be focused on developed flower
model system which can recognize Malaysian blooming flower or extending the
dataset built and Verities sample of images can be captured for different flowers
and recognize their types.

2.Pavan Kumar Mishral, Sanjay Kumar Maurya, Ravindra Kumar Singh and
Arun Kumar Misral present a semi automatic plant identification based on digital
leaf and flower images[5]. They proposed an algorithm for identification using
multiclass classification based on color, shape volume and cell feature. Each stage
further also divided into three steps. First stage comparison based on extracted
features from RGB component. Second stage based on shape feature Area
Convexity, Perimeter Convexity, sphericity and Circulatory. And last stage based
on cell and volume fraction feature. Experiment is performed on a sample of
diverse collection of 1000 leaf and flower and recognition rate is up to 85% on
an average.

In proposed system entire feature cannot be taken at a time because it will


take lot of time for computation and space. So multi stage comparisons are used
for identification of image.Its multi stage comparison so required more tables to
stored results and its long process. They used Unsupervised learning algorithm
which has less accuracy as compared to supervised classification algorithm.

3.Tanakorn Tiay, Pipimphorn Benyaphaichit, and Panomkhawn Riyamongkol


proposed flower Recognition System Based on Image Processing[6].This system
uses edge and color characteristics of flower images to classify flowers. Hus
seven moment algorithm is applied to acquire edge characteristics. Red, green,
blue, hue, and saturation characteristics are derived from histograms. K- nearest
neighbor is used to classify flowers.The system returns the top three most similar
flower images.The Canny edge detection algorithm is applied to the cropped
image to receive edge data. The edge data will be the input into Hus seven-
moment algorithm. Classification: All characteristic values will be classified by
the K-nearest neighbor algorithm. The three most nearest flower characteristics
are selected; the most nearest flower information is displayed.

This system is based on color model so the accuracy is high if their color
are distinct. But if colors are same then it may mislead to classify the image. So
this system can be further improved to yield more accuracy by combining other
features, such as numbers of petals and flower texture. The accuracy of this
system is more than 80%.
4.Prof.Suvarna Nandyal, Miss.Supriya Bagewadi proposed Automated
Identification of Plant Species from Images of Leaves and Flowers used in the
Diagnosis of Arthritis[7].The present work deals with identification and
classification of medicinal plants that are used in treatment of rheumatoid.In the
present work, plant parts mainly leaves and flower are taken as an object for
identification, since these are available for all the time and have some 2D in
nature size and shape.The proposed work deals with image processing techniques
such as feature extraction and classification. The features namely height, width,
margin and texture featuresare used for extracting leaf shape features. Similarly
for flowers, the petal count and colors are extracted in RGB and Ycbcr color
space. The obtained features are trained by neural network classifier. The
classification results have shown an accuracy of 85% for leaf and 85% for flower.

The present work deals with development of a system where a user in the
field can take a picture of unknown plants, leaf and flower and the system to
classify the species. In the proposed work, shape and texture features of sample
plant images of five classes are used in the rheumatoid are extracted. Further the
accuracy can be increased by taking an efficient shape features in frequency
domain. The work can be extended by taking more features and other classifier.

5.Yuita Arum Sari and Nanik Suciati proposed Flower Classification using
Combined a* b* Color and Fractal- based Texture Feature[8].This research
proposes a new method of flower classification system using combination of
color and texture features.The first phase is getting the crown of the flower, which
is localized from a flower image by using pillbox filtering and OTSUs
thresholding.The color features are extracted by removing L channel in L*a*b*
color space, and taking only a* and b* channel, because of ignoring different
lighting condition in flower image. The texture features are extracted by
Segmentation-based Fractal Texture Analysis (SFTA). Classification is done
using kNN classifier.KNN classifier is used to assess similarity among image
flowers. Cosine measure outperforms to all distance measures under k = 9.The
combined a*b* features and texture gives the better performance when using
cosine measure, than using L* color channel when combined with texture feature.
The flower classification achieves the best result with accuracy 73.63%.

6. M. Z. Rashad1, B.S.el-Desouky2 , and Manal S.Khawasik proposed Plants


Images Classification Based on Textural Features using Combined
Classifier[9].This paper introduces an approach of plant classification which is
based on the characterization of texture properties. They used the combined
classifier learning vector quantization. All plant images they use in their system
are in 128 × 128 resolution. A learning rate is user-designated in order to
determine how much the link weights and node biases can be modified based on
the change direction and change rate. The higher the learning rate (max. of 1.0)
the faster the network is trained. If no. of epochs increases the accuracy increases.
If learning rate increase the more accurate but the more time. It shows that
accuracy is 98.7% compared to other systems.

The system has an advantage of its ability of classifying and recognizing the
plant from a small part of the leaf without depending neither on the shape of the
leaf or on its color features, since the system essentially depends on the textural
features. Hence, the system is useful for the botany researchers when he wants to
recognize a damaged plant, since this can be carried out depending only on a
small part of the damaged plant.

7.Dr.S.M.Mukane, Ms.J.A. Kendule proposed Flower Classification Using


Neural Network Based Image Processing[11].In this paper, it is proposed to have
a method for classification of flowers using Artificial Neural Network (ANN)
classifier. The proposed method is based on textural features such as Gray level
co-occurrence matrix (GLCM) and discrete wavelet transform (DWT).The ANN
has been trained by 50 samples to classify 5 classes of flowers and achieved
classification accuracy more than 85% using GLCM features only. In this
experiment pyramid structured type of DWT is used with dB8 as a wavelet filter.
Feature database is created using wavelet decomposed sub bands up to forth level
of decomposition. Experimentation has been conducted on databases of 50
images and 5 classes. The classification accuracy under ANN classifier has been
investigated. As compared with all classes GLCM features shows highest result
while combination of DWT and GLCM shows less success rate. Hence it is found
that flower images can be classified easily with the GLCM features only.

Only gray level features have been used. The neural network is trained
using the backpropagation algorithm. Own database of flowers of 5 classes, each
containing 10 flower images has been created. It has been found that MLP offers
accuracy 87% with GLCM features.

8. C. H. Arun, W. R. Sam Emmanuel and D. Christopher Durairaj propose


Texture Feature Extraction for Identification of Medicinal Plants and Comparison
of Different Classifiers[12].Texture analyses of the leaf images have been done
in this work using the feature computation. The features include grey textures,
grey tone spatial dependency matrices(GTSDM) and Local Binary Pattern(LBP)
operators. For each leaf image, a feature vector is generated from the statistical
values. 70% of the images in the dataset are the training dataset and the rest are
included in the test set. Six different classifiers are used to classify the plant leaves
based on feature values. It is observed that without preprocessing(NP) the best
performance obtained is 88.0% with kNN for categories C1 and C2, 94.7% with
DT for C3, 94.7% with kNN for C4, 94.7% with SGD for category C5. In this
case, the best performance of 94.7% is achieved using the categories C3, C4 and
C5. The best classification gives very small error rate for the medicinal plant leaf
identification. It is necessary to reduce the error rate for better result. The
reduction of error rate may depend on the selected features and the dataset.
The method of classifying without preprocessing performed better. The
classification performance of 94.7% is obtained using Stochastic Gradient
Descent, Decision Tree and kNN classifiers. Therefore it is concluded that the
preprocessing approach is not suitable for the medicinal leaf identification.
Instead of using preprocessing, the direct application of feature extraction with
different categories produced better performance.

1.14 EXISTING METHOD

Figure 3 Existing Method


1.14.1 CONVOLUTIONAL NEURAL NETWORKS

Convolutional neural network (CNN) is a class of deep, feed-forward


artificial neural network that has been utilized to produce an accurate
performance in computer vision tasks, such as image classification and detection.
CNNs are like traditional neural network, but with deeper layers. It has weights,
biases and outputs through a nonlinear activation. The neurons of the CNN are
arranged in a volumetric fashion such as, height, width and depth.

1.14.2 ARCHITECTURE
A convolutional neural network consists of an input layer, hidden layers
and an output layer. In any feed-forward neural network, any middle layers are
called hidden because their inputs and outputs are masked by the activation
function and final convolution. In a convolutional neural network, the hidden
layers include layers that perform convolutions. Typically this includes a layer
that does multiplication or other dot product, and its activation function is
commonly ReLU. This is followed by other layers such as pooling layers, fully
connected layers, and normalization layers.

1.14.3 PYCHARM

PyCharm is an integrated development environment (IDE) used in


computer programming, specifically for the Python programming language. It is
developed by the Czech company JetBrains (formerly known as IntelliJ). It
provides code analysis, a graphical debugger, an integrated unit tester, integration
with version control systems (VCSes), and supports web development with
Django as well as data science with Anaconda

PyCharm is cross-platform, with Windows, macOS and Linux versions.


The Community Edition is released under the Apache License and there is also
an educational version, as well as a Professional Edition with extra features
(released under a subscription-funded proprietary license).

1.14.4 MACHINE LEARNING ALGORITHM

Supervised learning , Unsupervised learning and Reinforcement learning


can be categorized as the three different classes of machine learning algorithms.
Our model implements supervised learning. In supervised learning, the dependent
(target) variable is to be predicted using independent (predictor) variables with
the help of mapping functions which map inputs to the desired outputs. The
algorithm forges predictions based on the identified patterns and observations
over the cycle of training which is continued until the desired accuracy is reached.
In simple words, this category of machine learning algorithms trains the machine
with the help of examples and the model is based on both input and output data,
as presented in figure. Classification and Regression are the two implementations
of supervised learning.
CHAPTER 2
PROPOSED METHOD
2.1 BLOCK DIAGRAM

Figure 4 Proposed Method

2.2 FUNCTIONAL BLOCKS

• Convolutional layer
• Global pooling layer
• Flatten layer
• Fully connected layer
• Softmax layer

2.3 SOFTWARE REQUIREMENTS

Coding language:Python Tkinter Package


Coding IDE: Pycharm
Datasets: Kaggle dataset
Machine learning libraries: Numpy, Pytorch.

2.4 ARCHITECTURE

The CNN architecture, it is composed of convolutional layer, pooling


layer and fully connected layer. Convolutional layer and pooling layer are
typically alternated and the depth of each filter increases from left to right while
the output size (height and width) are decreasing. The fully connected layer is the
last stage which is similar to the last layer of the conventional neural networks.

2.4.1 CONVOLUTIONAL LAYER


Convolutional layers convolve the input and pass its result to the next
layer. This is similar to the response of a neuron in the visual cortex to a specific
stimulus. Each convolutional neuron processes data only for its receptive field.
Although fully connected feedforward neural networks can be used to learn
features and classify data, this architecture is generally impractical for larger
inputs such as high resolution images. It would require a very high number of
neurons, even in a shallow architecture, due to the large input size of images,
where each pixel is a relevant input feature. For instance, a fully connected layer
for a (small) image of size 100 x 100 has 10,000 weights for each neuron in the
second layer. This convolution reduces the number of free parameters, allowing
the network to be deeper. For example, regardless of image size, using a 5 x 5
tiling region, each with the same shared weights, requires only 25 learnable
parameters. Using regularized weights over fewer parameters avoids the
vanishing gradients and exploding gradients problems seen during
backpropagation in traditional neural networks. Furthermore, convolutional
neural networks are ideal for data with a grid-like topology (such as images) as
spatial relations between separate features are taken into account during
convolution and/or pooling.

2.4.2 GLOBAL POOLING LAYER


Global Average Pooling is a pooling operation designed to replace fully
connected layers in classical CNNs. The idea is to generate one feature map for
each corresponding category of the classification task in the last mlpconv layer.
Instead of adding fully connected layers on top of the feature maps, we take the
average of each feature map, and the resulting vector is fed directly into the
softmax layer.
One advantage of global average pooling over the fully connected layers is that it
is more native to the convolution structure by enforcing correspondences between
feature maps and categories. Thus the feature maps can be easily interpreted as
categories confidence maps. Another advantage is that there is no parameter to
optimize in the global average pooling thus overfitting is avoided at this layer.
Furthermore, global average pooling sums out the spatial information, thus it is
more robust to spatial translations of the input.

2.4.3 FLATTENING LAYER

This layer transfigures the multi-dimensional tensor output from the


dropout layer to a one-dimensional tensor. This layer is helpful to sort out the
output the module and predict the what the output is generated by the module. It
is the in form of one-dimensional way it is helpful to sort and drop the classes
which are not suitable or similar to the given image.

2.4.4 FULLY CONNECTED LAYER

Fully connected layers connect every neuron in one layer to every neuron
in another layer. It is the same as a traditional multi-layer perceptron neural
network (MLP). The flattened matrix goes through a fully connected layer to
classify the images.

2.4.5 SOFTMAX LAYER

This layer is in the work of changing the output of the model in the form of
a probability sequence and generate a value based on each classes given to the
model. It converts the score of each class into Probability Distribution. The
Probability Distribution values are the one to deceide the final output of the
model.
2.5 PRE-PROCESSING

In imaging science, image processing is processing of images utilizing


mathematical operations by utilizing any form of signal processing for which the
input is an image, a series of images, or a video, such as a photograph or video
frame; the output of image processing may be either an image or a set of
characteristics or parameters cognate to the image. Most image-processing
techniques involve treating the image as a two-dimensional signal and applying
standard signal-processing techniques to it. This is the step taken before the major
image processing task. The problem here is to perform some basic tasks in order
to render the resulting image more suitable for the job to follow. In this case it
may involve enhancing the contrast, removing noise, or identifying regions likely
to contain the postcode.

2.6 TRANSFER LEARNING

Transfer learning is a powerful deep learning technique in which


pre-trained models can be used for feature extraction and fine tuning. This
technique can be used in image classification like vehicle classification, object
detection and segmentation. The advantage of using this technique is it saves time
to train the network from the start and less data is needed to get good results. The
training can also be done using a central processing unit (CPU) even without the
computational power of graphics processing unit (GPU). Instead of creating new
model from scratch, pre-trained models can be used. These models are trained
from the large image database like ImageNet and COCO dataset. Some of these
models are AlexNet, VGG16, VGG19, ResNet50, Inception V2, InceptionV3,
Xception, DenseNet and MobileNet. This paper focuses on the two models only.
Inception V2 and MobileNet.
2.7 IMPLEMENTATION

2.7.1 PYTHON TKINTER PACKAGE

Tkinter is the standard GUI library for Python. Python when combined
with Tkinter provides a fast and easy way to create GUI applications. Tkinter
provides a powerful object-oriented interface to the Tk GUI toolkit. Import the
Tkinter module.

2.7.3 PYCHARM

PyCharm is cross-platform, with Windows, macOS and Linux versions.


The Community Edition is released under the Apache License,[7] and there is
also an educational version, as well as a Professional Edition with extra features
(released under a subscription-funded proprietary license)

2.7.4 DATASETS

We are used Kaggle datasets. This dataset contains 4242 images of


flowers.The data collection is based on the data flicr, google images, yandex
images.You can use this datastet to recognize plants from the photo.The pictures
are divided into five classes: chamomile, tulip, rose, sunflower, dandelion.For
each class there are about 800 photos. Photos are not high resolution, about
320x240 pixels. Photos are not reduced to a single size, they have different
proportions.The data collection is based on scraped data from flickr, google
images, and yandex images.

2.7.5 PYTHON

Python is an easy to learn, powerful programming language. It has efficient


high 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 mini areas on most platforms. The Python interpreter and the
extensive standard library are freely available in source or binary form for all
major platforms from the Python Web site and may be freely distributed. The
same side also contains distribution and pointers to many free third party Python
modules, programs, tools, and additional documentation.

The Python interpreter is easily extended with new function and data
types implemented in C or C++ or other languages scalable from C. Python is
also suitable as an extension language for customizable applications. If you do
much work on computers, eventually you find that there's some task you'd like to
automate. For example, you may wish to perform a search-and-replace over a
large number of text files, or rename and rearrange a bunch of photo files in a
complicated way. Perhaps you'd like to write a small custom data base, or a
specialized GUI application, or a simple game. If you're a professional software
developer, you may have to work with a several C/C++/Java libraries but find the
usual write/compiler/test/re-compile/cycle is too slow.Perhaps you're writing a
test suite for such a library and find writing the testing code a tedious task. Or
maybe you're written a programme that could use a extension language, and you
don't want to design and implement a whole new language for your application.
Python is just the language for you. You could write UNIX shell script or
windows batch files for some of the tasks, but shell scripts are best at moving
around files and changing text data, not well-suited for GUI application or games.

You could write a C/C++/Java program, but it can take a lot of


development time to get even a first draft program. Python is similar to use,
available on windows, MacOS x, and UNIX operating systems and will help to
get the job done more quickly.
2.8 MACHINE LEARINING LIBRARIES

2.8.1 NUMBY

NumPy offers comprehensive mathematical functions, random number


generators, linear algebra routines, Fourier transforms, and more. Interoperable.
NumPy supports a wide range of hardware and computing platforms, and plays
well with distributed, GPU, and sparse array libraries

2.8.2 PYTORCH

PyTorch is an open source machine learning framework based on the


Torch library,used for applications such as computer vision and natural language
processing, primarily developed by Meta AI.It is free and open-source software
released under the Modified BSD license. Although the Python interface is more
polished and the primary focus of development, PyTorch also has a C++
interface.

2.9 MODULES
The programming modules of the automated Flower Recognition was
divided into three streams;

Required_declaration, Global_test and Train_test modules

1.Required_declaration Module

This module consists of all the global variables, constants and required Library
used to during the program. The constants like Image size, text size, bins for
histogram. Besides that, the training path and small functions are defined in this
module. The function defined are:
A.Fd_histogram: To extract Color Histogram features from the image, we use
cv2.calcHist() function provided by OpenCV. The arguments it expects are the
image, channels, mask, histSize (bins) and ranges for each channel [typically 0-
256). We then normalize the histogram using normalize() function of OpenCV
and return a flattened version of this normalized matrix using flatten().

B.Fd_haralick: To extract Haralick Texture features from the image, we make


use of mahotas library. The function we will be using is
mahotas.features.haralick(). Before doing that, we convert our color image into a
grayscale image as haralick feature descriptor expect images to be grayscale.

C.Fd_hu_moment: To extract Hu Moments features from the image, we use


cv2.HuMoments() function provided by OpenCV. The argument to this function
is the moments of the image cv2.moments() flatenned. It means we compute the
moments of the image and convert it to a vector using flatten (). Before doing
that, we convert our color image into a grayscale image as moments expect
images to be grayscale.

2.Global_test Module

This module is the extension of the Required_declaration module. Usinf


the training path from previous module, for each of the training label name, we
iterate through the corresponding folder to get all the images inside it. For each
image that we iterate, we first resize the image into a fixed size. Then, we extract
the three global features and concatenate these three features using NumPy’s
np.hstack() function. We keep track of the feature with its label using those two
lists we created above - labels and global_features.After extracting features and
concatenating it, we need to save this data locally. Before saving this data, we use
something called LabelEncoder() to encode our labels in a proper format. We
normalize the features using scikit-learn’s MinMaxScaler() function so that, one
feature might not dominate the other with respect to its value . After doing these
two steps, we use h5py to save our features and labels locally in .h5 file format.
3.Train_test module

This module is run after the Global_test module is executed. After


extracting, concatenating and saving global features and labels from our training
dataset, it’s time to train our system. We have created our Machine Learning
models using the help of scikit-learn.We have used Logistic Regression, Linear
Discriminant Analysis, K-Nearest Neighbors, Decision Trees, Random Forests,
Gaussian Naive Bayes and Support Vector Machine as our machine learning
models. Furthermore, we have used train_test_split function provided by scikit-
learn to split our training dataset into train_data and test_data. By this way, we
have trained the models with the train_data and test the trained model with the
unseen test_data. The split size is decided by the test_size parameter.For checking
the accuracy of the model, We have used a technique called K-Fold Cross
Validation, a model-validation technique which is the best way to predict ML
model’s accuracy. In short, if we have chosen K = 10, then we have split the entire
data into 9 parts for training and 1 part for testing uniquely over each round up to
10 times. The accuracy of the model may vary as number of images per class is
changed. For more accurate result we would have to increase the dataset around
500-1000 images per class, which is a time consuming task.We have imported all
the necessary libraries to work with and create a models list. This list will have
all our machine learning models that will get trained with our locally stored
features. During import of our features from the locally saved “.h5” file-format.
2.10 OUTPUT

Figure 5 Training accuracy & Validation accuracy

Figure 6 Recognize the flower name


Figure 7 Recognize the flower name & save it new folder
CHAPTER 3

CONCLUSION
CONCLUSION

Flower recognition is useful to identify the flower signature. The


methods are used to extract flower features are based on color, shape, petal count
and texture etc. In colour based model accuracy is high only if the flower colours
are distinct. In shape based model there is problem if the view point of the image
is different. Same as in petal count if the some of petals are missing then it may
mislead to classify the image. Classifiers plays important role to test the data and
check the accuracy of classification algorithm. Supervised classification gives
higher accuracy as compared to unsupervised classification algorithms. MLP
gives better result as compare to logistic regression, kNN, pNN and SVM.

To identify different flower images based on its surface parameter is


challenging and most expensive task. Flower image surface parameters are
grain, color and texture. The combined feature extracted from each of its
parameter is used to identify flower type and gives better result as compare to
using single parameter. Since flower grain analysis plays an important role in
flower recognition it is used to identify the flower type. Whereas MLP feed
forward method using back propagation algorithm gives higher accuracy to
classify the flower images.
FUTUURE SCOPE

Some of the future scopes that can be done to this system are:

1. To provide more information of flower and their family, that might help Botany
student for study and research purpose.

2. This helps in predicting the flower present in data set.

3.Validate if the upload image is flower or not.

4.Increase the species of flower that can be identified.

5.Convert the program into android compatible.


REFERENCES

1. http://en.wikipedia.org/wiki/Digtal_image_processing
2. http://en.wikipedia.org/wiki/Machine_learning
3. http://en.wikipedia.org/wiki/List_of_machine_learning_concepts
4. Fadzilah Siraj, Muhammad Ashraq Salahuddin and Shahrul Azmi Mohd
Yusof ,Digital Image Classification for Malaysan Blooming Flower IEEE-
2010.
5. Pavan Kumar Mishral, Sanjay Kumar Maurya2, Ravindra Kumar Singp,
Arun Kumar Misral A semi automatic plant identification based on digital
leaf and flower Images IEEE-2012.
6. Tanakorn Tiay, Pipimphorn Benyaphaichit, and Panomkhawn
Riyamongkol Flower Recognition System Based on Image Processing
ICT-ISPC-2014.
7. Prof.Suvarna Nandyal, Miss.Supriya Bagewadi, Automated Identification
of Plant Species from Images of Leaves and Flowers used in the Diagnosis
of Arthritis IJREAT-Volume 1, Issue 5, Oct- Nov, 2013.
8. Yuita Arum Sari and Nanik Suciati,Flower classification using combined
a*b*color and Fractal-based Texture feature, International Journal of
Hybrid Information Technology Vol.7, No.2 (2014).
9. M. Z. Rashad1 , B.S.el-Desouky2 , and Manal S .Khawasik, Plants Images
Classification Based on Textural Features using Combined Classifier,
(IJCSIT) Vol 3, No 4, August 2011
10. Mari Partio, Bogdan Cramariuc, Moncef Gabbouj, and Ari Visa,Rock
Texture retrieval using gray level co-occurrence Matrix ,(ITS) Surabaya,
Indonesia.
11. Dr.S.M.Mukane and Ms.J.A.Kendule, Flower Classification Using Neural
Network Based Image Processing IOSR-JECE Volume 7, Issue 3,Sep. –
Oct. 2013.

12. C. H. Arun, W. R. Sam Emmanuel and D. Christopher Durairaj, Texture


Feature Extraction for Identification of Medicinal Plants and Comparison
of Different Classifiers International Journal of Computer Applications
(0975 – 8887) Volume 62 – No. 12, January 2013.

You might also like