Deep Learning for Classifying Food WasteDeep Learning for Classifying Food Waste Amin Mazloumian...

5
Deep Learning for Classifying Food Waste Amin Mazloumian Institute of Embedded Systems Zurich University of Applied Sciences Zurich, Switzerland [email protected] Matthias Rosenthal Institute of Embedded Systems Zurich University of Applied Sciences Zurich, Switzerland [email protected] Hans Gelke Institute of Embedded Systems Zurich University of Applied Sciences Zurich, Switzerland [email protected] Abstract—One third of food produced in the world for human consumption – approximately 1.3 billion tons – is lost or wasted every year. By classifying food waste of individual consumers and raising awareness of the measures, avoidable food waste can be significantly reduced. In this research, we use deep learning to classify food waste in half a million images captured by cameras installed on top of food waste bins. We specifically designed a deep neural network that classifies food waste for every time food waste is thrown in the waste bins. Our method presents how deep learning networks can be tailored to best learn from available training data. Index Terms—deep learning, neural networks, machine learn- ing, food waste I. I NTRODUCTION A study carried out by the Swedish Institute for Food and Biotechnology, on request from the Food and Agriculture Organization of the United Nations revealed that roughly one third of the food produced in the world for human consumption is wasted or lost, which amounts to about 1.3 billion tons per year [1]. In medium- and high-income countries about 40% of food is wasted at the consumption stage [1], [2]. To reduce waste at consumption stage, quantifying and classifying food waste is crucial [3]–[5]. However, there is a lack of data for individual consumers waste [3], [4]. In recent studies, relying on the paradigm of Internet-of- Things, waste data is monitored in smart garbage systems [6], [7]. In these smart systems, waste data is collected using sensors under waste bins. The collected sensor data is periodically transferred to cloud for analysis and decision making. The sensors only measure waste level and waste weight in the bins. These systems are primarily designed to accomplish timely waste collection. Interestingly however, by only providing food waste weight data to consumers and charging them accordingly, their food waste was reduced by 33% [8]. In this paper, a more informative view to food waste pro- duction behavior at the consumption stage is achieved through classifying food waste in waste bins. The classification task is feasible by processing images captured from food waste in the waste bins. The images are captured by installing cameras on top of the waste bins and monitoring the top surfaces of food waste in the bins. This study focuses on classifying food waste in half a million images captured by cameras installed on top of waste bins. The system design of a smart garbage systems that uses our classification is out of the scope of this study. The automatic classification of food waste in waste bins is technically a difficult computer vision task for the following reasons. a) It is visually hard to differentiate between edible and not-edible food waste. As an example consider distin- guishing between eggs and empty egg shells. b) Same food classes come in a wide variety of textures and colors if cooked or processed. c) Liquid food waste, e.g. soups and stews, and soft food waste, e.g. chopped vegetables and salads, can largely hide and cover visual features of other food classes. In this research, we adopt a deep convoultional neural network approach for classifying food waste in waste bins [9]. Deep convolutional neural networks are supervised machine learning algorithms that are able to perform complicated tasks on images, videos, sound, text, and etc. The deep neural networks are composed of tens of convolutional layers (deep) that train on labeled data (supervised training) to learn target tasks. Labeled training data is composed of thousands of input- output pairs. In the training phase, the networks learn to produce the expected training output (labels) given the training input data. The training is performed by calculating millions of parameter values for feature extraction convolutional filters. In image processing, first layers of trained deep convolutional networks detect simple features, e.g. edges and corners. Based on the low level features extracted in first layers, deeper layers detect higher level features such as contours and shapes. Image recognition convolutional networks classify only one object of interest in every input image [10]–[12]. For instance, a binary classifier trained to distinguish between cats and dogs can recognize whether its input image contains a cat or a dog. On the other hand, object detection convolutional networks detect and locate multiple objects of interest in every image [13]. The networks typically specify the location of every object by defining a bounding box around the object. In our example, there would be a rectangle of type “cat” around every cat and a rectangle of type “dog” around every dog. Image segmentation networks classify every pixel in their input images [14]. In the example, every pixel would be classified as a type cat pixel, a type dog pixel, or a background pixel. Building training data for training object detection networks and segmentation networks are extremely costly. Thousands of images should be annotated by manually defining bounding boxes around every object when building training data for object detection networks. The situation is worse in building arXiv:2002.03786v1 [cs.CV] 6 Feb 2020

