Artificial Intelligence for the Classification of Plastic Waste Utilizing TinyML on Low-Cost Embedded Systems

— BCG's implementation of the economy makes Thailand more environmentally conscious. The consolidation policy encourages consumers to eliminate single-use plastics using the 3Rs. This article introduces a solution to reduce plastic waste drastically using artificial intelligence. Utilizing a low-cost Arducam Pico4ML embedded device and TinyML, a plastic waste classifying system prototype is developed for plastic bottle segregation. The grayscale image datasets of PET, HDPE plastic bottles, and unknown objects are adjusted in the image pre-processing state and utilized to create trained models using MobileNetV2 convolutional-based neural network algorithms. Effective feature extraction and model training are performed on the Edge Impulse platform, and the trained model is exported to an embedded device using the optimized compiler. A further RS485 Modbus communication protocol feature enables integration with a programmable logic controller (PLC). The validation results of the trained model indicate a classification performance of 100% accuracy. Based on the average precision results, it is notable that the trained model can recognize the most common waste with an average accuracy of over 90%. The minimum classification rate of the MobileNetV2 quantized model is 249 milliseconds. It is also implemented in low-cost embedded devices for real-time plastic waste classification using fewer processing resources (185.4K ROM and 88K RAM). The findings exhibit sequential contributions that satisfy the criteria for classifying plastic bottles and the machine's integration capacity. These outcomes are anticipated to foster social shifts in behavior and enhance public awareness about plastic waste management.


I. INTRODUCTION
In recent years, the environmental crisis related to plastic waste has attracted considerable attention in many countries worldwide, especially regarding waste from single-use plastics.More than 150 million tons of single-use plastics are produced globally every year.Only 9% of all plastic waste has been recycled.About 12% were incinerated, while the remaining 79% ended up in landfills or the natural world, causing long-term damage to the creature and the environment [1], [2].Public awareness and identifying viable strategies to improve resource and waste management frameworks are critical challenges to achieving a sustainable circular economy in plastic and zero waste [3].
In Fig. 1, Thailand is among the top ten Asian countries with a high value of annual estimated plastic emitted to the ocean per capita, 2019 at 0.33 kilogram, due to the growth of the urban community and people's consumption of plastic products [4].According to Thailand's State of Pollution Report 2019, 28.7 million tons of solid waste were generated (up 3% compared to 2018).Around 50% of the total plastics consumed are non-biodegradable single-use plastics (such as bags and packaging), which are not used in the circular economy system and are often improperly disposed of in open dumps or by open burning [5].
To increase a country's competitiveness and create an economic future with social growth, Thailand is becoming more environmentally conscious by implementing a sustainable development framework, the Bio-Circular-Green Economy [6].The combination policy focuses on the 3R strategy (reduce, reuse, recycle), encouraging both producers and consumers to reduce single-use plastic by greening production, green living, and sustainable consumption [7], [8].Presently, the segregation of different types of plastic waste in Thailand has been done manually by the recycler or seller of plastic waste.As a result, implementation can suffer from increased labor costs and be time-consuming.The concepts of integrated intelligent sensors have been proposed in various studies, but they are mainly disadvantageous to widespread adoption due to the limitation of the cost of the equipment and the system.For example, [9], [10] suggested the architecture of the sorting system using spectroscopic techniques adapted to the management of plastic waste recycling.Artificial intelligence, machine learning, and deep learning have recently attracted much attention in implementing the segregation of urban waste due to their superior performance and profitability.For example, the adaptation of multi-sensor cyber-physical sorting systems (CPSS) in urban waste sorting was presented in [11].The architecture of hyper-spectral, industrial, and short-wave infrared) was applied with the neural network for waste image classifying and sorting using robotic arms.A two-stage localization and classification were used to increase the average accuracy of the waste category detector [12].In [13], A lightweight garbage classification model using ShuffleNet v2 with mixed PMAM mechanism and activation functions was proposed for classifying the garbage into the specified categories.YOLOv2 lightweight network usage and backend server have been designed to work with built-in modules to detect and identify decorative waste automatically.
In [14], [15], an IoT-based smart waste management system integrated with the Lora wireless network was expressed by mentioning the application of an AI algorithm, the TensorFlow deep learning model, for object classification and real-time waste data management.The convolutive neural network (CNN) model has been applied and supplemented by a variety of techniques to improve waste classification and segregation [16], [17].For instance, deep learning combined with the knowledge transfer approach CVGGNet and MobileNetV2 model were proposed in [19,20] and described the technique for improving recycling waste's classification accuracy.MobileNetV3-Large was proposed to generate a garbage classification model for implementation in a network-based application that enhances waste separation efficiency [21].
Balancing the expense of integrating the technology with the accuracy of the classification model is a key obstacle in implementing AI to plastic waste segregation.Fig. 2 displays a comparison of several microcontrollers and AI systems.It signifies that the low-cost microcontroller hardware cannot support the AI algorithm for complicated image classification applications [22].The suggested system's cost must be kept as low as possible to stimulate social behavioral change and create public awareness of the need to support plastic waste management.This article suggests a system for sorting plastic waste based on deep learning.The goal is to develop an applicable solution for Thailand to use a lot less single-use plastic.Using the low-cost Arducam Pico4ML deep learning machine vision platform and the Tiny ML development package, a system prototype is made to sort different types of plastic waste.The MobileNetV2 convolutional base model is performed by the Edge Impulse platform for effective feature extraction, therefore exporting the trained model to an embedded device by the Edge Optimized Neural (EON™) compiler.Further features of RS485 Modbus protocol communication are developed to utilize the integration of the proposed system with other machines or a programmable logic controller (PLC).
This study aims to propose viable strategies to reduce Thailand's consumption of single-use plastics significantly.The significance of our contributions is emphasized in the following manner:  Low-cost deep learning using embedded AI for machine vision and the Arducam Pico4ML with Tiny ML development set, the prototype of the plastic waste classifying system to classify plastic types using MobileNetV2 neural network algorithms. RS485 Modbus communication, the industrial Modbus protocol, is developed to integrate the proposed system with other machines or a programmable logic controller (PLC).This paper is organized as follows: The second section provides details of the proposed materials and methods.The third section presents experimental results, analysis, and discussion.The conclusions are expressed in this last section.

