Real-time household garbage detection system applied to monitoring camera
By introducing the convolutional block attention module, bidirectional feature pyramid network and CBAM attention mechanism into the domestic garbage detection system, the problem of insufficient detection accuracy and speed in the existing technology is solved, and efficient garbage detection in complex environments is achieved. Suitable for real-time applications.
Patent Information
- Application Number
- CN202410563384.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing domestic waste detection models have room for improvement in detection accuracy and speed under complex backgrounds and multi-target environments, and traditional methods have large parameters and are difficult to guarantee real-time performance.
In the real-time domestic waste detection system under surveillance cameras, a bidirectional feature pyramid network (BiFPN) is introduced by adding a convolutional block attention module to the Backbone layer, and a high-resolution feature layer is added to the Neck layer, combined with the CBAM attention mechanism. and P2 small target detection layer, improving the YOLOv5s model to improve detection accuracy and efficiency.
It achieves the most advanced detection performance on multi-target domestic waste data sets in complex environments, improves detection accuracy and efficiency, reduces model complexity and running memory, and is suitable for real-time applications.
Smart Images

Figure CN118736480A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of environmental monitoring, and in particular relates to a real-time domestic waste detection system applied to a monitoring camera. Background Art
[0002] With the development of economy and the improvement of people's quality of life, a large amount of domestic waste is inevitably generated in daily life. Studies have shown that in the next 30 years, the global waste generation will increase from 2.01 billion tons per year in 2016 to 3.4 billion tons per year. Therefore, in order to reduce environmental pollution and reduce the risk of disease transmission, the importance of domestic waste management is self-evident. Generally speaking, paper, plastic, metal, etc. constitute the garbage components in urban environment and public places. Among them, plastic waste is the most abundant garbage in the world, and its negative impact on the environment and health is greater than other types of garbage. A large number of studies have shown that if domestic waste is not properly managed, it will have serious adverse effects on the local environment, including but not limited to causing bad landscapes, breeding bacteria, and even leading to negative impacts on local tourism and affecting urban economic development.
[0003] Despite awareness of the serious consequences of waste on the environment and health, domestic waste management still faces severe challenges in many cities and public places in developing and developed countries. One of the biggest reasons for the difficulty in promoting domestic waste management is that domestic waste is dispersed over a large area in cities. The labor cost of collecting and processing domestic waste by manual inspection methods is extremely high, the missed detection rate is high, and it is easy to endanger the health of inspection workers. Therefore, designing a lightweight and highly generalizable algorithm that can be embedded in surveillance cameras to monitor the exposure of domestic waste in street communities in real time is crucial to reducing the cost of manual inspections and promoting automated domestic waste management.
[0004] Object detection algorithms have been around long before deep learning. Currently, object detection has become an important research direction in the field of computer vision. Traditional object detection algorithms are mainly based on image processing and machine learning algorithms. Traditional methods use classic image classification algorithms to manually extract features at the geometric, edge, and texture levels, and then classify images through classifiers. However, these methods all have the characteristics of complex processes, low efficiency, low accuracy, and poor generalization ability.
[0005] The superior performance of deep learning has made it widely adopted in the field of computer vision. With the continuous development of deep learning research and the continuous improvement of GPU performance, convolutional neural networks (CNN) have been widely used in the fields of object detection and image classification. The convolution layer in the deep convolutional neural network has good abstract feature extraction capabilities and can represent high-level semantic information of different layers in the form of hierarchical feature representation, without the need to extract image features through other traditional feature extraction algorithms. Existing object detection networks can be divided into two categories: two-stage and single-stage. The former first generates candidate regions and then classifies and regresses them. The latter directly regresses bounding boxes and class labels. Among the two-stage algorithms, the Faster Region-based Convolutional Neural Network (R-CNN) is a representative algorithm that combines the region proposal network and Fast R-CNN. Nowakowski and Faster R-CNN was used for e-waste detection with an average accuracy of over 90%. Faster R-CNN achieved high accuracy but was slow and performed poorly on small objects. To address these issues, single-stage algorithms such as Single Shot Multibox Detector (SSD) and You Only Look Once: Unified Live Object Detection (YOLO) have been developed, which are faster but less accurate than two-stage algorithms. YOLOv5 has become the most popular one due to its excellent overall performance. Liu et al. proposed a household waste detection model based on YOLOv5 to achieve household waste detection in simple backgrounds. Patel et al. compared the garbage detection capabilities of several detectors and found that YOLOv5 outperformed other detectors. Mao et al. designed a high-precision detector based on YOLOv3 on a Taiwan recycled waste dataset. Li et al. proposed a multi-model cascade CNN based on SSD, YOLOv4, and Faster R-CNN to reduce false positive predictions of household waste. However, these detectors are mainly evaluated on datasets with simple backgrounds and single objects with fixed shapes. Domestic waste detection under surveillance cameras faces more challenges due to the presence of small target objects, complex backgrounds, overlapping objects, and the diversity of waste shapes. Existing waste detection models are unable to overcome these challenges, and there is still much room for improvement in detection accuracy and speed. In addition, some of these detectors have a large number of parameters, so real-time performance may not be guaranteed. Summary of the invention
[0006] The present invention provides a real-time domestic waste detection system applied to a surveillance camera, which can effectively solve the above-mentioned problem.
[0007] The present invention is achieved through the following technical solutions:
[0008] The present invention provides a real-time domestic waste detection system applied to a surveillance camera, comprising:
[0009] Backbone layer: Backbone layer is used to obtain input images and extract features of input images; Backbone layer is equipped with a convolutional block attention module, which includes a channel attention submodule and a spatial attention submodule;
[0010] The channel attention submodule is used to receive input features and perform the first processing; the spatial attention submodule is used to receive the features processed by the channel attention submodule and perform the second processing;
[0011] The channel attention submodule includes a first average pooling unit, a first maximum pooling unit, a Shared MLP processing unit, a superposition unit and a first activation unit; the first average pooling unit and the first maximum pooling unit receive input features and process them respectively, and send output values to the Shared MLP processing unit respectively; after receiving the input value, the Shared MLP processing unit processes and obtains two fault feature vectors; the superposition unit obtains the two fault feature vectors, and superimposes the two fault feature vectors to obtain the channel attention feature; the channel attention feature is activated by the first activation unit to obtain the first output feature;
[0012] The spatial attention submodule includes a second average pooling unit, a second maximum pooling unit, a convolution unit, and a second activation unit; the first output feature output by the channel attention submodule is processed by the second average pooling unit and the second maximum pooling unit, and the output value is sent to the convolution unit, and the second activation unit activates the output value of the convolution unit to obtain the second output feature;
[0013] Neck layer: The Neck layer is used to receive the features output by the Backbone layer and further process the features extracted by the Backbone layer;
[0014] Head layer: The Head layer is used to receive the features processed and output by the Neck layer, and obtain the output value based on these features.
[0015] In the above embodiments, "Backbone" is a term in deep learning, which is usually used to describe a part of a convolutional neural network (CNN) or other neural network architecture. This term refers to the main structure or backbone of the network, which is responsible for extracting features of the input data and passing these features to subsequent layers to perform tasks such as classification, detection or segmentation. "Head" is a key component of a neural network model, which is mainly responsible for performing operations for specific tasks and generating the final output of the model. "Neck" refers to a component in a neural network model, usually located between the "backbone" and the "head". The role of the neck is to further process the features extracted by the backbone network and prepare them for the head for a specific task. Shared MLP is a term in point cloud processing networks, emphasizing that the same operation is taken for every point in the point cloud. The average pooling unit is used to perform average pooling processing, and the maximum pooling unit is used to perform maximum pooling processing.
[0016] In some of the embodiments, the Neck layer includes a first processing module, a second processing module, a third processing module and a fourth processing module; the Head layer includes a first detection module, a second detection module, a third detection module and a fourth detection module; the first processing module receives the features output by the Backbone layer for processing, and sends the processed features to the second processing module and the first detection module respectively; the second processing module receives the output features of the first processing module and the Backbone layer P4 layer, processes them, and sends the processed features to the third processing module and the second detection module respectively; the third processing module receives the output features of the second processing module and the Backbone layer P3 layer, processes them, and sends the processed features to the fourth processing module and the third detection module respectively; the fourth processing module receives the output features of the third processing module and the Backbone layer P2 layer, processes them, and sends the processed features to the fourth detection module respectively.
[0017] In some of the embodiments, the first processing module includes a CBS module and a Concat module connected in sequence; the second processing module, the third processing module and the fourth processing module respectively include a Concat module, a CBS module and an Upsamle module connected in sequence.
[0018] In the above embodiment, the CBS module refers to a specific neural network module, which consists of a convolution layer (Conv), a batch normalization layer (BatchNorm) and a SiLU activation function layer.
[0019] In some of the embodiments, the Upsamle module receives the feature map output by the previous processing module and fuses it with the feature map output by the corresponding layer of the Backbone layer.
[0020] In some of the embodiments, the first processing module includes a CBS module and a BIFPN module connected in sequence; the second processing module, the third processing module and the fourth processing module respectively include a BIFPN module, a CBS module and an Upsamle module connected in sequence.
[0021] In some of the embodiments, the weighted feature fusion mechanism of the BIFPN module is as follows:
[0022]
[0023]
[0024] in, Represents the input sample feature information of the i-th layer node, represents the intermediate feature information of the top-down transmission path of the i-th layer, Represents the output feature information of the bottom-up transmission path of the i-th layer, Conv represents the convolution operation, and Resize represents the upsampling or downsampling operation;
[0025] At the same time, a fast normalization method is used in the weighted feature fusion process, and its formula (3) is as follows:
[0026]
[0027] In formula (3), O represents the output value, I i The input value of the node, ω i represents the weight of the input node, and j represents the sum of all input nodes.
[0028] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0029] (1) The real-time domestic waste detection system applied to surveillance cameras provided by the present invention extracts key features and suppresses irrelevant information by adding a convolutional block attention module (CBAM) between the P2 layer and the P3 layer in the Backbone layer.
[0030] (2) This application adds a high-resolution feature layer P2 to the Neck layer, which improves the efficiency and accuracy of detecting tiny garbage targets and can retain shallower details and location information.
[0031] (3) This application introduces a bidirectional feature pyramid network (BiFPN) and improves the FPN and PANet of the Neck layer into a BiFPN structure, which can enhance the model's ability to enhance deep feature fusion.
[0032] (4) A large number of experiments are conducted to evaluate the EcoDetect-YOLO method proposed in this application. The experimental results show that the proposed EcoDetect-YOLO method achieves state-of-the-art detection performance on the proposed multi-target domestic waste dataset in a complex environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0034] Figure 1 A schematic diagram of a YOLOv5 detection structure having: Input, Backbone, Neck and Head in the prior art;
[0035] Figure 2 It is a schematic diagram of the overall network architecture of OLOv5s in the prior art;
[0036] Figure 3 A schematic diagram of the structure of the attention mechanism of the convolutional block attention module provided for some embodiments of the present invention;
[0037] Figure 4 A schematic diagram of the structure of a channel attention submodule in a convolutional block attention module provided in some embodiments of the present invention;
[0038] Figure 5 A schematic diagram of the structure of a spatial attention submodule in a convolutional block attention module provided in some embodiments of the present invention;
[0039] Figure 6 A schematic diagram of the overall network structure of the YOLOv5s model after adding the P2 small target detection layer provided in some embodiments of the present invention;
[0040] Figure 7 (a) The FPN and PANet structures in the YOLOv5s model after adding the P2 small target detection layer; (b) The BiFPN structure in the YOLOv5s model after adding the P2 small target detection layer;
[0041] Figure 8 A schematic diagram of the overall network architecture of EcoDetect-YOLO provided in some embodiments of the present invention;
[0042] Fig. 9 A sample diagram of a multi-target domestic waste exposure image dataset in a complex environment provided by some embodiments of the present invention;
[0043] Fig.10 Distribution of data sets provided for some embodiments of the present invention: the blue bar graph represents the distribution of the number of images of each type of garbage; the gray bar graph represents the distribution of the number of each type of garbage;
[0044] Fig.11 This is a comparison chart of the first part of the detection results of the YOLOv5s model and the EcoDetect-YOLO model;
[0045] Fig.12 This is a comparison chart of the detection results of the second part of the YOLOv5s model and the EcoDetect-YOLO model;
[0046] Fig.13 The robustness test results are shown in Figure 2. (a) represents the original image; (b) represents the image after increasing the brightness; (c) represents the image after reducing the brightness; and (d) represents the image after adding Gaussian noise. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0048] The terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or modules is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other steps or modules that are inherent to these processes, methods, products, or devices.
[0049] YOLOv5 is a single-stage object detection algorithm. The model is computationally efficient and has a simple structure. YOLOv5 uses a deep convolutional neural network (CNN) to detect objects. Its implementation method mainly involves dividing the entire image into a series of grids and predicting the presence of objects in each grid, as well as their location, size, category, and other information. YOLOv5 mainly consists of four parts: Input, Backbone, Neck, and Head. Figure 1 shown.
[0050] Input: includes input for image data augmentation and stitching, setting three initialization anchors, and adaptively scaling the image size.
[0051] Backbone: The backbone network of YOLOv5 consists of CBS, C3 and SPPF. It converts the original input image into a multi-layer feature map and extracts features for subsequent target detection. As a common basic module in convolutional neural networks, the CBS module plays a role in feature extraction of input images and consists of Conv, BatchNorm and SiLU. Conv is the most basic layer in convolutional neural networks, which is mainly used to extract local spatial information from input features. The BatchNorm layer is attached after the convolution layer, which helps to normalize the distribution of feature values in the network. The SiLU activation function is a nonlinear function that introduces nonlinear transformation capabilities to the neural network. The C3 module can significantly improve the computational efficiency of the network while maintaining high accuracy, improving the speed and efficiency of target detection. The SPP module is a spatial pyramid pooling layer that can process input images of different resolutions and achieve adaptive size output, which can increase the receptive field and extract the overall features of the detected target. YOLOv5 uses SPPF instead of SPP, which reduces the amount of calculation by half with the same effect.
[0052] Neck: YOLOv5 uses a combination of feature pyramid network (FPN) and path aggregation network PANet in the neck. Compared with FPN, PANet combines the bottom-up network and top-down network structure to fuse feature maps of different scales. Feature maps of different scales complement each other and enhance the detection effect.
[0053] Head: The head of YOLOv5 uses three detection heads to detect target objects and predict the category and position of the target, corresponding to feature maps of 20x20, 40x40 and 80x80, and outputs targets of three different sizes: large, medium and small.
[0054] The YOLOv5 model is divided into four types of models according to different depths and widths: YOLOv5s, YOLOv5m, YOLOv5l and YOlOv5x. The corresponding depth and width parameters increase successively, and the effect of the model gradually improves, but it is also accompanied by a more complex network structure and a slower detection speed. The domestic waste exposure detection model of the present invention needs to display the waste exposure situation in real time and reduce the running memory as much as possible. Therefore, this application selects YOLOv5s with a relatively simple network structure and a faster detection speed as the benchmark model. The overall network architecture of YOLOv5s is as follows Figure 2 shown.
[0055] Multi-scale feature fusion
[0056] Multi-scale feature fusion aims to improve model performance by integrating features of different scales, which is particularly important in object detection tasks. Traditional neural networks usually use fixed-size filters or pooling operations when processing input images, but this approach may lead to the loss of low-level details or high-level semantic information. Introducing multi-scale feature fusion in the neural network architecture can solve this problem. There are many ways to achieve multi-scale feature fusion. A common method is to connect or superimpose feature maps of different scales, so that the network can use information from multiple scales to make decisions at the same time. Another method is to use a pyramid structure to generate feature maps of different levels and fuse them together, so that the model can capture details and semantic information at different scales. Through multi-scale feature fusion, the model can better adapt to objects or scenes of different scales and sizes, and enhance the robustness of the model and improve its performance in complex scenes. Multi-scale feature fusion is an important issue in feature extraction because features of different scales are important for different tasks. However, the traditional top-down feature pyramid network (FPN) is often unable to make full use of features of different scales due to the limitation of unidirectional information flow, so a more effective method is needed to solve this problem. The YOLOv5 algorithm uses the PANet network for feature fusion. Compared with FPN, PANet adds a bottom-up path aggregation network to achieve bidirectional information flow. However, the PANet network requires more parameters and computing resources, which means that its speed is relatively slow and is not suitable for real-time target detection tasks. Secondly, although PANet uses a bottom-up path aggregation network to improve the efficiency of information flow, if the low-level feature information is not rich enough or some information is lost, this method may lead to a decrease in detection accuracy. As a new network structure for multi-scale feature fusion, BiFPN adds a bottom-up feature path on the basis of FPN. Through bidirectional connections and feature fusion of feature nodes in the feature pyramid network, it solves the problem that traditional unidirectional FPN cannot fully utilize feature information of different scales, and improves fusion accuracy and efficiency. The present invention modifies the original FPN and PANet structures of the YOLOv5 neck layer into a BiFPN network, thereby achieving more efficient multi-scale feature fusion.
[0057] Attention Mechanism
[0058] The attention mechanism is used to enhance the attention of the neural network to different parts of the input data. It simulates the attention mechanism in the human visual system and allows the network to selectively focus on information related to the current task. In traditional neural networks, each input is treated equally and all features are calculated at the same time. However, in many tasks, only a small part of the input may be crucial to the output. If each input is treated equally, it may lead to low algorithm efficiency and poor generalization ability. The introduction of the attention mechanism can better solve this problem. The attention mechanism has achieved remarkable success in various deep learning tasks. For example, in image classification tasks, the attention mechanism can help the network automatically focus on the classification-related areas in the image, thereby improving accuracy. In the text summary task, the attention mechanism can enable the model to better focus on the most important content in the original text when generating a summary, thereby generating a more accurate and concise summary. In order to enhance the focus on key areas, suppress unimportant background information, and improve detection accuracy, the present invention introduces a CBAM attention module. CBAM considers both spatial dimensions and channel dimensions, calculates their attention weight coefficients through the spatial attention submodule and the channel attention submodule, and multiplies them with the input feature map to adaptively refine the input features. Adding the CBAM attention module between the feature extraction backbone network and the inference layer enables the YOLOv5s algorithm to find areas with high feature map weights and pay more attention to important features during inference.
[0059] CBAM Attention Mechanism
[0060] In the field of deep learning, model training and prediction usually need to accept and process a large amount of high-dimensional data, but the importance of each feature is different. In this case, an attention mechanism (AM) is needed to assign higher weights to important features so that the deep learning model can pay more attention to these features.
[0061] CBAM combines two unique submodules, namely the channel attention submodule and the spatial attention submodule, to improve the model's understanding and processing capabilities of input features. Its structure is as follows: Figure 3 As shown:
[0062] First, the channel attention submodule focuses on extracting the most critical attributes from the input fault features. It extracts two sets of significant features by performing average pooling and maximum pooling operations on the input features. Then, these two sets of features are further processed through a series of perception layers to produce two unique fault feature vectors. These vectors are synthesized into the final fault channel attention features through element-wise addition and subsequent activation processes to emphasize the importance of specific channels. The processing flow of the channel attention submodule is as follows: Figure 4 As shown;
[0063] Next, the spatial attention submodule shifts the focus to how to optimize features from the spatial dimension. It receives the output of the channel attention submodule as input and performs average pooling and maximum pooling operations to capture the spatial distribution of different fault features. By concatenating the two pooling results and passing additional convolution and activation steps, the module generates a weighted spatial feature map. This feature map is multiplied with the original input features to emphasize the most important spatial regions in the input. The processing flow of the spatial attention submodule is as follows Figure 5 As shown;
[0064] In summary, CBAM effectively enhances the model's attention to important features in both channel and spatial dimensions through these two complementary modules, thereby improving the richness and accuracy of important feature representation.
[0065] P2 small target detection layer
[0066] Small target detection relies on deep semantic information and underlying detail information, and simple feature fusion methods are difficult to significantly improve its detection accuracy. When detecting small targets, since small target samples occupy a small size of the image and multiple downsampling is required in the Backbone layer of the YOLOv5s model, the feature information of the obtained samples is reduced. After passing through the Neck layer, the model is difficult to learn the feature information of small target samples. In the three detectors of the Head layer, smaller targets cannot be detected, resulting in the omission of small target samples in the detection results. Therefore, in order to make the model better adapt to the detection of small targets, a small target detector is added to the Head, and the deep feature map is fused with the shallow feature map for detection, thereby effectively improving the accuracy of the model in detecting small target samples.
[0067] The original YOLOv5s model has three detectors in its network structure. If the input image size is 640*640, after multiple downsampling of the Backbone layer and feature fusion of the Neck layer, detection feature maps of 20x20, 40x40 and 80x80 can be obtained respectively, which can detect targets with sizes larger than 32x32, 16x16 and 8x8. If there are samples with a size smaller than 8x8 in the input image, it will be difficult for the YOLOv5s model to detect these samples, resulting in missed detections.
[0068] In order to solve the above problems, the P2 small target detection layer is introduced into the YOLOv5s model. The main operation process is as follows: After adding the P2 small target detection layer, the network structure is added at the 16th layer of the Neck in the YOLOv5s model, where Upsamle is added at the 19th layer. The feature map obtained by its operation is fused with the feature map of the 2nd layer of the Backbone, and finally detected by the detector of the Head layer to obtain detection feature maps of 20x20, 40x40, 80x80 and 160x160. Among them, the newly added 160x160 detection feature map can detect samples with a size greater than 4x4. Since the feature map of the second layer has more feature information of small target samples, the model can learn more sufficient sample information in the subsequent fusion detection process, thereby improving the adaptability of the model for small target sample detection. The overall network structure of the YOLOv5s model after adding the P2 small target detection layer is as follows Figure 6 shown.
[0069] BiFPN Module
[0070] The FPN and PANet structures in the Neck layer of the YOLOv5s model perform multi-scale fusion of the features of the input image, where the FPN structure transmits the image semantic feature information from top to bottom, and the PANet structure transmits the image position feature information from bottom to top. Since the input image contains sample feature information of different resolutions, the features are simply summarized during fusion, and their contribution to the output features is unreasonable.
[0071] In order to better solve the above problems and improve the accuracy and efficiency of the model, the BiFPN module is introduced. This module uses a weighted feature fusion mechanism, as shown in formulas (1) and (2), so that the network structure of the model can learn the importance of feature information of different resolutions of the input image. At the same time, a fast normalization method is used in the process, and its formula (3) is shown below.
[0072]
[0073]
[0074] In formulas (1) and (2), Represents the input sample feature information of the i-th layer node, represents the intermediate feature information of the top-down transmission path of the i-th layer, It represents the output feature information of the bottom-up transmission path of the i-th layer, Conv represents the convolution operation, and Resize represents the upsampling or downsampling operation.
[0075]
[0076] In formula (3), O represents the output value, I i The input value of the node, ω i represents the weight of the input node, and j represents the sum of all input nodes. In order to satisfy the weight ω of each input node i ≥0 is established, and the RELU activation function is used for each ω i Perform the calculation operation. Set ε = 0.0001 to avoid numerical instability. This method makes each ω i The value range is scaled to [0, 1]. At the same time, since the Softmax method is not used, its training speed and efficiency are more efficient. BiFPN structure Figure 7 shown.
[0077] Since nodes with only one input edge do not perform feature fusion and contribute little to the feature network that aims to fuse different features, these nodes are removed and the bidirectional network structure is simplified. For input nodes and output nodes at the same level, an additional edge is added between them to fuse higher-level features at low cost and efficiently during multiple iterative superposition processes.
[0078] EcoDetect-YOLO object detection model
[0079] Based on the advantages of the YOLOv5s model in small target detection, this application proposes an improved EcoDetect-YOLO model for detecting garbage exposure on conventional landfills and residential communities. The main improvements of this model include: introducing the CBAM attention mechanism, the P2 small target detection head, and the BiFPN structure.
[0080] First, the CBAM attention mechanism is added between the P2 and P3 layers in the Backbone layer to enhance the useful features of the input feature map and reduce the impact of irrelevant features, focusing on the importance of each pixel in the feature map and assigning higher weights accordingly. Then, a P2 small target detection head is added to the Neck layer, so that when detecting tiny garbage targets, it can be quickly and effectively identified, improving the small target detection effect of the model. Finally, the FPN and PANet of the Neck layer are improved to the BiFPN structure, which helps the model determine useful weights for the comprehensive fusion of high-level and low-level features. Figure 8 This is the overall network architecture of EcoDetect-YOLO.
[0081] Dataset Introduction
[0082] Due to the problems of simple background, single type and small scale of existing garbage datasets, this application proposes a multi-target household garbage exposure image dataset based on urban surveillance cameras. Fig. 9shown.
[0083] Use the Fluid Annotation tool to manually annotate the images, including the target type, center point, width, and height, and obtain the Number of images and Number of values corresponding to each category. Fig.10 As shown in the figure, there are nine types of detection targets, including Paper trash, Plastic trash, Snakeskin bag, Packed trash, Stone waste, Sand waste, Carton, Foam trash and Metal waste. During the experiment, the data set was randomly divided into training set and test set in a ratio of 8:2 for training and testing of the YOLOv5s model.
[0084] Model Evaluation Metrics
[0085] Precision (P) refers to the ratio of the number of correctly classified positive samples to the number of samples determined as positive samples by the classifier.
[0086]
[0087] Recall or recall rate (Recall, denoted as R) refers to the ratio of the number of correctly classified positive samples to the number of true positive samples.
[0088]
[0089] In formulas (4) and (5), TP represents the number of samples predicted as positive examples when the sample value is positive. FP represents the number of samples predicted as negative examples when the sample value is positive. FN represents the number of samples incorrectly predicted as positive examples when the sample value is negative.
[0090] mAP is the formula (6), which is the area approximately enclosed by the Precision-Recall curve. 0.5 (%) is the average precision calculated when the IOU threshold is 0.5, and mAP 0.5:0.95 (%) is a more stringent comprehensive evaluation indicator, which is the average accuracy calculated when the IOU threshold is 0.5-0.95.
[0091]
[0092]
[0093] FLOPs is usually used to measure the complexity of a model. The smaller the value, the faster the model runs. The corresponding formulas are shown in formulas (8) and (9).
[0094] FLOPs(Conv)=(2×C in ×K 2 -1)×W out ×H out ×C out #(8)
[0095] FLOPs(Conv)=(2×C in -1)×C out #(9)
[0096] In formulas (8) and (9), C in and C out Represents input channel and output channel respectively, K, H out and W out They are respectively represented as the convolution kernel size, the height and width of the output feature map.
[0097] Experimental environment and training parameters
[0098] The versions of PyTorch and Torchvision used in the YOLOv5s model experiment are 2.0.1 and 0.15.2 respectively, and training and testing are performed in the Windows 10 environment. The hardware configuration used in the experiment is: Intel(R) Xeon(R) Silver 4210CPU@2.20GHz, 32GB; NVIDIA GeForce RTX 3090 40GB. The program is run using the Pycharm compiler in the CUDA11.8, Python3.8.16 environment.
[0099] During the model training process, the number of epochs was 300 in the garbage dataset, the pixel size of the input image was 640x640, and the SGD optimizer based on gradient operation was used to iteratively adjust the weight value of the model. The Initial learning rate was set to 0.01, the Weight decay was set to 0.005, and the Batch size was set to 12. Table 1 shows the core parameters of the YOLOv5s model training process.
[0100] Table 1 YOLOv5s model training parameters
[0101]
[0102] Object Detection Model Evaluation
[0103] Table 2 Comparison of the results of the YOLOv5s model and the EcoDetect-YOLO model
[0104]
[0105]
[0106] As shown in Table 2, the precision recall rate of the EcoDetect-YOLO model proposed in this application increased by 3.6%, and the mAP 0.5 Increased by 4.5%, mAP 0.5:0.95 An increase of 0.7%.
[0107] Fig.11 Left and Fig.12 The content on the left is the test results of the EcoDetect-YOLO model proposed in this application. Fig.11 Left and Fig.12 The content on the right is the test results of the baseline YOLOv5s model. The blue boxes in the figure indicate that the model missed the target sample, and the green boxes indicate that the model incorrectly detected the target sample.
[0108] Depend on Fig.11 and Fig.12 The results show that when the target to be detected is covered or the sample features in the image are incomplete, the baseline YOLOv5s model is prone to missed detections, such as Fig.11 (2, 4, 8), among which Pack trash, Snakeskinbag and Sand waste are not provided completely because some samples are at the edge of the picture; Fig.11 The Plastictrash in (6) is hidden by some bushes. Fig.12 The metal waste in (10) is partially obscured by a thick black wire. At the same time, if there are small targets in the image, the baseline YOLOv5s model will also easily miss detections, such as Fig.12 (12, 14, 16), the image has a wide field of view and contains tiny Paper Trash, Foam Trash and Carton objects. The EcoDetect-YOLO model proposed in this application can adapt to these situations. At the same time, the objects detected by the EcoDetect-YOLO model have higher confidence. The baseline YOLOv5s model treats the white parking line as Paper Trash. Fig.12 (18) Through the comparison of the results, the improved EcoDetect-YOLO model combined with the three improvements effectively adapts to the situations of different sample sizes and feature changes, and improves the accuracy of target detection and the missed detection rate.
[0109] Analysis of the effect of attention mechanism
[0110] In order to verify the advantages of the CBAM attention mechanism, this application adds CA, SE and ECA attention mechanisms to the benchmark YOLOv5s model for experimental comparison. Among them, the CA attention mechanism is position-sensitive and direction-aware. By fusing the position and direction information of the features, it can improve the accuracy of the model in determining the target position. The SE attention mechanism assigns corresponding weights according to the importance of each channel, which is used to solve the loss problem caused by different weights mapped to features for each channel during the network extraction process of the YOLOv5s model. The ECA model is a lightweight channel attention mechanism module that removes the fully connected layer and replaces it with a 1x1 convolutional layer to reduce the parameters of the model. This model avoids the side effects brought about by the dimensionality reduction process and effectively captures the cross-channel interactions, thereby better extracting the essential features of the target.
[0111] Table 3 Comparison of attention mechanism results
[0112]
[0113] As shown in Table 3, the mAP of YOLOv5s+CBAM 0.5 The effect is the best, which is 56.2%. Compared with YOLOv5s+CA, YOLOv5s+SE and YOLOv5s+ECA, the mAP is increased by 1.9%, 2.4% and 3.2% respectively. 0.5:0.95 The effect is also the best, at 30.4%, which is an increase of 0.5%, 0.8% and 0.6% respectively. At the same time, it can be found that the Weights and FLOPs of the YOLOv5s model with the attention model added have not changed much. Through comprehensive comparison of experiments, it is found that the CBAM attention mechanism can keep the YOLOv5s model lightweight and improve the accuracy of the model.
[0114] Analysis of ablation experiment results
[0115] Table 4 Ablation experiment results
[0116]
[0117] From the ablation experiment results in Table 4, we can find that the CBAM attention module improves precision, recall, and mAP. 0.5 and mAP 0.5:0.95 The P2 small object detection improves recall rate and mAP by 3.5%, 0.4%, 2.8% and 0.3% respectively. 0.5 and mAP 0.5:0.95 The BiFPN module improves accuracy, mAP by 4.9%, 2.0%, and 0.1%, respectively, while reducing accuracy by 0.8%. 0.5 , respectively, increased by 0.8% and 0.7%, while mAP 0.5:0.95Compared with the baseline YOLOv5s, the improved EcoDetect-YOLO model has a lower recall rate and mAP 0.5 and mAP 0.5:0.95 The accuracy of the model is improved by 3.6%, 4.5% and 0.7% respectively, but the accuracy is reduced by 0.9%. It is worth noting that there is a certain balance between the accuracy and recall rate of the model. When one indicator is improved, the other indicator is reduced. Overall, through the combination of the three modules, the EcoDetect-YOLO model has been significantly improved in terms of indicators.
[0118] Comparative analysis of experimental results of different models
[0119] We selected the one-stage target detection models SSD, YOLOv3, YOLOv3-tiny, YOLOv8s, and two models, YOLOv5m and YOLOv5l, obtained by changing different widths and depths in the YOLOv5 model. We trained the model experiments with the same experimental parameters, and the results are shown in Table 5.
[0120] Table 5 Experimental results of different models
[0121]
[0122]
[0123] As shown in Table 5, compared with the one-stage target detection model SSD, the EcoDetect-YOLO model proposed in this application can maintain a lower model scale and parameters while achieving mAP 0.5 The baseline YOLOv5s model has a similar network structure to the YOLOv3 model, but due to its smaller model size and parameters, its overall effect is not as good as the YOLOv3 model. The mAP of the EcoDetect-YOLO model is 0.5 Compared with the YOLOv3 model, the model size and parameters are lower, and the detection speed is faster. For YOLOv3-tiny, it is a YOLOv3 model with the same network depth and width and a simplified network structure. Compared with the EcoDetect-YOLO model, although its model size and parameters are similar and the detection speed is faster, the mAP 0.5 YOLOv5m and YOLOv5l are models with different network widths and depths in the YOLOv5 model. By increasing the model scale and parameters, compared with the baseline YOLOv5s model, the effects of both models are significantly improved, among which YOLOv5l has better effect. Compared with the EcoDetect-YOLO model, its mAP 0.5The YOLOv8 model is a more advanced model in the YOLO series. This application selects the YOLOv8s and YOLOv8l models for experiments. It can be found that compared with the EcoDetect-YOLO model, the detection speed of YOLOv8s is slightly faster, and the corresponding mAP is 0.5 Relatively low, and the model size and parameters are higher; YOLOv8l's mAP 0.5 The detection speed is lower than that of the EcoDetect-YOLO model, and the model scale and parameters are much higher.
[0124] Through the results analysis, the mAP of the EcoDetect-YOLO model proposed in this application 0.5 It is the highest among all models, which is 3.5%, 0.4%, 11.6%, 4.5%, 2.7%, 1.4% and 2.5% higher than SSD, YOLOv3, YOLOv3-tiny, YOLOv5s, YOLOv5m, YOLOv5l and YOLOv8s respectively, and the FPS reaches 36.56 frames / second. The scale, parameters and FLOPs of the model are similar to those of the baseline YOLOv5s model, which can meet the requirements of accurate and real-time detection of garbage exposure on the roads of conventional landfills and residential communities in real situations.
[0125] Robustness test
[0126] In real scenes, the camera shooting process is often affected by objective environmental factors, such as overexposure, dimming of scene light, and unclear images. In order to evaluate the ability of the EcoDetect-YOLO model proposed in this application to adapt to these scenes, this application performs three processing methods on the images in the test set: increasing brightness, reducing brightness, and adding Gaussian noise. The final experimental results are as follows: Fig.12 shown.
[0127] Depend on Fig.12 As shown in the figure, when increasing brightness, decreasing brightness and adding Gaussian noise, Snakeskin bag, Paper trash, Stone waste, Packed trash, Plastic trash and Metal trash can all be accurately detected, but some of them are missed, such as (1) Fig.12 As shown in the first to third rows, the original characteristic colors of Paper trash, Plastic trash, and Snakeskin bag are white. When the image is dim or blurred, the overall color of the sample is darker; (2) Fig.12As shown in the third and fourth rows, Packed trash and Stone waste are mainly piled up in clusters. When the image becomes blurred, their features are more complex, making it difficult for the model to collect sample features during the detection process, resulting in missed detections. Sand waste can be detected when the brightness is reduced because its features are dark and piled up in clusters. However, it will be missed when the brightness is increased and the image is blurred. Fig.12 As shown in the fourth row. When Carton and Foam trash are tiny in the image, they may be missed due to image blur, as shown in Fig.12 As shown in the fourth and fifth rows. In the case of reduced brightness and blur, false detections may occur, such as Fig.12 As shown in the third row, the model detects Paper trash as Plastic trash. Although the model is prone to missed detection when the image is blurred, the model is generally able to demonstrate its concurrent detection capabilities. The final mAP of the experiment 0.5 The result is still above 50%. Overall, the improved EcoDetect-YOLO model maintains good robustness when increasing brightness, reducing brightness, and adding Gaussian noise.
[0128] Since the garbage captured by the camera has problems such as small sample size, complex environmental background, and multi-scale, it is challenging to detect garbage exposure on the road in conventional landfills and residential communities in real time. Therefore, this application proposes an improved target detection model EcoDetect-YOLO based on the YOLOv5s model. Through the analysis of experimental results, it can be seen that the mAP of the baseline YOLOv5s model is 0.5 and mAP 0.5:0.95 The improvements to the YOLOv5s model are as follows: (1) The CBAM attention mechanism can enhance the useful features of the input feature map and reduce the impact of irrelevant features, effectively enhancing the model's attention to important features in both channel and spatial dimensions. Compared with the baseline YOLOv5s model, its mAP 0.5 and mAP 0.5:0.95 The results are improved by 2.8% and 0.3% respectively, while maintaining the lightweight advantage of the YOLOv5s model. (2) Since there are many small targets in the sample, by adding the P2 small target detection head, the small targets can be quickly and effectively identified, which improves the small target detection effect of the model. Compared with the baseline YOLOv5s model, its mAP 0.5 and mAP 0.5:0.95The improvements were 2.0% and 0.1% respectively. (3) BiFPN is an improvement based on the FPN and PANet structures, which can quickly fuse multi-scale features. For input nodes and output nodes at the same level, an extra edge is added between them to fuse higher-level features at low cost and high efficiency during multiple iterative superposition processes, and it can avoid the fusion of feature noise and quickly locate the position of small target samples. Compared with the baseline YOLOv5s model, its mAP 0.5 By combining the CBAM attention mechanism, P2 small target detection layer and BiFPN, the EcoDetect-YOLO model proposed in this application has a mAP of 0.7%. 0.5 and mAP 0.5:0.95 They reach 57.9% and 30.4% respectively, which are 4.5% and 0.3% higher than the YOLOv5s-based model. The model size is 15.7MB, and the FPS detection speed reaches 36.56 frames per second. At the same time, the EcoDetect-YOLO model still maintains relatively good performance and robustness in extreme cases.
[0129] The EcoDetect-YOLO model proposed in this application has high detection accuracy, fast detection speed and small model size, and is suitable for deployment in mobile devices to conduct real-time detection and control of garbage exposure on the road surfaces of conventional landfills and residential communities.
[0130] The above description is only a preferred embodiment of the present invention and does not constitute any limitation to the present invention. Any simple modification or equivalent changes made to the above embodiments based on the technical essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. A real-time domestic waste detection system applied to a surveillance camera, characterized in that: include: Backbone layer, which is used to obtain an input image and extract features of the input image; The Backbone layer is provided with a convolutional block attention module, which includes a channel attention submodule and a spatial attention submodule; The channel attention submodule is used to receive input features and perform a first processing; the spatial attention submodule is used to receive features processed by the channel attention submodule and perform a second processing; The channel attention submodule includes a first average pooling unit, a first maximum pooling unit, a Shared MLP processing unit, a superposition unit, and a first activation unit; the first average pooling unit and the first maximum pooling unit respectively receive input features and process them, and respectively send output values to the Shared MLP processing unit; after receiving the input value, the Shared MLP processing unit processes it to obtain two fault feature vectors; the superposition unit obtains the two fault feature vectors and superimposes the two fault feature vectors to obtain a channel attention feature; the channel attention feature is activated by the first activation unit to obtain a first output feature; The spatial attention submodule includes a second average pooling unit, a second maximum pooling unit, a convolution unit, and a second activation unit; the first output feature output by the channel attention submodule is processed by the second average pooling unit and the second maximum pooling unit, and the output value is sent to the convolution unit, and the second activation unit activates the output value of the convolution unit to obtain a second output feature; Neck layer, the Neck layer is used to receive the features output by the Backbone layer and further process the features extracted by the Backbone layer; The Head layer is used to receive the features output by the Neck layer and obtain output values based on these features.
2. The real-time domestic waste detection system for use under a surveillance camera according to claim 1 is characterized in that: The Neck layer includes a first processing module, a second processing module, a third processing module and a fourth processing module; the Head layer includes a first detection module, a second detection module, a third detection module and a fourth detection module; the first processing module receives the features output by the Backbone layer for processing, and sends the processed features to the second processing module and the first detection module respectively; the second processing module receives the output features of the first processing module and the Backbone layer P4 layer, processes them, and sends the processed features to the third processing module and the second detection module respectively; the third processing module receives the output features of the second processing module and the Backbone layer P3 layer, processes them, and sends the processed features to the fourth processing module and the third detection module respectively; the fourth processing module receives the output features of the third processing module and the Backbone layer P2 layer, processes them, and sends the processed features to the fourth detection module respectively.
3. The real-time domestic waste detection system for use under a surveillance camera according to claim 2 is characterized in that: The first processing module includes a CBS module and a Concat module connected in sequence; the second processing module, the third processing module and the fourth processing module respectively include a Concat module, a CBS module and an Upsamle module connected in sequence.
4. The real-time domestic waste detection system for use with a surveillance camera according to claim 3 is characterized in that: The Upsamle module receives the feature map output by the previous processing module and fuses it with the feature map output by the corresponding layer of the Backbone layer.
5. The real-time domestic waste detection system for use with a surveillance camera according to claim 2, characterized in that: The first processing module includes a CBS module and a BIFPN module connected in sequence; the second processing module, the third processing module and the fourth processing module respectively include a BIFPN module, a CBS module and an Upsamle module connected in sequence.
6. The real-time domestic waste detection system for use with a surveillance camera according to claim 5, characterized in that: The weighted feature fusion mechanism of the BIFPN module is as follows: in, Represents the input sample feature information of the i-th layer node, represents the intermediate feature information of the top-down transmission path of the i-th layer, Represents the output feature information of the bottom-up transmission path of the i-th layer, Conv represents the convolution operation, and Resize represents the upsampling or downsampling operation; At the same time, a fast normalization method is used in the weighted feature fusion process, and its formula (3) is as follows: In formula (3), O represents the output value, I i The input value of the node, ω i represents the weight of the input node, and j represents the sum of all input nodes.
Citation Information
Patent Citations
ESB-YOLO model cultured fish school detection method based on channel non-dimensionality reduction attention mechanism and improved YOLOv5
CN115690675A
Method for detecting dense ship targets in any direction based on attention enhancement
CN116168240A
Port container damage detection method and system based on improved YOLOv5
CN116645586A
Multi-scale attention-fused traffic helmet small target detection system and method
CN116665156A
Unmanned aerial vehicle small target detection method based on improved YOLOv5
CN117853955A
Cited By
Target detection method based on EcoDetect-YOLOv2
CN120070873A