Transcript of Deep Learning for Classifying Food WasteDeep Learning for Classifying Food Waste Amin Mazloumian...

Page 1: Deep Learning for Classifying Food WasteDeep Learning for Classifying Food Waste Amin Mazloumian Institute of Embedded Systems Zurich University of Applied Sciences Zurich, Switzerland

Deep Learning for Classifying Food WasteAmin Mazloumian

Institute of Embedded SystemsZurich University of Applied Sciences

Zurich, [email protected]

Matthias RosenthalInstitute of Embedded Systems

Zurich University of Applied SciencesZurich, Switzerland

[email protected]

Hans GelkeInstitute of Embedded Systems

Zurich University of Applied SciencesZurich, [email protected]

Abstract—One third of food produced in the world for humanconsumption – approximately 1.3 billion tons – is lost or wastedevery year. By classifying food waste of individual consumers andraising awareness of the measures, avoidable food waste can besignificantly reduced. In this research, we use deep learning toclassify food waste in half a million images captured by camerasinstalled on top of food waste bins. We specifically designed adeep neural network that classifies food waste for every timefood waste is thrown in the waste bins. Our method presentshow deep learning networks can be tailored to best learn fromavailable training data.

Index Terms—deep learning, neural networks, machine learn-ing, food waste

I. INTRODUCTION

A study carried out by the Swedish Institute for Food andBiotechnology, on request from the Food and AgricultureOrganization of the United Nations revealed that roughly onethird of the food produced in the world for human consumptionis wasted or lost, which amounts to about 1.3 billion tons peryear [1]. In medium- and high-income countries about 40%of food is wasted at the consumption stage [1], [2]. To reducewaste at consumption stage, quantifying and classifying foodwaste is crucial [3]–[5]. However, there is a lack of data forindividual consumers waste [3], [4].

In recent studies, relying on the paradigm of Internet-of-Things, waste data is monitored in smart garbage systems[6], [7]. In these smart systems, waste data is collectedusing sensors under waste bins. The collected sensor datais periodically transferred to cloud for analysis and decisionmaking. The sensors only measure waste level and wasteweight in the bins. These systems are primarily designedto accomplish timely waste collection. Interestingly however,by only providing food waste weight data to consumers andcharging them accordingly, their food waste was reduced by33% [8].

In this paper, a more informative view to food waste pro-duction behavior at the consumption stage is achieved throughclassifying food waste in waste bins. The classification task isfeasible by processing images captured from food waste in thewaste bins. The images are captured by installing cameras ontop of the waste bins and monitoring the top surfaces of foodwaste in the bins. This study focuses on classifying food wastein half a million images captured by cameras installed on topof waste bins. The system design of a smart garbage systemsthat uses our classification is out of the scope of this study.

The automatic classification of food waste in waste bins istechnically a difficult computer vision task for the followingreasons. a) It is visually hard to differentiate between edibleand not-edible food waste. As an example consider distin-guishing between eggs and empty egg shells. b) Same foodclasses come in a wide variety of textures and colors if cookedor processed. c) Liquid food waste, e.g. soups and stews,and soft food waste, e.g. chopped vegetables and salads, canlargely hide and cover visual features of other food classes.

