You are on page 1of 8

e-ISSN: 2582-5208

International Research Journal of Modernization in Engineering Technology and Science


Volume:02/Issue:06/June-2020 www.irjmets.com

FRUIT FRESHNESS DETECTION USING CNN APPROACH


Aniket Harsh*1, Kishan Kumar Jha*2, Shashwat Srivastava*3,
Abhinav Raj*4, Raghav S*5
*1,2,3,4
Student, VTU, Department of Information Science and Engineering, Sir M. Visvesvaraya
Institute of Technology, Bengaluru, Karnataka, India.
*5
Associate Professor, Department of Information Science and Engineering, Sir M. Visvesvaraya
Institute of Technology, Bengaluru, Karnataka, India.

ABSTRACT
Grading of fruits is based on inspections, experiences and through observation. The suggested system utilizes
machine learning technique to grade freshness of fruits. 2D fruit portrayals are graded on shape and color based
analyzing method. Maybe different fruits images might have similar color, size as well as shape values.
Therefore, using color or shape property analysis methods are not very effective to identify and differentiate
fruits images.
Therefore, we used a technique to increase the accuracy and perfection of the fruit freshness detection with the
help of size, shape and color based method with the union of Convolutional Neural Network (CNN). The
suggested system initiates the procedure by clicking the fruit's image. Then, the image is transferred to the
filtration level where the properties like size, shape and color of fruit samples are withdrawn.
Henceforth, with the use of convolutional neural network, the fruit pictures are going through training and
testing process. In this proposed paper, convolutional neural network is employed to draw out the size, shape
and color of fruit and with the union of these three features, the obtained results are very encouraging.
KEYWORDS: Image Processing, Machine Learning, Deep Learning, CNN.

I. INTRODUCTION
One of the largest economic sectors is agriculture and it plays the vital role in economic growth of India. Still in
India, the traditional examination of fruits is performed by human specialist. A large amount of time and money
is wasted in the fields for checking the freshness of the fruits by humans.
In this paper, we are analyzing a safe and economic way to detect the fruit freshness based on size, shape and
color. Testing of fruits should be done in a non-damaging methods because these are very fragile items. While
fruit sizing, the key physical property is it’s color, which provides the visual property.
Hence, classification of fruit freshness is very important, for increasing the market share and establishing a
better quality standards. If the classification and grading is done through manual methods, the process will be
slow and sometimes it will be full of errors. The humans classify fruits freshness based on color, size, etc.
If these quality measures are mapped into automated system by using suitable programming language then the
work will be faster and without errors. This results in increasing speed and decreasing cost in fruit sorting
process. Recently, deep learning techniques have been found progressively useful in the fruit industries, mainly
for the applications in fruit freshness detection.
Fruit characteristics such as shape and color are pivotal for perceptible inspection. A systematically independent
structure for fruit grading based on freshness must be able to efficiently identify both the parameters. We can
easily obtain the shape of the fruits from their digital image.
However, color recognition involves a lot of psychological and physical concepts, making it difficult to
accurately model and process color in that image. There are many different grades of color systems that are
present for the sorting of fruits based on colors. In this classification system based on their color, software
development is very important.
www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science
[456]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
Volume:02/Issue:06/June-2020 www.irjmets.com
The complete structure is designed over neural network concept to inspect the color, size and shape of the fruit.
The most important factor in fruit classification is it's color, but many fruits have similar color, hence their size
help us to solve this kind of problem. The size and color based categorization involves extraction of the
necessary data from the fruit by physical observation of the surface and sorting it to the respective grade.
Convolutional Neural Network (CNN) is employed to recognize the size, shape and color of different fruit
samples. The journal is ordered as follows: Section 2: Discussion of the work done in past years by different
publications. Section 3 explains the suggested fruit freshness detection technique. Section 4 shows the quality
detection experimental results. Finally, conclusion is in section 5.

II. LITERATURE SURVEY


