Title Lightweight Model Implementation Using Neural Network For Fruit Recognition
Title Lightweight Model Implementation Using Neural Network For Fruit Recognition
FRUIT RECOGNITION
Contents
Abstract............................................................................................................................................2
Chapter 1..........................................................................................................................................4
1.1 Introduction............................................................................................................................4
1.2 Aim........................................................................................................................................6
1.3 Objective of the project.........................................................................................................6
1.4 Research Questions...........................................................................................................6
1.5 Background............................................................................................................................6
1.6 Problem Statement.................................................................................................................7
1.7 Report structure.....................................................................................................................7
Chapter 2..........................................................................................................................................8
2.1 Introduction............................................................................................................................8
2.3 Literature review....................................................................................................................8
3.1 Introduction..............................................................................................................................19
3.2 Requirement gathering.............................................................................................................20
3.2.1 Hardware requirements.....................................................................................................20
3.2.2 Software requirements......................................................................................................20
3.2.2.1 Flask...............................................................................................................................20
3.2.2.2 Python language.............................................................................................................20
3.3 Tools used................................................................................................................................21
3.3.1 Kaggle datasets:................................................................................................................21
3.3.2 Python programming language:........................................................................................21
3.3.3 Tensor flow:......................................................................................................................21
3.3.4 Keras:................................................................................................................................22
3.3.5 Jupyter notebook:..............................................................................................................22
3.4 Techniques...............................................................................................................................23
3.4.1 Deep learning:...................................................................................................................23
3.4.2 Convolutional neural network:.........................................................................................23
3.4.3 Dense layer.......................................................................................................................23
3.4.4 Sequential model..............................................................................................................24
3.5 Research Concept....................................................................................................................24
3.5.1 Collecting or gathering data..............................................................................................24
3.5.2 Code execution.................................................................................................................25
3.5.3 Testing the trained datasets...............................................................................................25
3.5.4 Output display...................................................................................................................25
3.6.Diagram...................................................................................................................................25
3.6.1 Flowchart..........................................................................................................................25
3.6.2 Sequence Diagram............................................................................................................28
3.7 Conclusion...............................................................................................................................29
4.1 Introduction..............................................................................................................................29
4.5 Result and discussion...............................................................................................................40
4.6 Challenges................................................................................................................................44
4.7 Conclusion...............................................................................................................................44
Abstract
In recent years Machine learning and CNN are the thriving technology across the world.
In this proposed project, the objects i.e. fruits represented on the image can be identified by using
the machine learning model with the proper training using plenty of images. When we have a
large number of training images, the deep learning model is used to predict the image accurately
among the other images. The deep learning model and Machine learning algorithms help in fruit
identification and also to predict the fruit name. The image recognition for fruits identification is
slightly complex when the image gets overlapped and also when it gets stacked, that issue is
sorted in this project by using various layers in the CNN and also by using large datasets to get
high accuracy. In this project, Convolution Neural Network (CNN) is used to predict the name of
the fruit given in the image. In this project, the model is well trained where the image of the
fruit is considered as the input of the model while the label of the fruit will be the output of the
model. If the training for the Convolution neural network model is done successfully, the
model/system will able to identify the fruit and predict the name of the image. The already
existing projects have fewer layers in CNN and the fruits used for prediction are also
comparatively less. In this project, many layers are included in the CNN model also the number
of fruits used for the training is also high. The dataset is collected from the popular website
named Kaggle. Python is the scripting language used in this project due to its efficacy. Tensor
flow and Keras are the two platforms that support the Python programming language. This CNN
architecture helps to identify fruits with different structures, colors, and shapes. A high number
of datasets are used for training to get perfect results. The accuracy rate of this project is more
than 95%. The fruits in this project can be recognized using their shape, size of fruits, and also
by different features. This project describes how the CNN and Machine learning algorithm is
used to identify the fruits.
Keywords: Computer vision, machine learning, CNN, Kaggle, network, datasets, Tensorflow
and Keras.
Chapter 1
1.1 Introduction
This project explains fruit recognition with the help of recent technology and also
highlights the benefits and goals of the proposed method using datasets. In agricultural areas like
the food industry, packaging, marketing, etc., The recognition of the fruits plays a major role.
Classification of the fruits and sorting the fruits based on their quantity is time-consuming. In
order to rectify this, the recent technology, a deep neural network is used here to segregate the
fruits. This helps to recognize and predict the fruits based on their shape, size, and other features
with high accuracy. In this project, Convolution Neural Network CNN is used for image
identification. The recognition of fruit helps in many industries like harvesting, sales industries
to segregate the fruits by identifying the fruits. In the harvesting industry it helps to identify the
fruit type without much intervention by humans and it auto segregates the fruit after harvesting
and in the sales industry, it helps to identify the fruit for calculating the price of the fruit even
though many fruits stack together. Previously the image processing method is used to identify
the fruit.
Tensorflow and Keras are used as the supporting language for Python. Each layer of the
CNN is followed by Rectified Linear Unit Layer (RLUL). Kaggle is the open-source website
used to obtain the datasets. In this project, the dataset consists of 15 varieties of fruits along with
4000 images. This will helps to identify the image of the fruits and label the fruits based on their
shape and size using this recent technology. In this method, the networks are trained to identify
the fruits like apples, orange, bananas, etc based on the pixel datasets. However, it is difficult to
identify the images due to overlapping and complexity, the deep learning model is well trained in
order to identify the image and predict their name with high accuracy. The segregation of fruit
and weighing individually is time-consuming and it needs much work. When it gets automated
using the fruit recognition, a lot of time gets saved along with the less human work.
The machine learning algorithm’s subset deep learning is used in this project. The data
which contains high model abstraction can be collected by this Deep learning technique. In this
method, the models can understand the details from the picture/Text and this helps to analyze
better. The deep learning technique brings high accuracy than manual prediction. The advantage
of the convolutional neural network over other networks is that it will notice the structure of the
image while processing of the image is ongoing. . This will helps to identify the image based on
their accuracy and this will show that the image recognition is achieved successfully (Sakib,
2019). The CNN opts in this project since the image structure gets noticed even at the time of
processing the image and also to come out of the errors based on the deep model, the deep belief
algorithm is included. In this method, there are plenty of hidden layers and the values can be
related and improved. This model needs less time for training and the Deep belief model gets
included along with the CNN to get the benefit. The datasets collected from the common source
Kaggle, More than 4000 datasets are used in this project for training and more than 15 variety of
fruits with different structures, shapes, and colors are used. (Harsh, 2020) The color needs to be
the same while the fruit segregation must vary. Tensor flow is used to implement, train and test
the network of the paper. This is the open-source from google for solving various machine
learning computations with graph support. In this paper, the tensor flow serves as a supporting
platform for fruit recognition. Thus fruit recognition with a machine learning algorithm provides
better output with high accuracy. In this project, Convolutional Neural Network helps to identify
the fruits based on their size, shape, and other features. This paper gives a brief introduction, the
aim of the paper, objectives, benefits of fruit recognition using the CNN method and research
questions will be discussed and also the background analysis of this network and the drawbacks
of the existing system and solution to that also discussed below.
1.2 Aim
The aim of the proposed project is to recognize the fruit effectively and identifying its
name by using the convolutional neural network and Deep learning model.
To collect various fruit images for processing the image and classification
To extract features to classify the fruits based on the features and to create the
algorithm to reduce complexity
To perform the CNN based testing, training using a deep learning model and the
accuracy is analyzed.
1.5 Background
The purpose of fruit identification helps in many industries to enhance the business
effectively. The fruits identified can be used for billing effectively by pricing the fruit
automatically, the matured fruit identification can help to harvest effectively, the fruit
segregation can help to classify fruits in the sales industry without human intervention, etc. In
this project, the various researches on fruit recognition using image processing and deep learning
are reviewed. The image processing used for the fruit recognition is done under five major steps:
Collecting the datasets, Pre-processing the images, Categorizes the image, Extraction of the
feature and then the segregation of the fruit. The fruit extraction may get complex in image
processing since some fruits may hold similar features. The number of fruits used in the previous
projects is also less (Horea Muresan, 2018). The convolution neural network also used in many
projects previously but the number of layers in the network is less and this could be the reason
for less accuracy which is less than 87% (S.Arivazhagan, 2010).
Chapter 2
2.1 Introduction
This includes the multiple resources and research related to the fruit recognition
approaches like using color, shape, size, image processing, etc. The latest articles would be
obtained and would be reviewed to understand the currently existing system, the problems,
background, methods used , advantages, restrictions, and the research the work area of the
project.
2.3 Literature review
Recognition of Fruits using Image processing:
The author (Nayak,2019 ) proposes the method based on texture, color, and shape to
recognize the fruit effectively since in the food industry, it is more important to identify the fruit
based on their quality because nowadays persons are more conscious of health. A variety of
fruits are available in the market, but identifying the good fruit is a more risk-able task. In order
to short this, the natural lighting method is used. Particular fruit is recognized by image
segmentation methodology. In this article, a fruit recognition paper is implemented by using the
MATLAB image processing toolbox. This consist of four processes namely pre-processing,
Extraction of feature, Segmentation and Recognition. This paper can be used for both real and
non-real time application. In the case of non-real-time application, pre-processing is used to
browse the image, then from the image, features are extracted by using GLCM (Grey Level Co-
occurrence Matrix), RGB and Color Histogram in the second stage. Then for the further process,
the image from the RGB is converted into a Grayscale image by the system. In the image, the
distribution of colors like red, green, and blue can be represented in terms of the color histogram.
The extracted features are given as input SVM classifiers. Then the output “fruit name” is
displayed.
The researcher ( (Zawbaa, 2014) explains the method that recognizes the fruits by
identifying the fruit types. The work involves image classification and identification of fruit
based on the size, shape, and texture. In this article, pre-processing, classification, and feature
extraction are the three stages involved. In order to reduce the index color, the size of the image
is resized into 90*90 pixels, which takes place in the first stage. Next in the second stage, the
feature extraction, SIFT (Scale Invariant Feature Transform), shape, and color are used to extract
the image of each dataset. Finally, in the Classification phase, the K-NN K-Nearest
Neighbourhood algorithm and SVM Support Vector Machine algorithm is used to identify
different types of fruits. This process carries the above model and demonstrated on the dataset
containing 178 images of fruit. Thus this will provide fruit name with a high rate of accuracy.
This will helps the people to identify the fruits in an easy manner
The study explores that Computer vision and machine learning are playing a vital role in
food industries nowadays. This article will helps to monitor, sort, and pick the fruits that will
ensure production in a faster manner. The main aim of this paper is to investigate the methods
like auto-harvesting and categorize the fruits based on their color and texture. (Jana, 2017). This
article will propose a new approach that will overcome the issues in the previous method. The
proposed method will account for different fruits according to their types. The main motivation
of this paper is to provide the result with high accuracy and efficiency. In every paper, the first
stage of classification of fruits is pre-processing which is done in order to make a separation of
the fruit from foreground to background. From the segmented image, the feature of texture from
the Grey Level Co-occurrence Matrix and the color feature from the statistical layer are
extracted. These two combine in a single feature. A support Vector Machine is trained by a
feature combination of GLCM and statistical descriptor. Once the training is completed, the
model is ready to find the unlabelled image of the fruit. This method is also suitable for
embedded-based paper and single-board computers.
The research explains that the fruit is recognized using Convolutional Neural Network
CNN model. (Hou, 2016). For every process, the image should be extracted, in this paper, the
image is extracted from the selective algorithm, and the region of the image is obtained from the
fruit image entropy. This is considered as the input of the Convolutional Neural Network. The
process will be started after proper training of the network. The final decision is made only after
the fusion of the region by using a voting mechanism. The achievement is done after doing the
work in a better manner. The application of this method in the supermarket helps to find a variety
of fruits, fruit stacks, etc, and also made multiple training to identify the fruit types. After
successful training, this network will be remarkable over the fruit recognition stacked based on
weighing scale
The paper explains that the Hardcoded feature Extraction algorithm is used to detect the
fruit within the tree by video or image processing. This algorithm has shown high accuracy.
Even though it shows high accuracy, the hardware is still intensive and not applicable for real-
time applications. This article gives an explanation of a deep convolutional neural network that is
based on a detector of a single stage. This technique will eliminate the hard feature based on
shape, size, and texture. (Bresilla, 2019). Then this architecture takes the image as input and
then divides it into the grid, represented as AXA where A is used to define the fineness of the
grid. The image recognition and localization algorithm are fixed on each cell of the grid. This
will helps to identify the image based on their feature. This architecture gives 90% accuracy.
This model is also designed with a feature to accommodate the error rate. The speed taken for the
processing is also high that will be apt for real-time application. In this paper, we have discussed
fruit recognition using deep neural network technique by using a single-shot detector YOLO.
This paper gives a brief explanation of identifying the fruits and also vegetables in the
retail shop with the help of the image attached with the system. The system attached with the
image will help the customer to label or identify the fruits and vegetables along with the price
rate according to the weight of the fruits and vegetables. (Femling, 2018). This new approach is
proposed in order to reduce the interaction between the system and the human, to speed up the
time for identification, and to improve the usability of the graphical interface comparing with the
manual features. The hardware designed for this paper is Raspberry pi, a camera to capture the
image, display to view the result. In order to classify the object, various convolutional Neural
Network has been trained and tested to provide high accuracy. Heuristic evaluation is used to test
the usability of this network and this shows accuracy and user friendly compared with other
technology. This system evaluated two CNN architectures namely Inception and MobileNet.
This classifies 15 types of fruits and vegetables
The scholar explains that the fruit product challenge includes the approach for the
classification and grading of fruits. Among these, identifying a fruit based on quality is one of
the major challenges. This article represents the system to analyze four varieties of fruits and also
ranks the fruit based on their quality. The first algorithm shows the color of the image like red,
blue, and green. The second algorithm (Bhargava, 2019) shows the background of the image
which is detached by the split and merge algorithm. After this, color, gesture, geometrical
features are extracted. In order to evaluate the fruit type and quality, geometrical features are
most widely used. Then in order to evaluate the quality algorithms like K- Nearest neighbor K-
NN, SVM Support Vector Machine, SRC Sparse Representative classifier algorithm, and
Artificial Neural Network ANN algorithm is used. The accuracy of the quality evaluation is
detected for four algorithms. Finally, SVM is considered more effective and the output is
considered as more comparable with other techniques.
This article presents the detection of fruit using a deep convolutional neural network. The
main aim of the paper is to provide high, accurate, fast, and reliable output in the detection of
fruits, because fruit detection acts as a vital element in the platform of agricultural robotics, in
the estimation of fruit yield, and also in harvesting. Recent research (Sa, 2016) over the deep
neural network states that it led to the development of a new approach called Faster Region-
based CNN (Faster R CNN). Most of them adopted this model because the task can be
performed with the images obtained from the Color that is RCB and Near-Infrared (NIR). In
previous research, RCB and NIR are the fusion methods used to detect. This leads to proposing a
Faster CNN model which is more effective than prior work and scores F1 Grade. Bounded Box
annexation is used for additional accuracy. This model concludes by showing the result of
detecting seven fruits which takes four hours for both annoying and training. Thus future results
show the annotation of fruits can be done by utilizing Amazon mechanical Truck which is an
algorithm and other outsources to achieve high accuracy.
Recent research of this paper explains that humans are so busy with their personal works,
all want to do work with accuracy, less time along low cost. This method is proposed to satisfy
their needs. Related to this, counting the fruits takes more time and requires manpower. In order
to reduce the effort of the user, the algorithm is developed in computer vision to reduce the
manpower. In order to avoid this problem, the algorithm like automatic fruit detection and
counting of fruit is essential. (A, 2019). This provides high accuracy. In order to achieve good
object detection, counting of fruits, classification of fruits various algorithms and extraction
features are introduced. Proper training should be given for the algorithm to provide accurate
output. In this paper, Raspberry pi is the hardware used for fruit detection along with the camera.
This paper provides a deep explanation for the detection of fruits in trees, sorting of images is
based on the color and shape of the fruit. Image taken from the online or videos can be
considered as input, pre-processing of the image is done with the help of computer vision
designed with python. The result not only helps for sorting, identifying, and classification of
fruits it also helps in fruits overlapping and recognition of fruits. There are many areas available
for the researchers to explore new innovation in terms of fruit detection
The paper says that the computer vision, detection of fruit using Deep Convolutional
neural network CNN is the most promising feature. By using recent technology, the
identification of fruits is done through images. Due to complexity and standard similarity, fruit
identification and classification is more difficult. In this article, the fruit detection using the CNN
model is discussed. This proposed technique uses deep learning for identification. In this method,
four layers are used for observation. The network is well trained and tested. Fruit recognition
faces various challenges based on the size, shape, and texture (Sakib, 2019). The main problem
faced by this fruit recognition is image segmentation. The features of this method are read using
a sparse autoencoder (SAE). Thus this paper states the identification of fruits using the CNN
algorithm. The accuracy is generated by passing through the hidden layer. Convolutional Neural
Network CNN is similar to Artificial Neural Network ANN. The input for this algorithm is an
image represented in pixel it passes through the hidden layer and output is obtained. Thus this
experiment gives the name of the fruit image with accuracy.
This article gives a detailed study about the mixture of both validation and establishment
of fake food tests with new technology. The new technology will automate the collection of data
and also the analyses. (Mezgec, 2019 ). In this method, to find fake food, technology like
matching food, deep learning, and standardization of food is used based on natural language
processing. The previous method is similar for all the processes because both segmentation and
classification of food take place at the pixel image level. To know its performance, the accuracy
and interaction that had to mean during the union of the pixel are measured. Firstly, in food
matching, food items in the image are described and then compares the recognized image with
the compositional data regarding both name and their descriptors name. Thus the final report of
the food matching provides a result with an accuracy of 93%. Further research is doing over
automated dietary assessment and also research on food choice. This method overcomes the
former research by its pixel accuracy. Nasco food model which is also known as Replica – food
model is most commonly used for Dietary assessment and also for educational purposes.
Because of its complexity, the results of this method have not performed well. In order to
overcome the issues, the new method of deep learning is implemented. This method is more
effective for image recognition. It also helps to validate the food image many times. The method
that is contributed in this paper are fake food buffet, image recognition of fake food, pre-
processing of the image, training of deep learning finally food matching. Thus an advanced
method for food recognition is developed and food images are collected using the FFB method.
The proposed paper says that the classification of food images (O'Leary, 2018) is one of
the features of Computer vision, which is most commonly used for image detection and content
retrieval. Nowadays, more researches are conducted in this area in order to classify different
types of the food image. This paper investigates about one of the main domains called food
image classification. This method is helpful for Restaurants and in intake calculators of dietary.
For this accomplishment, Deep Convolutional Neural Network is introduced in two ways.
Transfer learning and re-training of Deep Convolutional Neural Network is done. Next, the
image is extracted from CNN's pre-training in order to train the convolutional classifiers. In this
paper, a new database is introduced based on the guidelines of the Australian diet. By comparing
the other methods, the most accurate method is introduced in this paper. This gives accurate
results when compared to the existing method, but the training time taken is comparatively low
than the existing one.
The paper includes the remote sensing method and explains that deep learning has gained
more attention in research years. (Mahmoudi, 2018).
In deep learning, the convolutional neural network is the best approach in the application of
visual recognition. Google Net and VGGNet is a pre-trained model for image classification. This
model is considered a pre-trained model because of its dimensionality and it requires less sample
to be trained. This new technology shows CNN architecture that can be used for two real
hyperspectral that is real-time application data sets. By calculating the orthonormal basis that
relates to the correlation matrix, the issues over-dimension can be overcome. This will reduce the
dimensionality of the image and also increases the signal-to-noise ratio. This overall method is
performed by subspace feature extension. This paper describes the combination of both the
framework like Convolutional Neural network CNN architecture and the subspace feature to
provide more information and design CNN, this will limit the sample for the training. The
feature which is generated by the subspace and CNN framework will provide regression of this
method. This feature provides better performance by using original and conventional data based
on a recent approach. The result shows 98% accuracy by the performance shown in an Indian
university
Feature extraction using CNN and Deep learning technique:
This article details the extraction feature of images by using the Convolutional Neural
network CNN and deep learning technique. (Jogin, 2018). Moreover, image classification is
basically done by identifying the shape and geometry of the object which is surrounded by the
human. This image classification is done with four processes like pre-processing of the image,
segmentation of the image features extraction, and finally classification. The proposed method is
faster and provides better accuracy while comparing with the past method. This new technology
will be used for many applications like Features of security, authentication, face recognition,
medical areas, identification of traffic, etc. The identification of images can be done with various
techniques. Among that machine learning is the most used method for image identification. This
algorithm has been developed years ago, but it has not implemented in a better way due to
computational power. With the help of a deep learning algorithm, the image is represented in a
better way by proper training of the network. In the first layer, the CNN gets revolution by the
shapes and then in the deep layer, it will make to learn the extracted features and finally provides
accurate result. This technology has emerged as the fundamental keys for understanding the
cortex visual in the terms of humans and animals in the computer vision field. Thus this paper
features the image that has been extracted using a convolutional neural network. This performs
better in deep learning. The deep learning algorithm is used for various applications and results
show accuracy and this method is almost accepted by many researchers. This network has certain
drawbacks like training is less, computational power is lagging emerged during network scale.
These issues can be overcome by the research done in the future with a better result
The author did research and found that in the existing method, the application of the CNN
technique for fruit identification (Naranjo-Torres, 2020) is not considered the best approach. In
this paper, the advantage of using CNN over the previous method is discussed. In this study, we
are able to study details that are applied in three applications. In the first application, CNN is
applied directly to identify the fruits based on their names. This first approach is applied in
markets, supermarkets, retail shops, and also for wholesalers. The second one is identifying the
quality of fruit which is used to identify the damage on the internal and external damages that
occurs in the fruit, to know its maturity degree, and also used to identify the disease or to know
the nutrition in the fruits are in normal level. The final application is known as fruit detection that
is used in orchards for fruit harvesting, it estimates the location for harvesting fruits. The
approach of CNN may vary for different applications. THE new CNN approach is developed by
pre-training the CNN by modifying various layers and parameters. This provides an accuracy of
about 100%. It also found to be better in the area of robotic harvesting.
The main aim of this paper is to identify the fruit images using different datasets. The
name of the fruit is mentioned as Fruit 360 and can be obtained from the resource Github and
Kaggle. To obtain a good and best classifier, the dataset should be of high quality. The image
dataset contains objects and also noisy backgrounds. If we change the background, the
classification of the image will be identified incorrectly. Next deep neural network should be
trained properly to identify the image. (Mureşan, 2017). This part is considered as most complex
because the main target of this paper is to obtain the classifier and identify the object from the
image. This will suit the current trend that is working in the required field. In this, counting of
fruits and recognizing of fruits from the image is represented by using the Auto counting method.
In this article, the target is fruits that are identified based on their shape and color according to
the plant canopy. The main motive of this paper is to identify the pepper fruits in the greenhouse.
The deep learning algorithm is used in this field to identify the fruits. Convolutional Neural
network comes under Deep learning algorithm. These networks consist of a convolutional layer,
pooling layer, and fully connected layer. A deep belief network is a model that is composed of
hidden layers. This model is very important because it reduces the training time and improves the
quality. The successful output of image classification and recognition is obtained by using the
artificial neural network ANN.
The study says, in the retail stores, the vegetables and fruits payment is to be identified
manually. In this paper, the convolutional neural network CNN method is used in order to
classify the fruits that will speed up the checking process. The process is designed with three
classes that will identify the fruits with or without the plastic bags. In order to increase the
accuracy of classification, a new approach is added to the Convolutional neural network
architecture. Single RGB color, histogram, RGB centroids are the input. These are obtained from
the K means clustering. This paper shows accuracy for both fruits with or without bags.
Customers' purchases are most important to rely on Retail stores. In this paper, a minimum
number of training are performed to classify the fruits with better accuracy. Data augmentation is
also not exposed to the dataset. (Rojas-Aranda, 2020). This is also like to measure the light-
sensitive illumination. Future research can be done to compare the accuracy of CNN architecture
against the CNN along with GPU hardware and datasets. In this paper, the data accuracy for
different methods is discussed. MobileNetV2 architecture is the model used for this method and
trained with two dataset versions. The first image that having fruits without a bag and the second
image having fruits inside the bag. The accuracy of the fruit image is higher in the image without
a plastic bag. The colors are based on the background that should be taken into account. In the
future, the elimination of the background will be processed.
The main aim of this research person is to develop a system that is used to identify fruits
and vegetables. (Chandak, 2019). Particular category feature is also obtained along with the
fruits and vegetable identification. A conveyor belt is updated over the fruits and vegetables by
assumption. The input may be obtained through images, text, or videos. In this project, input is
obtained through images. In the first part, the dataset and models have selected. Next, the model
is re-trained according to the dataset collected. Thermography, tomography is some of the
specific image capturing techniques used in this task to classify the fruits and also to count the
number of the fruits present in the dataset. In this process, kaggle 360 dataset is used to extract
the data contains 96 fruit classes and contains 103 images in each 96 fruit classes. But later it is
clear that the dataset is used only for classifying the fruit image not for counting the objects. In
order to count the object, the MS COCO dataset is preferred. Models chosen for this project is
YOLO. This technique first split into grids and then classes are assigned when the objects are
detected. As a result, overlapping occurs. The accuracy also found to be lower comparing with
others. Another issue is that YOLO is best in videos than in images. Image segmentation is
another technique used here, this also fails because it is low color contrast. Tried with edge
detection, it too fails. After several attempts Mask C – RNN is used. It is single with the best
performance for MS COCO Dataset. Detection of the object, segmentation semantic are the two
functions performed by this model. Thus Mask C- RNN shows less loss, less time for every
layer.
Chapter 3
3.1 Introduction
In this portion, the methodology for recognizing the fruits using the CNN. The various
algorithms are used for the recognition of fruits are discussed below. The Hardware
requirements, tools requirements, and also the representation of the flow chart explains the
process flow would also be discussed
3.2.2.1 Flask
Flask is a framework in Python and it is segregated as a micro one since it doesn't need
any specific tools or libraries and also it helps to create reliable and maintainable applications. It
creates a defined structure for the developing application and Flask framework. The flask is a
lightweight web application in python and It is selected since it's easy to use and extends the
objective aim to create a firm base to the application when it is created. It gives a solid base even
it is complex[ CITATION SEU98 \l 1033 ]. This also prevents the duplicate images in the training
from entering the system. By using this framework the system can identify any fruit name that
gets uploaded to the system.
3.3.4 Keras:
Keras gives the interface for the programming language Python and it is given with the
deep neural networks. It also supports Tensor flow by acting as an interface. It is considered a
neural network building block. The testing input is supported with the help of Keras, it also trains
the datasets which are collected from the Kaggle. The steps involved in the Keras process are,
Keras acts as a supporting layer for Python. In this Keras layer, the layers like dense,
dropout, two-dimensional layer, activation layer, and max-pooling layer are extracted. Among
those layers, We are using the Dense layer as the important one in this project.
⦁ The dense layer is implemented only when output operation is obtained to be activation. When
the output gets activated, the Dense layer is used in this project process.
3.4 Techniques
3.4.1 Deep learning:
Deep learning is very popular in recent years because of its high accuracy when it is
trained with a high number of datasets. That is one of the primary reasons to select the deep
learning technique in this project hence a huge amount of datasets can be included to train the
system which can lead high accuracy than the previous /existing methods. Deep learning
delivered a high level of accuracy when it is tried for mage classification, identification of
the object, lost image restoration, classification of the image, etc[ CITATION Sen09 \l 1033 ]. These
techniques are used in various neural networks to train machines to automate the tasks done by
the visual systems. The primary advantage of the deep learning technique is to resolve the critical
issues that need to predict the hidden patterns of the data from the provided datasets and this
technique of finding the relationship among the huge number of related variables.
3.6.Diagram
The flowchart is generated for the method of fruit identification using the CNN and how
it enhances the process of identification of fruit with high accuracy. The dataset needs to be
trained and tested to get accurate results at the end.
3.6.1 Flowchart
The below flowchart explains the process of fruit recognition using CNN and Python.
The process begins with the insertion of fruit images and then the images get pre-processed,
Then the image gets trained using the algorithms. After training the images to get trained with
the provided datasets. Then it gets tested to get the corresponding output.
Flowchart
3.6.2 Sequence Diagram
The sequence diagram for the fruit recongition is depicted. The interaction is carried out
between the images in the sequential order in sequence diagram. The objects involved in the
scenario are shown and the sequence of messages are interacted between the specified objects in
the image which would process the scenario. This sequence diagram helps to find out how the
system functions and interacts with its image objects. The behavior of the future system or the
existing systems functions could be viewed through the sequence diagram.
3.7 Conclusion
The overall methodology and the mandatory requirements for the fruit identiifcation and
recognition. The requirement collection , tools used and the fow chart depliciting the process of
fruit recognition are illustrated well[ CITATION Woo09 \l 1033 ]. The research concept and the the
process taken on how to find the fruit exactly using the above tools ad techniques along with the
Python as programming language. The sequence diagram also designed for the sequence of
happenings that would be performed by the system. The functionality of the system and how
they are communicated with other object in the system are shown clearly so as to provide better
understanding of what actually happens in the system when these proess steps are carried out.
Chapter 4
4.1 Introduction
Python is used as the coding language i the project and the mandatory functions would be carried along
with the imported libraries functions. The flask framework would be built to enhance the applications that
are complex. The deep learning algorithm and CNN used to create the project effectively[ CITATION
Dew21 \l 1033 ]. The functions and the methodology are created to detect the fruit based on the color,
shape and size. The coding created for recognizing the fruits irrespective of the shape, size and
color[ CITATION Sen09 \l 1033 ].
The steps involved in fruit recognition are collection of data, pre-processing the obtained data, extraction
of image, classification of image finally evaluation or validation of image. Each stage in this project gives
output based on their requirements[ CITATION Jan16 \l 1033 ]. The flowchart for the fruit recognition is
given.
Collection of data:
For this project, the data are collected from the open source website “kaggle”. Kaggle helps the users to
find the data and publish in better way. In this project, 15 fruits images are extracted from the kaggle
dataset. The data’s obtained from other source cannot give a clear image. After collecting the data’s, the
images are passed through the deep neural network[ CITATION Che17 \l 1033 ]. It helps to train the system
and provide the result with high accuracy. After downloading the datasets, proper library should be
loaded in order to compose a data frame. Data frame is formed by using add loop function. From the data
framework, the fruit is classified as fruit name, path and label is formed for each 15 fruits. This project is
formed by using python libraries namely tensor flow and keras.
Above chart describes the flow chart of fruit recognition. Designs based on requirements. Each stage
gives desired output based on their constraints.
Pre-processing of image:
After collecting the datasets, next process to be performed is image pre-processing. In this phase
unwanted images that is image with poor quality is eliminated before passing the image through neural
network. With the help of pre-processing, the bad quality image is deleted, distortion is eliminated. Pre-
processing is an important process that should be used before starting image classification. It is essential
to delete the unwanted images from the datasets. In this phase, the image is first converted into gray scale
and then to gray threshold and finally to black and white image by removing all the impurities. Now the
collected data is ready to process[ CITATION Woo09 \l 1033 ]. The collected data is encoded then decoded
in order to obtain image with high accuracy. Decoded image is passed to the image resizing, in this the
original image is re-sized into quarter of its original image, then it is passed through image array
convertor in order to convert the image into black and white image, that black and white image is passed
to the dimension expander then it starts predicting.
Feature extraction of the image is important for every terms of machine learning, in recognition of pattern
and also in image recognition. After pre-processing of the image, next stage to be performed is feature
extraction. Feature extraction includes extraction of image based on shape, size and texture. Two
important features of fruit recognition are feature extraction and identification of feature. Feature
extraction is one of the processes in image classification[ CITATION WKJ03 \l 1033 ]. The methods like
Histogram of oriented Gradients HOG for extraction of shape, HSV, Color histogram and color histogram
for extraction for color and finally GLCM for extraction of texture. In this project, tensor flow has a
special feature to map the images. In terms of convolutional network, pooling layer is used to reduce the
spatial size of the fruit image. Each image mapped feature is converted into single dimensional array.
Extracted fruit image is used for further process and to get desired output.
Classification of image:
Next phase in image recognition is classification of fruits, which is important process in the image
identification. By using the deep neural network, the classification of fruits takes place. In this project, 15
types of fruit images are classified along with path and label. Proper training is given in order to obtain
image accuracy. Here the images are obtained in cluster format. It will categories the fruits in different
format. The cluster 1 may indicate the fruit apple, cluster two indicates orange fruit, cluster 3 indicates
fruit banana and so on. In this phase 15 varieties of fruits are classified. Thus this phase helps to train the
system and get the output which is desired[ CITATION SEU98 \l 1033 ]. The challenge towards image
classification is it has to identify different types of fruits and next it has to identify different varieties of
fruits among the types. Classification of fruits is quite difficult because fruit 360 dataset consisting many
types and varieties of fruits.
Image evaluation:
Final stage of the fruit recognition is image evaluation. In Deep neural algorithm, convolution network
helps to identify the images by using different layers. Thus final image is obtained by comparing the
extracted and tested data with the original fruit image[ CITATION AAR97 \l 1033 ]. Finally, the desired
image is obtained in this phase with high accuracy. Evaluation of the images is done after the
classification technique. Evaluation gives the final output based on their constraints.
Loading libraries:
The gathered dataset samples are pre-processed using the data pre-processing technique. The
image needs to be pre-processed are imported using the ImageDataGenerator and the Keras is used as the
frame work in this proposal for the fruit recognition. With Keras the cognitive load gets decreased since it
follows the methods effectively and it provides easy and reliable APIs which deceases the user actions and
it provided the high accuracy in the fruit identification.Keras is easy to learn and reliable source
Keras used as an optimizer in this project. Optimizers are used to modify and shape dataset that
needs to be trained to the exact form with the datasets and it is used in this project due to the learning rate.
Decay rate increase small learning rate which can be used so the loss won’t change after the drop to the
point .When the model shows perfect accuracy at the time of handling the data and the situation occurs
when the model has set of complex rules. The datasets train_test_split function are used to split the
datasets for two different resolutions: Training and testing. The training dataset is to create the model and
the testing dataset is to evaluate the performance of the model. The huge number of datasets is imported
for the training and also various datasets are used to test the dataset models to give the high accuracy
outputs. Sklearn (Scikit learn) is a Library function of Python that provides multiple processing features
for the data and it is used for the segregation, combination and the sample selection. The model_selection
is a process for creating the map for analyzing the data and then this is used for measuring the new dataset.
The sample selected properly allows creating accurate outputs when the prediction is completed. The fruit
is recognized and then identified using the pattern prediction
In this step, the model has to be trained using the provided samples and then the model is tested
against the leftover dataset. When there is a dataset, it has to be split using the Sklearn train_test_split
function.
Pyplot is a set of functions that build Matplotlib work like MATLAB. Every Pyplot function generates
few changes to the sample picture. E.g. creating a picture creates a conspiracy location in the image and
plot few highlights in the area, adorns the spot with mark. The random process is imported from the
library, in this method this returns random number as output between 0 and 1. Based on the random
number creator function, the random modules functions and also the created float (random) number is
between 0.0 and 1.0. Arguments are not needed for the function. The dataset is selected randomly with
different fruits with different colors, shapes and sizes. Import CV2 files from the python library bindings
and it is built to resolve the image issues. In the CV2, imread() is a process to load an image from the
saved file. If the image is in not readable format due to poor quality of the image, image missing state, if
it don’t have exact permissions, or if the format is invalid then the output matrix will be empty. The
python has OS module which gives different functions to work along with the operating system. OS is
one of the common utility Python modules. This module gives an easiest option of utilizing operating
system functionality (dependent). Import sequential is a part of the keras framework and it has multiple
layers and sequential model is related by fleeting multiple layers to the generator. From the Keras models
import the sequential from the layers of keras and then import dense and the activation model.
load_image_from_folder supports to import images from the dataset folder. Listdir() method in python
helps to get all the files and directories in the mentioned directory. This return all the files and
directories that are mentioned. After loading the libraries , path is needed for image storage. In
order to load the images in the path , the function load image from folder is used. Then the
stored images in the path and the data frame is generated for every fruit and named every fruit
with the path. The loop is generated for this process. After naming the fruit, then the function
returns the path and this loop goes untill the exact identification of all the fruits.
Dataset shuffling:
The Data frame (df) function selects data by mention of the rows and columns. The df. loc indexer inputs
data in a various way than just the indexing operator. It can opt subsets of rows or columns. It can also
select subsets of rows and columns respectively. After giving their specific number, resulting data frame
is visualized for first 10 rows. The above figure represents the visualization. The visualization is
represented in terms of fruit name, path and label. After visualization, fruit types that are distributed in the
datasets are plotted.
Dataset display:
Fig 6: display the dataset
The imshow function displays the picture of the fruit, but does not store the image data in the
MATLAB storage. If the dataset has many images, imshow displays the first pciture in the dataset.
When generating a colorbar in a plot with multiple images, it needs to be mentioned which image this
color bar needs be generated and it is mentioned as plt. After visualization, 10 pictures from the datasets
are displayed along with their labels. The images obtained are used for recognition of the fruit with high
accuracy. This image is obtained during the pre-processing stage. Once data is collected from the source
kaggle, image is uploaded to the training system that helps to encode the image; obtained image is
decoded to open the image in required format. Decoded image is resized in terms of height and weight.
Image array converter is used to convert the resized image into black and white image, and then
dimension of that black and white is expanded. After the following steps, the process starts to predict the
images. These steps take place in the pre-processing stage. It also helps to delete the corrupted images
obtained during the dataset collection.
Fig 7: comparison of original and re-sized image
plt. show() begins a loop and looks for the existing figure objects and opens one or many connected
windows tat shows the figures. The plt.show() provides the interactive backend. In this part, the original
image is compared with the resizing image; the process starts to predict the high accuracy. The original
picture is resized in order to have the same size of the deep neural network. Resizing of the image is done
with 150X150 formats. This resizing makes half size of the original image.
Fig 8: layer uploading
Import Conv2D ,2D convolution layer generated a kernel that is convolutional with the input layer to
create the outputs with tensor flow. When the activation is not any then it is applied to the outputs as well.
During the usage of the Conv2D layer as the first one in the model, insert the function argument and find
the difference based on the Picture colours. The variation of the image represents the different fruits in the
dataset. Max pooling is used when the down samples are inserted by accepting the maximum values
through the window mentioned by the pool size for all dimension along with the axis. The window is then
changed by strides in every angle. The output got finally has needed information (with the number of
rows or columns) when it using the padding option as Valid. The output image is same. More dataset of
fruits goes through more training and testing and it results with the accuracy rate is high.
After resizing, model supports sequential manner. Layers abstracted from the keras sequential models are
activation, flatten, dense, dropout, conv2D and maxpooling. Dense layer is used to interconnect all the
layers that return the output as the input for the next layer. Dropout layer is used to remove the unwanted
neurons present in the neural network. It will reduce the overloading the images during the training
period. Flatten is used to collapse or merge the image into one dimensional array or D array. It
automatically extracts the features of the image. Maxpooling is 2D spatial layer which is used to extract
exact image feature by reducing the dimension. Pooling is used to avoid over fitting. By using this
original image is converted into quarter the size of original image. Activation is used to increase the non-
linear property of the image. After this, activation is connected to the pooling layer.
After applying the images to the layer, testing process takes place. Result is obtained by using the
prediction taken place in the test. Accuracy of the data frame is obtained. Based on that accuracy, training
result is gathered.
Train and test, the testing data set needs to be selected and the other dataset is taken as the training
dataset. The model on the training set fits and then the test set is validated. The validation score retained
and sample got discarded. Training is given to the test dataset for accuracy. In order to increase the initial
statement of the project, pre-training is given to the deep belief algorithm. Proper training should be given
to every network for getting results with high accuracy. Improper training results are displayed in
unsuccessful result. In this X train and y train needs to be deleted often in order to free up the storage.
Model accuracy, the accuracy of the model is noted here and if the classification error is taken into
consideration and then the accuracy that can be achieved is 100% and if the regression errors are taken
into account then the error rate 0.0 and these accuracy is highly not possible to achieve. The prediction
modeling also has prediction errors.
Epoch is the number of epochs has to be set manually and the high number of epochs give the best
accuracy rates hence the epochs needs to be set in maximum and the based on the error rates the
termination training needs to be done and an epoch is one learning cycle where the whole training data set
is known and when there is more than one batch then for one epoch two needs to be done.
Images are passed to the deep layer in order to provide training. The time taken to load the image and to
provide training in the deep learning algorithm takes up to 1312 seconds. The input of the sigmoid is
represented in binary format either as 0 or 1. After successful training, the accuracy of the uploaded
image is obtained. Compare accuracy of the obtained image with the validated image accuracy. Thus
result shows the distribution of various types of fruits and vegetable images. The outputs are represented
in the graphical manner. Network consist of various loss function, the loss in the network can be reduced
by using the software softmax and sigmoid cross entropy. Information loss of the images can be reduced
by using padding function. Each steps implemented gives a desired output based on their constraints. The
output shows 94.75% accuracy.
Above image represent the recognition of fruits and the stage before identification. The listed images are
tomato, persimmon, banana, mango, peach, petya and orange. Each fruit is classified based on their path
and label[ CITATION MTB06 \l 1033 ]. The numbers given to each fruit will helps to identify the fruit
easily.
Fig 13: fruit types distribution
The above image represents the distribution of different types of fruits. The distributed fruit varieties are
apple, kiwi, mango, guava, banana, orange, pear, peach, pitaya, plum, tomatoes, pomegranate, carambola,
muskmelon, and persimmon. From the result, it is clearly noticed that apple reached highest distribution
while persimmon, muskmelon and carambola found to be lowest which is in same level.
The above image represents the classification report done by using the last 1/20 or 2220 dataset.
Fig 17:
confusion matrix
Above image represents the confusion matrix in which the accuracy of the fruit recognition is obtained by
using CNN model.
Above image represents the difference between the true and predicted label. Thus the classification of
fruits with 94.75% is obtained.
4.6 Challenges
The major issue faced by fruit recognition using deep neural network is MNIST benchmark. In this
project the fruit 360 dataset consist of large number of datasets with different classes of image. Hence the
dataset in this project is to be specific. The task is based on fruit recognition. The computer will face a
challenge because there is large number of fruits classification in the dataset. Another issue is different
types of fruits to be identified, then fruits with different varieties to be identified. Padding is used to
neglect the loss. Pooling layer is used to avoid over fitting.
4.7 Conclusion
In the proposed project, the fruit recognition is achieved using the CNN and Deep learning approach.
There are plenty of methods available to segregate the fruits based on the pattern. The project is to
identify the fruits with the accuracy rate high. At the time of deep learning is a huge step in image
processing The CNN is analyzed via its layers and among those the important layer is a dense layer.
A dataset is collected from the source kaggle, due tio its clarity and reliability. By using the pre-
processing technique, image with poor quality and corrupted can be removed. By using the open source
software Jupiter, the dataset collected for import to the training. Tensor flow library is used for testing and
training the data. By using the neural network, the images are classified using the name of the fruit like
apple, orange, banana etc. Process and methodology discussed in the project helps to know better about
the convolutional neural network[ CITATION JZh05 \l 1033 ]. Design and analysis is done in order to
recognize the fruits with high accuracy. The image structure is identified to predict the pattern during the
pre-processing stage. Google colab is recommended for future to overcome the issues in the fruit
recognition project. Implementation section clearly shows the project steps and methodology followed to
implement the project. Outcomes have been obtained after the successful implementation and results are
discussed in better manner. Much research has been done in order to classify the fruits and researchers
have stated their opinion based on their view prior. But fruit recognition by using deep learning provides
better result. The accuracy of this fruit recognition by using deep neural network algorithm is found to ss
94.75%. This project helps to reduce the intervention of human, less time consuming and will helps to
access the fruits in the supermarket, in agricultural area easily. The results are found with high accuracy.
5.0 Reference
Brewer, M., L.Lang, Fujimura, K., Dujmovic, N., Gray, S., & Knaap, E. (2006). "Development of a
Controlled Vocabulary and Software Application to Analyze Fruit Shape Variation in Tomato and
Other Plant Species. Plant Physiology, 6.
Cheng, Hong, Damerow, Lutz, Sun, Blanke, Y., et al. (2017). Early Yield Prediction Using Image Analysis of
Apple Fruit and Tree Canopy Features with Neural Networks. Journal of Imaging, 6.
Dewi Agushinta R, H. M. (2021). A Method of Cloud and Image-Based Tracking for Indonesia Fruit
Recognition . IEEE XPLORE, 6.
Jana, ]., Susovan, Parekh, & Ranjan. (2016). “Intra-class Recognition of Fruits using Color and Texture
Features with Neural Classifiers. International Journal of Computer Applications, 6.
Jimenez, A., R.C, & Pons, J. (1997). "Shape-based Methods for Fruit Recognition and Localization using a
Laser Range-Finder. International Workshop on Bio-Robotics, 6.
Jimenez, A., R.Ceres, & Pons, J. L. (2000). A survey of Computer Vision Methods for Locating Fruit on
Tree. IEEE XPLORE, 6.
Jung, W., & Cho, N. (2003). Relevance Feedback in Content-Based Image Retrieval System by Selective
Region Growing in the Feature Space. Signal Processing: Image Communication, 6.
S.E.Umbaugh. (1998). "Computer Vision and Image Processing: A Practical Approach using CVIP tools.
First ed. Prentice Hall Professional Technical , 6.
Seng, Chaw, W., & S.H, i. (2009). A New Method for Fruits Recognition System. ICEEI'09 International
Conference on Electrical Engineering and Informatics,, 6.
Seng, W. C., & Mirisaee, S. H. (2009). A New Method for Fruits Recognition System. International
Conference on Electrical Engineering and Informatic, 6.
Zhao, J., Tow, J., & Katupitiya, J. (2005). "On-tree fruit recognition using texture properties and color
data. n international conference on Intelligent Robot and Systems, Edmonton Canada., 6.