In this research, we adopt a deep convoultional neuralnetwork approach for classifying food waste in waste bins [9].Deep convolutional neural networks are supervised machinelearning algorithms that are able to perform complicated taskson images, videos, sound, text, and etc. The deep neuralnetworks are composed of tens of convolutional layers (deep)that train on labeled data (supervised training) to learn targettasks. Labeled training data is composed of thousands of input-output pairs. In the training phase, the networks learn toproduce the expected training output (labels) given the traininginput data. The training is performed by calculating millionsof parameter values for feature extraction convolutional filters.In image processing, first layers of trained deep convolutionalnetworks detect simple features, e.g. edges and corners. Basedon the low level features extracted in first layers, deeper layersdetect higher level features such as contours and shapes.

Image recognition convolutional networks classify only oneobject of interest in every input image [10]–[12]. For instance,a binary classifier trained to distinguish between cats anddogs can recognize whether its input image contains a cator a dog. On the other hand, object detection convolutionalnetworks detect and locate multiple objects of interest in everyimage [13]. The networks typically specify the location ofevery object by defining a bounding box around the object.In our example, there would be a rectangle of type “cat”around every cat and a rectangle of type “dog” around everydog. Image segmentation networks classify every pixel intheir input images [14]. In the example, every pixel would beclassified as a type cat pixel, a type dog pixel, or a backgroundpixel.

Building training data for training object detection networksand segmentation networks are extremely costly. Thousands ofimages should be annotated by manually defining boundingboxes around every object when building training data forobject detection networks. The situation is worse in building

arX

iv:2

002.

0378

6v1

[cs

.CV

] 6

Feb

202

0

Page 2: Deep Learning for Classifying Food WasteDeep Learning for Classifying Food Waste Amin Mazloumian Institute of Embedded Systems Zurich University of Applied Sciences Zurich, Switzerland

training data for segmentation networks. Every image containstens of thousands of pixels, and every pixel should be markedwith a class label.

What if there are multiple objects in every image, whilelocalization and segmentation training data are not available?In our applications, multiple objects (food waste) are addedsequentially to the monitored scenes (top surfaces of foodwaste in waste bins). In our available data set, for every timewaste is thrown in the bins, only the class label of the wasteis provided.

II. DATA

Our data set consisted of a total of about half a millionimages. The food waste bins were placed on weight sensors.Every time food waste was thrown inside a bin, the weightsensor under the bin detected the event and triggered an imagecapture. The images include the top surfaces of food waste, theinside parts of the waste bins, and very frequently surroundingsof the waste bins. The surroundings were mainly parts of flooraround the bin and very rarely plates and persons who threwthe wastes. Each image received a time stamp together with abin id, and a food class label.

The food classes of the images were manually labeled.There was a total number of 20 food classes. Examples fromfood class labels are: apple, cheese, rice, and beef. The foodclass labels of images specify the last food class that wasthrown in the bins. Food waste bins came in various shapes,sizes, colors, and materials. Some plastic and metal binscaused mirror reflections of food waste on the inside body ofthe bins. Another difficulty arose when garbage plastic bagswere placed inside bins. In addition to the food class labels, foronly 1000 images, binary masks were provided that markedfood waste pixels in the images.

III. METHOD

Our proposed method has two sequential parts: a pre-processing pipeline and a classification convolutional net-work. The preprocessing pipeline prepares the images for thefollowing classification part. The pipleine performs scaling,background subtraction, and region-of-interest cropping. Suchprocesses are typical in image processing applications. How-ever, we specifically designed a deep neural network to wellbenefit from our available training data.

A. Preprocessing Pipeline

We trained a U-Net deep convoultional network for back-ground subtraction [15]. More specifically, we used the 1000mentioned images with binary masks to train a deep convolu-tional network with the U-Net architecture to mark food wastepixels in the captured images. The U-Net architecture relies onthe strong use of data augmentation to use available annotatedsamples very efficiently. It is therefore feasible to train a U-Neton the very few available annotated images for which binarymasks are available.

In our application, we used a U-Net the binary classificationof pixels for one of the two classes: a) food waste and b) not

food waste. By only selecting food waste pixels, the food wasteclassification in our next step would not have to deal with theother parts of the images. Our trained U-Net produces foodwaste binary masks of size 128×128 for an input RGB imageof the same resolution. The network includes about 8.6 milliontrainable parameters and 19 convoultional layers.