The inexplicable research work done in recognition or segmentation of objects for further classification has been
done. For efficient and accurate identification of fruit, features extracted from the segmented image considered
to be an essential part. In order to understand the current state of art in this area, a survey of work done related to
recognition and categorization of fruit has been presented in this chapter. Aleixos et al. [2002] designed and
implement a multispectral camera to capture noticeable and near infrared images.
The main focus is on size, color and existence of defects on citrus fruits. The given experiment is skilled to
study the lemons, mandarins and oranges. The study presents a parallel system for estimating size as well as
inspecting its surface for diseases. Proposed system is capable of classifying mandarins and lemon correctly
with the precession of 93% [1]. Kleynen et al.
[2003] described the optimum filters for distinguishing broad range of wavelength for detecting defects on fruit
based upon quadratic discriminant analysis. Multi spectral perception structure is used for this work.
Reflectance spectra of the sound and damaged surface can be observed with the help of NIR spectrometer.
Defects considered are scald, visible flesh damage, bruises, frost damage etc.
For differentiating bruise surface from healthier one is performed by the use of combination of four filters. Thus
the proposed method was able to select the wavelength band to sort the jonagold apples [2]. Leemans and
Destain [2004] have presented a grading method for jonagold apples only.
Technique used in this approach is k-means clustering which clusters the objects and clusters undergoes for
classification. Results of the categorization possibilities of objects were analyzed and jonagold is graded on the
basis of these results. There are various steps that performed for grading the jonagold apples.
First image acquisition is performed and then segmentation of image is done to locate the fruit in the image. .
Finally find the possibility of defects for the grading purposes. The correct rate of classification for jonagold
apple is 73% [3]. In agricultural and horticulture, one of the mainly used applications is image processing.
In this paper, quality identification is done automatically using few image processing methods that can be done
with the help of some image features like shape, color and size. This research work presents the distinguishing
of good and bad fruits are focusing on image processing techniques like segmentation and classification. First
withdraw few defined features from the inserted image, later with the help of different techniques like
dissolution using k-means clustering, thresholding and classification using SVM (Support Vector Machine) and
CNN (Convolutional Neural Network). It gives the output in respect of percentage of accuracy.
Color is the most noticeable property for pinpointing disease and growth of the fruit. In this paper, with the help
of few efficient algorithms we have reviewed the extraction of color features. The aim of this journal is to
provide a launch to machine and deep learning and color based sorting algorithms, it’s constituents and present
work described on an automatic fruit sorting system.
III. METHODOLOGY
The methodology that involves in this scheme involves the following steps.

 Select the fruit Images.


 Resize all fruit images to standard size.

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[457]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
Volume:02/Issue:06/June-2020 www.irjmets.com
 Convert all the RGB images into Gray Scale.
 Changing the dataset from having (n, breadth, height) to (n, depth, width, height).
 Split dataset into training, test & validation set using keras train_test_split command.
 Transforming our data type to float32 and normalizing our data values from 0-255 to the range [0, 1].
 Preprocess class labels.
 Define our model architecture.
 Compile model with stochastic gradient descent optimizer and categorical-cross entropy and also the
learning rate=0.0001.
 Fit and train data.
 Evaluate model on test dataset and calculate the confusion matrix.
 Classification has to be done through Python 3.6.
