Smart Food Sorting Using Deep Learning
Smart Food Sorting Using Deep Learning
Abstract—Food quality detection refers to the process of allows for the evaluation of fruit freshness without the need to
2024 3rd International Conference on Advanced Electrical Engineering (ICAEE) | 979-8-3503-4935-1/24/$31.00 ©2024 IEEE | DOI: 10.1109/ICAEE61760.2024.10783364
evaluating and assessing the characteristics, properties, and cut, peel, or otherwise physically alter the fruit. Traditional
safety of food products to determine their overall quality. It methods of checking fruit freshness, such as cutting open the
ensures that the food is free from harmful contaminants, such as fruit to examine its color, texture, or aroma, can lead to waste
bacteria and viruses. Traditional methods involve various testing
and reduce the shelf life of the fruit. Non-destructive
techniques to identify potential issues related to safety and
nutritional value. However, these methods often require manual techniques, on the other hand, enable fruit producers,
labor, resulting in extended detection times and laborious distributors, and retailers to assess the quality of the fruit
processes. Food fruit sorting techniques, on the other hand, are without compromising its integrity, allowing them to make
methods used to categorize and separate fruits based on informed decisions about its handling, storage, and
attributes such as size, color, shape, ripeness, and quality. In this distribution. Among these techniques, we find imaging, which
article, we present an embedded system remotely connected to a is based on cameras, and computer vision algorithms that can
server-trained model for fruit image classification using the analyze visual characteristics like color, shape, and surface
Convolutional Neural Network (CNN) deep learning algorithm. features to determine freshness. This article introduces an
The accuracy of the model reached 94% in the validation set.
embedded system that is connected remotely to a server-
The embedded system is based on a Raspberry Pi
microcontroller equipped with a camera, enabling real-time trained model for fruit image classification. The rest of the
sorting of fruits into six categories: fresh orange, fresh banana, paper is structured as follows: The related work in this axis of
fresh apple, rotten banana, rotten apple, and rotten orange. research is presented in the second section. Third we propose
Additionally, it incorporates a weight sensor to determine the a system that is divided into two main parts, one for creating a
total weight of each category.
model to classify the food fruit using CNN, the second for
proposing a smart embedded system to sort these foods, we
Keywords—food sorting, convolution neural network, embedded also propose the algorithms for the communication scenario
system, Raspberry Pi, quality detection and controlling the servo motors for triggering the actions by
the microcontroller, the fourth section is dedicated to the
I. INTRODUCTION discussion and results, In the final section, we present the
According to the World Food Summit’s definition, the conclusions drawn from our work, along with discussing
objective of food safety is to ensure that every individual has potential perspectives and aspirations for future endeavors.
access to safe, nutritious, and sufficient food that meets their
dietary requirements and preferences, promoting a healthy and II. RELATED WORKS
active lifestyle [1]. The key factor influencing public health Machine learning has the potential to harness vast and
and social security is food safety [2]. Around the world, an emerging data sets effectively, leading to enhanced food
estimated 600 million almost 1 in 10 people fall ill after eating supply safety and effective mitigation of food safety incidents
contaminated food each year, resulting in 420 000 deaths and [5]. Machine learning powered computer vision systems can
the loss of 33 million healthy life years [3]. The presence of accurately inspect and grade food products, ensuring that only
hazards in the food or feed supply chain can pose risks to the high-quality items reach consumers. This helps reduce the
safety of food products, potentially leading to adverse impacts chances of contaminated or substandard products being sold.
on human and animal health. It is crucial to monitor and The authors in [6] proposed an automatic mango grading
identify potential food safety hazards throughout the entire technique that categorizes mangoes based on their quality
supply chain to ensure the effective functioning of food safety using key fruit features, including size, shape, color, and
management systems [4]. A non-destructive way to detect surface pixel characteristics. To achieve this, they employed
fruit freshness refers to a method or technique of assessing the the Naive Bayes and Support Vector Regression (SVR)
freshness or ripeness of fruits without causing any damage or algorithms, which enable efficient sorting of mangoes
altering the fruit’s quality. In other words, it is a method that according to their respective quality levels. The same thing in
triggerAction(Response) :
Fig. 6 training and validation loss
match response:
case "fresh banana":
weight["response"] +=getDataWeightSensor() The final results of the model in the table 2.
rotateMotor(ListMotor[0], "left") TABLE 2
case "rotten banana": THE RESULTS MODEL AFTER 50 EPOCHS
weight["response"]+= getDataWeightSensor()
loss accuracy
rotateMotor(ListMotor[0], "right")
Training set 0.22 0.92
case "fresh orange":
Validation set 0.13 0.94
weight["response"]+= getDataWeightSensor()
rotateMotor(ListMotor[1], "left")
We chose a CNN architecture that yielded acceptable
case "rotten orange":
results and did not require an extensive training process. The
weight["response"]+= getDataWeightSensor()
training took approximately 35 minutes in the Kaggle lab. The
rotateMotor(ListMotor[1], "right")
Raspberry Pi is our chosen single-board computer because it
case "fresh apple":
offers built-in Wi-Fi capabilities without needing other
weight["response"]+= getDataWeightSensor() modules. The widespread Linux distribution is the Raspberry
rotateMotor(ListMotor[2], "left") Pi OS, which makes programming tasks straightforward and
case "rotten apple": accessible using Python. We deploy the trained model on
weight["response"]+= getDataWeightSensor() another computer (server) because we tend to use modular
rotateMotor(ListMotor[2], "right") programming software design techniques. By dividing the
functionality into smaller, manageable chunks, we achieve
better results, and the system becomes easier to maintain and
more extensible for future development.