The complete preprocessing pipeline is illustrated in Figure1. After extracting food waste pixels using the trained U-Net, a square-shaped bounding box of detected food waste iscalculated and cropped. The bounding box squares are squareswith minimum sizes that include all food waste pixels withinimages. The cropped bounding boxes are finally scaled to adesired fixed size (224×224) for the classification in the nextstep.

B. Deep Neural Network for Classifying Food Waste

The classification labels only specify the food classes of thewaste that were last thrown in the waste bins. As an example,imagine that we throw some salad in an empty waste bin.The added weight of the waste bin would be detected bythe weight sensor under the bin. This would trigger an imagecaptured from the top surface of salad. The image would belater manually annotated as food class salad. Now imaginethat we throw an apple in the same waste bin. Another imagewould be captured and would be annotated as food class apple.The new image would not only contain the apple but also thesalad around the apple. Parts of apple might be covered by thesalad and the surface appearance of salad would change aroundthe apple. As we throw more food waste is the bin, more foodclasses would be present in the captured images. Although thetop surface appearance of previously-existing waste in the binsslightly changes every time, the label specifies only the foodwaste class of the last thrown waste.

To classify the last food waste thrown in the bins, it shouldbe identified what parts of images belong to the last foodwaste thrown in the bins. Therefore, every time the imagesof the waste bin before and after throwing waste should becompared. As an image is captured for every time waste isthrown in the bins, consecutive pairs of images from same binsshould be compared. It is naive to assume that pixel values thathave significantly changed between the consecutive imagesnecessarily belong to the last thrown food waste. Because,once food waste is thrown in the bins, the pixels valuesbelonging to the visible surface of the previously-existing foodwaste potentially changes as well.

We designed a deep convolutional neural network thatclassifies last food waste thrown in the bins based on the twoimages before and after throwing the waste (Figure 2). Thefeatures of the two images are extracted at different abstractionlayers through two separate convolutional paths. While initialconvolutional layers extract low-level features such as edgesand corners, deeper convolutional layers extract highter-levelfeatures such as contours and shapes at higher abstractionlevels. The two covolutional paths are two instances of theconvolutional blocks of a pre-trained VGG16 trained on theImagenet dataset [10]. During the training phase, we set the

Page 3: Deep Learning for Classifying Food WasteDeep Learning for Classifying Food Waste Amin Mazloumian Institute of Embedded Systems Zurich University of Applied Sciences Zurich, Switzerland

RGB input image

Downscale128 x 128 U-Net Upscale

binary mask

Apply binary mask to input image

Cropbounding-box

Scale to224 x 224

RGB preprocessed image

Fig. 1. In a preprocessing pipeline, food waste pixels in captured images are marked using a U-Net. Square-shaped bounding boxes for the marked pixelsare then automatically calculated. Finally, the bounding boxes are cropped and scaled to a desired fixed size for classification.

weights of these two feature extraction paths non-trainable(freeze the two convolutional paths). The VGG16 consistsof 5 convolutional blocks. Each convolutional block containsseveral convolution layers and a pooling layer. The poolinglayers down-sample the representation of the image. The firsttwo convolutional blocks of a VGG16 network contain 2convolutional layers, while the last three convolutional blockscontain 3 convolutional layers.

In our design, we introduce a new neural network layer,delta layer, to emphasize features that appear after throwingthe last food waste. After throwing an apple on salad, forexample, we aim to focus on location-specific features of theapple-and-salad image, which were not present in the saladimage. The delta layer at a certain abstraction layer computersψ (Vafter − λcVbefore) for feature volumes of the after-imageVafter and before-image Vbefore, where λc is a trainbale scalingconstant and ψ denotes the ReLU activation function. TheReLU activation function sets negative values to zero andkeeps positive values unchanged. The intuition behind ourlayer design is to keep feature values that exist (have bigpositive values) in Vafter and do not exist (have smaller positivevalues or negative values) in Vafter.