Convolutional Neural Network
CNN are a specialized type of ANNs used for image analysis. Since computers sees image as a matrix of
numbers that represent single pixel, it is important that the relation between the pixels (values) remains same
after the image is handled through the network.
Convolution neural networks are used to save the spatial relationship between the pixels, that have different
mathematical operations piled on top of each other to generate layers of the network.
Architecture of CNN model
In this paper we suggested a two-track deep neural network model architecture. The first layer comprises of
deep learning algorithm i.e. convolution neural network with maximum pooling to increase the structural ability,
whereas the second layer comprised of fully connected layers.
Apart from the final concentrated layer of output neurons, the neural network has four layers of middle hidden
neurons. The input holds 160×160×4 neurons, which represents the RGB(Red, Green and Blue) value for a
160×160×4 image. The first convolution-pooling layer apply a local receptive field of size 4×4 with a stride
length of 1 pixel to extract 32 feature maps, followed by a max pooling operation managed in a 2×2 region, the
second and third convolution-pooling layers use the same 4×4 local receptive field (kernel) resulting 64 and 128
features maps respectively whereas other parameters remain not changed.
The fourth layer is fully-connected layer having 128 ReLU (rectifier linear unit) neurons and 16 SoftMax
neurons are there in output layer that corresponding to the 16 different categories of fruits. The three
convolutional-pooling layers also utilizes ReLU activation functions.
In the Figure below shows the main four operations in the Conv.Net:
1.Convolution
2.Non-Linearity (ReLU)
3.Pooling & Sub Sampling
4.Classification (Fully Connected Layer).

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[458]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
Volume:02/Issue:06/June-2020 www.irjmets.com
Convolution in instance of Conv.Net is used to withdraw attributes from input image. Convolution converses the
spatial association among pixels by learning image properties using small squares of input image.
The model which will use 4×4 filter to evaluate convolved properties. Rectified linear unit is the full form of
ReLU, a non-linear operation. The main motive of ReLU is to insert non-linearity in the Conv.Net because
mostly Conv.Net has to learn non-linear real world data. In our Network, we use ReLU activation method since
it trains the neural network many times faster without a notable abundance to generalizing precision and
accuracy.
The benefit of ReLU is it’s unsaturation of the slope, which highly accelerates the concurrence of stochastic
gradient descent as comparison to the sigmoid / tanh method. Another attribute is that compared to tanh/sigmoid
neurons that demands costly operations, the implementation of ReLU can be simply done by thresholding a
matrix of activations at zero. Fully connected layer is a multi-layer perceptron that uses a SoftMax activation
method in the final output layer.
The convolutional and max-pooling layers extract high level features from image and used fully connected layer
to classify the input images. The network was trained with the stochastic gradient descent algorithm with a
cross-entropy cost function. As far we know the Adaptive optimizers are optimum for getting faster viable
results, but SGD plus momentum is generally a better approach for getting genuinely good results.
It just takes extra labor to tune the hyper parameters properly. The dropout used to overcome the over fitting
problems with dropout rates of 0.5 and 0.35 were placed for the third convolutional pooling layer and fully-
connected layer respectively. Spatial dimensionality of the obtained output as well as sampling is accomplished
by the pooling layer, moreover decreasing the number of specifications within that activation.
The fully-connected layers then performs the same purpose as discovered in standard For classification purpose,
class scores and ANNs were produced from the activations . Furthermore, ReLU was used among these layers to
increase the performance.
Dataset
Datasets plays very vital role in research as it is much expensive and harder to generate.
Therefore, our main aim was to design a dataset which contained different fruit images which contained
different feasible fruit images and where represented by as many images as possible. The snapshots were
captured at a resolution of 320×258×3 pixels by using High definition web camera. From experimental view,
they were reduced to 150×150×3 resolution sample in the journal.
The dataset comprising of 12 different categories with four different fruit with each fruit divided into ripped,
unripe and over ripped. All images are saved at 16 bits per channel in RGB color-space. These properties
increased the dataset irregularity and show more practical scenario. The Images had huge differences in quality
and radiance. Illumination is part of these variations in imagery.
As a matter of fact, same fruit can generate two images due to radiance less close than two images of fruits of
different. The dataset of fruits were collected under comparatively less restricted conditions. Images were also
taken with different conditions i.e. with lights of the room on and off, changing the position of camera into
different angle, open windows, closed windows, open curtains, and closed curtains scenario.
For a real application, it is very essential to manage with radiance variation, camera snapshot artifacts, shadows
and specular reflections. We generated all kind of real world challenges for our dataset within our laboratory
environment. Basic few constraints which we considered during dataset collections are:

 Pose differences with different kind of fruits.


 Variable number of fruits.
 Used High definition Webcam to take images.
 Same color but different classification fruits images.
 Different color same classification fruit images.
 Different lighting surroundings.
www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science
[459]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
Volume:02/Issue:06/June-2020 www.irjmets.com
To establish a large amount of differences, fruit portrayals have been imprisoned by different fruit inclination,
variability on the number of fruits, radiance and fruit size.

IV. RESULTS AND DISCUSSION


This section presents the experiments and quality detection of fruit samples along with an unknown fruit.
In order to better understanding of the project, we have taken two different fruit samples which are different in
size, color and shape, and also an animal image to compare with the given result of the system for better
understanding.
The CNN based outcome of the three samples are shown below in the form of a table and also in a descriptive
pie chart respectively.
Table 1. Comparison of 3 different images.

SN Category

1 Apple Ripe 96.85 0.93 3.5

2 Apple 0.02 0.207 1.86


Overripe

3 Apple 2.5 0.297 2.95


Underripe

4 Banana Ripe 0.001 0.045 2.56

5 Banana 0.006 0.022 11.8


Overripe

6 Banana 0.035 0.025 3.03


Underripe

7 Mango Ripe 0.058 89.72 2.6

8 Mango 0.005 0.247 18.11


Overripe

9 Mango 0.257 2.036 2.337


Underripe

10 Orange Ripe 0.001 5.4 10.42

11 Orange 0.004 0.93 13.83


Overripe

12 Orange 0.106 0.63 10.19


Underripe

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[460]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
Volume:02/Issue:06/June-2020 www.irjmets.com

13 Pomegranat 0.064 0.11 8.095


e Ripe

14 Pomegranat 0.023 0.144 6.399


e Overripe

15 Pomegranat 0.015 0.01 2.264


e Underripe

Resul - APPLE RIPE MANGO RIPE UNSURE


t

Fig. - Fig: 1 Fig: 2 Fig: 3

Fig-1: Apple Ripe

Fig-2: Mango Ripe

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[461]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
Volume:02/Issue:06/June-2020 www.irjmets.com

Fig-3: Elephant(Unsure)