A. Plastic Waste Classifying Prototype Module
The plastic classifying module prototype consists of a cylindrical container 11 centimeters in diameter and 19.5 centimeters in height.Fig. 3 depicts the plastic waste classifying compartments.The Arducam Pico 4ML microcontroller, RP2040 SoC chip dual Cortex M0+ and Arduicam greyscale camera, HiMax HM01B0, QVGA, and 0.96-inch color SPI LCD display LED lighting are used to provide precise information on the vision environment that the chamber has implemented for obtaining, classifying, and validating datasets.Using a deep learning MobileNetV2 convolutional neural network model, the Arduicam camera module will recognize and categorize different types of plastic bottles.
The diagram in Fig. 4 depicts the design of a plastic waste classifying module that allows data visualization and connection to any vending machine via RS485 industrial communication to implement waste classification and transmit the classified signals to the categorization system, points accumulation system, or vending machine payment system.There are three primary methodological compartments in creating the deep learning-based modulus of classifying plastic bottles: data collection, the MobileNetV2 convolutional neural network model, and the RS485 industrial communication protocol.

C. Deep Learning-Based Classification Technique
The deep learning-based classification technique for plastic waste classifying consists of the MobileNetV2 convolutional base model, the TensorFlow Lite framework, and Edge Optimized Neural (EON™).