The feature volumes of the two convolutional paths atdifferent abstraction layers are integrated in a third trainableconvolutional VGG16 path using delta layers. More specif-ically, the resulting feature volumes of delta blocks at eachabstraction level are added to result of the same abstractionlayer of the third convolutional path. Finally, the last featurevolume of the third path is flattened and after three fully-connected neural network layers (dense block), classificationoutput is produced. Our deep model has in total 50.7 millionparameters from which 21.2 million are trainable and 29.5million are not trainable.

IV. RESULTS

In a pre-processing phase, we used a U-Net for backgroundsubtraction (Section III-A). For 1000 images segmentationbinary masks were available. The masks marked food wastepixels in the images. We split the data set into training,validation, and test sets with 700, 200, and 100 images,respectively. The U-Net was trained to a pixel-wise accuracy

of 95.8%. In agreement with the literature, we observed thatwith a relatively small data set our U-Net was well trained.

To classify food waste, we designed a deep convolutionalneural network (Section III-B). The classification data setconsisted of about half a million images. Each image waslabeled only with a food class label. The label defines thefood waste class of the last thrown item in the waste bin.We emphasize that although multiple food waste classes wereavailable in images, no localization and segmentation datawere available. Our trained deep network, classifies food wasteimages into 20 food waste classes with a categorical accuracyof 83.5%.

V. DISCUSSION

In this study, we adopted a deep convoultional neuralnetwork approach for classifying food waste in waste bins.In this study, multiple objects of interest (food wastes) wereadded sequentially to a monitored scene (food waste bin). Asmultiple objects of interest were present in every image, imagerecognition networks were not applicable. Since localizationdata was not provided, we could not use object detectionnetworks. Also, segmentation data was not available. Wetherefore could not use segmentation networks.

In our data set, each image had a single label. The clas-sification labels only specified the food class that was lastthrown in the waste bins. We designed a deep convolutionalneural network that classified last food waste thrown in thebins based on the two images before and after depositingthe waste. The features of the two images were extracted atdifferent abstraction layers through two separate convolutionalpaths. The feature of the two convolutional paths at differentabstraction layers were integrated in a third convolutionalpath using our specifically-designed delta layers. Finally, thelast feature volume of the third path was flattened and afterthree fully-connected neural network layers (dense block),classification output was produced. Our trained deep networkclassified food waste images into 20 food waste classes witha categorical accuracy of 83.5%. Our results show how deeplearning networks can be tailored to best learn from availabletraining data.

Page 4: Deep Learning for Classifying Food WasteDeep Learning for Classifying Food Waste Amin Mazloumian Institute of Embedded Systems Zurich University of Applied Sciences Zurich, Switzerland

Conv. block 1

Conv. block 1

Conv. block 2

Conv. block 2

Conv. block 3

Conv. block 4

Conv. block 5

Conv. block 3

Conv. block 4

Conv. block 5

Convolutional blocks of pre-trained VGG16

Convolutional blocks of pre-trained VGG16

After-image

Before-image

I n+1

I n

Conv. block 1

Conv. block 2

Conv. block 3

Conv. block 4

Conv. block 5

Convolutional blocks of VGG16 (trainable)

Δ layer Δ layer Δ layer Δ layer Δ layer Δ layer

+ ++ + Flat

ten

Denseblock

Con

cate

ntat

e

Fig. 2. Our deep neural network consists of two seperate pre-trained VGG16-based convolutional paths for feature extraction in the images captured beforeand after throwing food waste. The feature volumes of the two convolutional paths at different abstraction layers are integrated in a third trainable convolutionalpath using our proposed delta layers.

Fig. 3. In a pre-processing phase, a trained U-Net network detects for every pixel whether is belongs to food waste. The pixel-wise accuracy of the trainedU-Net is 95.8%. In this figure, food waste pixels are marked with a red tone.

ACKNOWLEDGMENT