V. CONCLUSION
This paper focuses the use of convolutional neural network(CNN) in the field of food industry and agriculture.
The most important quality characteristics of agricultural products are size, color and shape.
To restore physical examination of food, CNN is widely employed which gives us genuine, unbiased and
constructive classification. We also established our own experimental database. The suggested technique
recognized fruits freshness (under ripped, ripped and over-ripped) with many real-world challenges in our
dataset, in order to enhance the functionality and versatility.
Hence, the suggested technique efficiently intensifies the rate of identification of fruit and its freshness
detection, so that the real world application demands can be achieved. We have carried out many experiments
our dataset and the results have showed that our classification system has achieved high accuracy rate.

FUTURE ENHANCEMENT
Furthermore, the design can be changed by increasing the width of conveyor belt so that the quality inspection
of fruits larger than tomatoes can be perform easily and to increase the precision of the system so that it can
further differentiate between natural and artificial color from original fruit color.
And also we can redesign our machine to work with a database consisting the information of different medicine
approved by the government along with their composition, usage and their side effects which can be known just
by taking a snapshot of the medicine and the system will recognize its name and the manufacturing company's
name along with its batch number and further retrieve more data from the database.

ACKNOWLEDGEMENTS
The pleasure and ecstasy that escort the successfully completion of any task would be incomplete without the
mentioning of the people who made it possible, whose constant guidance and encouragement crowned our
efforts with the success.
We are indebted to our guide, Mr. Raghav S., Asst. Professor’s, Department of Information Science and
Engineering, Sir MVIT, Bengaluru, who not only coordinated our work but also gave suggestions from time to
time.
We are greatly thankful to Dr. P. Vijayakarthik, Professor and HOD, Department of Information Science and
Engineering, Sir MVIT, Bengaluru, for his able guidance, regular source of encouragement and assistance
throughout this project.
We would like to express our immense gratitude to Dr. V.R. Manjunath, Principal, Sir MVIT, Bengaluru, for
www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science
[462]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
Volume:02/Issue:06/June-2020 www.irjmets.com
providing us with the excellent infrastructure and various other facilities to help get this project to its final
course.
We would also like to gratefully acknowledge the help lent out to us by all the faculty members of the
Department of Information Science and Engineering, Sir MVIT, Bengaluru, at any difficult time. We would also
like to take this opportunity to thank our college management for the facilities provided during the course of the
project. Furthermore, we acknowledge the constant support and feedback lent by our parents and classmates.

VI. REFERENCES
[1] Rashmi Pande, Nikunj Gamit, Sapan Naik, “Non-Destructive Quality Grading Of Mango (Mangifera
Indica L) Based On CIELAB Colour Model and Size”, IEEE International Conference on Advanced
Communication Control and Computing Technologies, pp. 1246-1251, 2014.
[2] S.P Archa, C. Sathish Kumar,” Segmentation of Brain Tumor in MRI images using CNN with Edge
Detection,” International conference on emerging trends and innovations in engineering and
technological research, July 2018.
[3] Sukhpreet Kaur, Akshay Girdhar and Jasmeen Gill, “Computer Vision-Based Tomato Grading and
Sorting”. J. Gill RIMT IET, Mandi Gobindgarh, India © Springer Nature Singapore Pte Ltd. 2018 M. L.
Kolhe et al. (eds.), Advances in Data and Information Sciences, Lecture Notes in Networks and Systems
38, https://doi.org/10.1007/978-981-10-8360- 0_7
[4] Dr. Muhammad Anzar Alam ,Engr. Zahida Parveen , Engr. Hina Shakir “Assessment of Quality of Rice
Grain using Optical and Image Processing Technique”, 2017 International Conference on
Communication, Computing and Digital Systems (C-CODE) 978-1-5090-4448-1/17/$31.00 ©2017 IEEE
[5] Sajad Sabzi, Yousef Abbaspour-Gilandeh, JuanIgnacio Arribas, “Non-intrusive image processing
Thompon orange grading methods” 978-1-5386-0566-0/17/$31.00 ' 2017 IEEE
[6] George Mathew Akshaya, Jaina George, Dr. J. S. Janardhana, K. J. Sabareesaan Research scholar,
Annamalai University, India. International Conference on Current Trends in Engineering and
Technology, ICCTET’13 IEEE 2013 IEEE- 32107 July 3, 2013, Coimbatore, India
[7] Ruchita R. Mhaski, P.B. Chopade M.P. Dale “Determination of Ripeness and Grading of Tomato using
Image Analysis on Raspberry Pi”2015 International Conference on Communication, Control and
Intelligent Systems (CCIS) 978- 1-4673-7541-2/15/$31.00 it 2015 IEEE
[8] Fatih Ertam and Galip Aydam – “Data Classification with Deep Learning using Tensorflow”, 2nd
International Conference on Computer Science and Engineering, 2017.

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[463]

You might also like