1) MobileNetV2
Convolutional Base Model: MobileNetV2 is a deep neural network developed by Google in 2018 that has been trained on millions of pictures to categorize things reliably.It is a simple model that is primarily used for picture categorization and other computer vision applications.MobileNetV2 employs depth-wise separable convolutions, a technology that separates the spatial and channel filtering operations [23][24].It employs a linear bottleneck layer with inverted residual blocks to provide faster and more effective training and inference.Furthermore, MobileNetV2 has an improved activation function, which reduces the amount of computing required for inference.As a result, it is refined for mobile and embedded devices [25].The function sequence of the MobileNetV2 convolutional base neural network applied to the proposed plastic waste classifying module is depicted in Fig. 6.Plastic bottle grayscale picture files of 32x32 pixels are utilized as input images for the MobileNetV2 neural network.Setting the alpha parameter to 0.05 in order to reduce the complexity of the classificational model so that it can potentially be employed by picture classification in the M0 core processor.Classify photos into three groups in our classifier: type 1 plastic, PET, type 2 plastic, HDPE, and unknown clarified things that are not included in the PET and HDPE kinds.Before transferring to the next layer, the Dense (32) layer and ReLU activation are used to minimize the size of the feature map.The created neural network has a 0.1 dropout layer.The output of the flattened dropout layer is then used as the input of the fully connected layer to decrease computation and manage overfitting.The three output classes are met by including softmax activation [26][27].
ReLU is the activation method used to enhance the output of the ℎ hidden layer as follows: employing the softmax layer for accurate classification output, which is z is the vector of raw neural network outputs.e has a value of 2.7182.The i th value represents the predicted probability that the test input will belong to class i.The process of constructing a model from a given dataset includes choosing the correct algorithm, adjusting the algorithm's parameters, and assessing the model's performance. Deploying: Create and distribute the software to embedded devices.
3) Edge Optimized Neural (EON™) Compiler: Edge Impulse's optimized compiler is a machine learning compiler that permits developers to execute machine learning models on edge devices that have been optimized [30].It aims to enhance the efficacy of machine learning models on edge devices by reducing model size and complexity without reducing precision.CMakeList is used as a utility for configuring, compiling, and building the Arducam Pico 4ML project to enable a deep-learning model on the embedded device.
 True positive (TP) is the number of samples that were accurately predicted as "positive." False positive (FP) is the number of samples that were incorrectly predicted as "positive." True negative (TN) is the number of samples that were accurately predicted as "negative." False negative (FN) is the number of samples that was wrongly predicted as "negative."

B. Experimental Results
To create the machine learning model, images of plastic bottles were collected and utilized to enable the model to differentiate between type 1 (PET), type 2 (HDPE), and unknown objects.Capture the following data using a variety of plastic bottles and viewing angles:  26 images of type 1 (PET) plastic bottles  26 images of type 2 (HDPE) plastic bottles  26 images of unknown objects are neither type 1 nor type 2 plastic.Images could be acquired from the AI plastic waste classifying module, Arduicam Pico 4ML, and uploaded in the same environment by navigating to the data acquisition procedure depicted in Fig. 9.
The impulse was intended to build a machine-learning model by taking raw data, changing the picture scale, manipulating the image with a pre-processing block, and then classifying new data with a learning block.Pre-processing blocks in Fig. 10 ~11 were used to transform a color picture to monochrome and then to create a feature array from the data.Set the picture width and height to 32 to generate an impulse.Before visualizing, the dimensionality reduction technique was conducted on the dataset during feature generation.In Fig. 12, the 1,024 features (32x32x1) are compressed into three classes and classified based on similarity and estimated on-device performance.
In order to train a neural network.An impulse was utilized to deploy a model that had been constructed, trained, and validated to an embedded This enables the model to operate without an internet connection, using little latency and electricity.Edge Impulse can compile the whole impulse, including the pre-processing stages, neural network weights, and classification code, into a single C++ library that may be embedded and can be included as part of the embedded software.During the deployment phase, the impulse will be exported, and a binary that can be run on the development board will be created.When the C++ building process is finished, the binary file may be downloaded and saved to the computer.
In order to manage the deep learning classification model deployed on embedded devices effectively, multicore processing is an additional technique applied to this research in which multiple processors are used to execute multiple tasks at the same time.The Arduicam Pico 4ML microcontroller chip has dual ARM Cortex-M0+ cores.It features two high-performance cores and two low-power cores.They both have access to the same memory, with which they may interact, allowing for efficient, concurrent processing of various tasks.
The developed multicore program accesses the SPI HiMax HM01B0 camera module via Core 0 and then runs the deeplearning classification model on the Arduicam Pico 4ML.The classified findings are then sent to Core 1, where they are printed on an LCD screen.Once the model was used to run on the AI waste classification device, The experimental results of a machine learning model classifying different types of plastic bottles while the trained model's real-time performance on the Arduicam Pico 4ML embedded device can be found in Fig. 15.

C. Discussion
The screen capture of three classes of detection is shown in Fig. 15.For type 1, type 2, and unknown, the greatest realtime classification performances are 100%, 98%, and 98%, respectively.Table III shows the average classification performances, where the classifying types are performed five times using different types of plastic bottles to get the average accuracy.EON Tuner was used to complete training various deep learning architectures and demonstrate confusion matrix in Fig. 16 in the case of MobileNetV1, Fig. 17