This research was funded through an Innosuisse grant bythe Swiss Innovation Agency (2019-2020).

REFERENCES

[1] J. Gustavsson, C. Cederberg, U. Sonesson, R. Van Otterdijk, andA. Meybeck, “Global food losses and food waste,” 2011.

[2] C. Beretta, F. Stoessel, U. Baier, and S. Hellweg, “Quantifying foodlosses and the potential forreduction in switzerland,” Waste management,vol. 33, no. 3, p. 764773, 2013.

[3] C. Reynolds, L. Goucher, T. Quested, S. Bromley, S. Gillick, V. K.Wells, D. Evans, L. Koh, A. C. Kanyama, C. Katzeff, sa Svenfelt,and P. Jackson, “Review: Consumption-stage food waste reductioninterventions what works and how to design better interventions,”Food Policy, vol. 83, pp. 7 – 27, 2019. [Online]. Available:http://www.sciencedirect.com/science/article/pii/S030691921830318X

[4] L. Secondi, L. Principato, and T. Laureti, “Household food waste be-haviour in eu-27 countries: A multilevel analysis,” Food policy, vol. 56,p. 2540, 2015.

[5] J. Aschemann-Witzel, I. De Hooge, P. Amani, T. Bech-Larsen, andM. Oostindjer, “Consumer-related food waste: Causes and potential foraction,” Sustainability, vol. 7, no. 6, pp. 6457–6477, 2015.

[6] V. Bhor, P. Morajkar, M. Gurav, D. Pandya, and A. Deshpande, “Smartgarbage management system,” International Journal of EngineeringResearch & Technology (IJERT), vol. 4, no. 03, p. 2000, 2015.

[7] S. Navghane, M. Killedar, and V. Rohokale, “Iot based smart garbageand waste collection bin,” International Journal of Advanced Research inElectronics and Communication Engineering (IJARECE), vol. 5, no. 5,pp. 1576–1578, 2016.

[8] I. Hong, S. Park, B. Lee, J. Lee, D. Jeong, and S. Park, “Iot-based smartgarbage system for efficient food waste management,” The ScientificWorld Journal, vol. 2014, 2014.

[9] W. Liu, Z. Wang, X. Liu, N. Zeng, Y. Liu, and F. E. Alsaadi, “Asurvey of deep neural network architectures and their applications,”Neurocomputing, vol. 234, pp. 11–26, 2017.

Page 5: Deep Learning for Classifying Food WasteDeep Learning for Classifying Food Waste Amin Mazloumian Institute of Embedded Systems Zurich University of Applied Sciences Zurich, Switzerland

[10] K. Simonyan and A. Zisserman, “Very deep convolutional networks forlarge-scale image recognition,” in International Conference on LearningRepresentations, 2015.

[11] C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan,V. Vanhoucke, and A. Rabinovich, “Going deeper with convolutions,”in Proceedings of the IEEE conference on computer vision and patternrecognition, 2015, pp. 1–9.

[12] K. He, X. Zhang, S. Ren, and J. Sun, “Deep residual learning for imagerecognition,” in Proceedings of the IEEE conference on computer visionand pattern recognition, 2016, pp. 770–778.

[13] B. Zhao, J. Feng, X. Wu, and S. Yan, “A survey on deep learning-based fine-grained object classification and semantic segmentation,”International Journal of Automation and Computing, vol. 14, no. 2, pp.119–135, 2017.

[14] Y. Guo, Y. Liu, T. Georgiou, and M. S. Lew, “A review of semanticsegmentation using deep neural networks,” International journal ofmultimedia information retrieval, vol. 7, no. 2, pp. 87–93, 2018.

[15] O. Ronneberger, P. Fischer, and T. Brox, “U-net: Convolutional networksfor biomedical image segmentation,” in Medical Image Computing andComputer-Assisted Intervention – MICCAI 2015, N. Navab, J. Horneg-ger, W. M. Wells, and A. F. Frangi, Eds. Cham: Springer InternationalPublishing, 2015, pp. 234–241.