IV. CONCLUSION
This research article proposes a deep learning-based plastic waste classifying system to provide plausible options for dramatically reducing Thailand's use of single-use plastic.A plastic waste classifying system prototype for categorizing plastic types is constructed using low-cost deep learning machine vision Arducam Pico4ML with TinyML.The Edge Impulse platform performs the MobileNetV2 convolutional neural network for effective feature extraction, and the trained model is exported to an embedded device using the optimized compiler.Additional RS485 Modbus communication protocol capabilities are being developed to integrate the proposed system with other machines or a programmed logic controller.(PLC).The validation results of the trained model indicate a classification performance of 100% accuracy.
Based on the average precision results, it is notable that the trained model can recognize the most common waste with an average accuracy of over 90%.The MobileNetV2 quantized model in the Tensor-Flow Lite framework has an optimal detection rate of 249 milliseconds.It is also implemented in low-cost embedded devices with 185.4KROM and 88K RAM for real-time plastic waste segregation using fewer processing resources to encourage behavioral changes and raise public awareness of the need to support plastic waste management.Future work will concentrate on cloud data management and visualization to improve the efficiency of collecting and disposal of plastic waste, ultimately culminating in the successful separation of plastic waste.

Fig. 1 2019
Fig. 1 2019 Annual average of plastic waste deposited into oceans per capita

2 )
TensorFlow Lite: TensorFlow Lite is a Google opensource framework for implementing machine learning/deep learning models in embedded devices.It allows on-device machine learning models to be inferred with low latency, resulting in faster performance and a smaller binary size [28-29].The Edge Impulse platform was used to perform TensorFlow Lite and allowed the optimized image classification tools to execute the plastic waste classification and deep learning model.Fig. 7 depicts the four essential workflow steps for implementing the TensorFlow Lite deep learning model. Raw data collection: Connect with real-time sensors, microphones, or cameras to gather raw data. Feature extraction: A method for reducing data dimensionality by extracting the most significant features from a dataset. Training machine learning/ deep learning algorithms:

Fig. 7
Fig. 7 TensorFlow Lite deep learning model implementation 4) RS485 Industrial Communication Protocol: The Modbus RS-485 protocol is a global industrial protocol connecting multiple manufacturers' equipment to an industrial network for centralized management and monitoring.A serial connection protocol (RS485) is used to enable multi-branch data transmission to other devices or machines in the deep learning-based plastic segregation module.It is a half-duplex protocol that is widely used in industrial automation equipment, including PLCs, sensors, and actuators.The 2wire bus topology layout shown in Fig. 8 connects the plastic waste segregation module to the microcontroller or PLC, with up to 32 nodes linked to the same bus.Arduicam 4ML has an RS485 UART 0 RX TX port for remote connection with a Baud rate of 9600.NONE/EVEN/ODD parity Modbus stop bits: 1 or 2 Addresses 1-247.The query in Table II will request 'Type' from a plastic waste classification module at node 1:

Fig. 8
Fig. 8 Integrated RS485 Modbus industrial communication protocol The algorithms have been configured to recognize patterns.As input data, the images are assigned to one of three classifications.Set some parameters, such as  The number of training cycles to 200. Learning rate of 0.005. Validate set size 22%. Auto-balance dataset: enabled.Data augmentation: enabled.

Fig. 9
Fig. 9 Data collected plastic bottle images

Fig. 13
Fig. 13 Confusion matrix and the trained model performance

Fig. 15
Fig. 15 The trained model's real-time performance on the Arduicam Pico 4ML embedded device in the case of 2D Convolutional Neuron Network, as well as expressed inference time and ROM/RAM usage based on the Arduicam Pico 4ML target device.

Fig. 16
Fig.16 The confusion matrix in case of MobileNetV1 result of the final hidden layer y forecast result Wout weight of the output layer

TABLE I
Table III estimates the classification performance of several architectural models.Table IV compares classification accuracy, latency time, and ROM and RAM utilization from various architectural models of MobileNetV1, MobileNetV2, and 2D Convolutional Neuron Network.

TABLE III AVERAGE
ACCURACY OF EACH CLASS.