Garbage sorting method based on integrated parallel attention module
By introducing an integrated parallel attention module into the garbage classification network and combining the channel and spatial attention mechanisms, the problem of key feature interference in garbage images is solved, the accuracy and efficiency of garbage classification are improved, and a more efficient automated garbage classification is achieved. Pick.
Patent Information
- Application Number
- CN202410623760.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-05-20
AI Technical Summary
Existing deep learning algorithms fail to fully consider the interference of the key features of garbage on the classification algorithm in garbage image classification, resulting in an increase in the difficulty of identification. Traditional methods are difficult to meet the needs of efficient and accurate garbage sorting.
The integrated parallel attention module is used to combine the channel attention module and the spatial attention module to improve the performance of the convolutional neural network in image recognition tasks, especially in complex scenes, by connecting the channel and spatial attention modules in parallel to capture images Different feature dimensions enhance the network's attention to key features.
It improves the classification accuracy and robustness of the garbage classification network, can more effectively identify and classify recyclable garbage, reduces labor costs and error rates, and improves the efficiency and recycling rate of garbage processing.
Smart Images

Figure CN118629020A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image recognition technology, and in particular to a garbage sorting method based on an integrated parallel attention module. Background Art
[0002] In recent years, with the continuous development of economy and society, and the continuous improvement of people's material consumption level, the amount of garbage generated is also increasing. This trend not only represents a waste of resources, but also poses a potential threat to the environment. Therefore, garbage disposal has become an important factor restricting the sustainable and healthy development of the economy and society. Traditional garbage sorting methods require a lot of manpower and time costs, and it is difficult to meet large-scale classification needs. Therefore, how to efficiently sort and recycle garbage has become one of the problems that people urgently need to solve.
[0003] Emerging computer vision technology, especially the application of deep learning algorithms, has brought new solutions to traditional garbage disposal methods. By using high-resolution cameras and advanced image recognition systems, computer vision technology can automatically identify and classify garbage, greatly improving sorting efficiency and accuracy. Garbage image classification technology based on deep learning, especially the application of convolutional neural networks, has become the core of automated garbage sorting. These algorithms can identify different types of garbage, such as plastic, metal, glass, and paper, by learning from a large number of garbage image data sets. This automated sorting system not only improves sorting speed and processing capacity, but also reduces labor costs and error rates. More importantly, it helps promote the sustainable development of the garbage disposal industry and reduce pressure on the environment by increasing recycling rates and reducing landfills. However, the key features in garbage images may be concentrated in local areas, which increases the difficulty of garbage sorting algorithms.
[0004] The invention patent with the authorization announcement number CN117611915A and the invention name “Intelligent garbage classification method and system based on ARM architecture” uses AlexNet neural network for efficient garbage image recognition, and realizes incremental learning of categories through online knowledge distillation technology to achieve garbage sorting; the invention patent with the authorization announcement number CN112926670A and the invention name “A garbage classification system and method based on transfer learning” uses transfer learning technology to construct a convolutional neural network and use simulated annealing algorithm for parameter optimization, and then trains the network through a garbage image data set to achieve automatic recognition and classification of garbage; the invention patent with the authorization announcement number CN112487938A and the invention name “A method for garbage classification using deep learning algorithm” uses a lightweight convolutional neural network SqueezeNet to extract features from garbage images, and uses the Adam algorithm to train the neural network to achieve automatic recognition and classification of garbage. The above methods realize automatic garbage sorting through deep learning algorithms. However, they fail to fully consider the interference of the key features of garbage on the classification algorithm. Summary of the invention
[0005] The core goal of the present invention is to realize automatic garbage sorting, aiming to accurately identify recyclable garbage through advanced deep learning algorithms, thereby improving the efficiency and accuracy of garbage disposal. In order to achieve this goal, the present invention focuses on developing intelligent algorithms that can focus on the key features of garbage, and on this basis, improves the classification performance and efficiency of convolutional neural networks. The method of the present invention builds a recyclable garbage sorting network based on an integrated parallel attention module, thereby realizing automatic classification of recyclable garbage images. The integrated parallel attention module is an attention mechanism that aims to improve the performance of convolutional neural networks in image recognition tasks, especially in complex scenarios such as garbage sorting. In these scenarios, the background diversity and category imbalance problems of the image may interfere with the model's recognition of the garbage itself. To solve these problems, the integrated parallel attention module integrates two types of attention modules: channel attention modules and spatial attention modules, which work in parallel to independently focus on the channel and spatial information of the feature map of the image.
[0006] The specific implementation steps of the method of the present invention are as follows:
[0007] A garbage sorting method based on an integrated parallel attention module, the method comprising: using the integrated parallel attention module to construct a recyclable garbage sorting network, wherein the recyclable garbage sorting network uses channel-spatial attention to extract key information of garbage feature maps, thereby realizing automatic recognition and classification of recyclable garbage images.
[0008] The specific steps of the construction method of the integrated parallel attention module are as follows:
[0009] S1: Build a channel attention module that integrates parallel attention modules. The channel attention module can capture the interdependence between different channels, strengthen important features while suppressing irrelevant features, and improve the network's attention to key features.
[0010] S2: Build a spatial attention module that integrates parallel attention modules. The spatial attention module focuses on capturing the changes in the feature map in the spatial dimension, allowing the network to focus on local features in the image.
[0011] S3: Connect the channel attention module and the spatial attention module in parallel so that both can focus on different feature dimensions of the image at the same time, thereby obtaining the integrated parallel attention module.
[0012] The recyclable waste sorting network is built based on the integrated parallel attention module. The specific method is as follows:
[0013] Firstly, the integrated parallel attention module is inserted into ResNeXt50, and then the images in the recyclable garbage dataset TrashZJ are uniformly cropped to the same size (such as 224×224) to train the network to obtain the recyclable garbage sorting network, and the trained recyclable garbage sorting network is used to automatically identify and classify recyclable garbage images.
[0014] Based on the existing open source garbage dataset, we screened and merged the recyclable garbage dataset TrashZJ. The specific method is as follows:
[0015] We filter out background-free garbage images from multiple public garbage datasets and merge them to build the TrashZJ dataset. TrashZJ includes 5 types of recyclable garbage (TrashZJ-5), including clothes, glass, metal, plastic, and paper.
[0016] In order to achieve fine recycling of garbage, TrashZJ can be further subdivided into 12 categories (TrashZJ-12), including pants, skirts, tops, cardboard, paper boxes, newspapers, paper cups, plastic bags, plastic bottles, plastic basins, cans, and glass bottles.
[0017] The construction of the integrated parallel attention module includes three parts: the first is to build the channel attention module, the second is to build the spatial attention module, and the third is to connect the channel attention with the spatial attention. The specific method is as follows:
[0018] The channel attention module is built on layer normalization. The channel attention module enhances the dependency representation between channels through layer normalization, and dynamically adjusts the importance of each channel through the attention mechanism, and finally obtains the attention weight that can reflect the importance of the channel. It can provide more stable attention weights and help improve the network's attention to key features.
[0019] The spatial attention module is built on instance normalization. The spatial attention module normalizes each pixel of each sample independently, focusing on capturing the changes in the feature map in the spatial dimension. This mechanism enables the network to focus on local features in the image, thereby improving the ability to recognize details.
[0020] The integrated parallel attention module connects the channel attention module and the spatial attention module in parallel. This allows both to focus on different feature dimensions of the image at the same time. This parallel structure not only avoids the potential impact of feature modification on subsequent modules, but also allows the network to learn channel and spatial information at the same time, thereby more comprehensively understanding the image content.
[0021] The channel attention module captures the interdependence between different channels, strengthens important features and suppresses irrelevant features. The specific method is as follows: First, the input garbage feature map F with a dimension of H×W×C is in Perform layer normalization to obtain the layer normalized feature map F LN , where μ is F in The mean of F in The standard deviation of λ and are all trainable affine transformation parameters used to control scaling and translation operations, and they can be continuously corrected through the network's own learning. The channel attention scaling factor λ obtained by layer normalization is used to measure the variance of the sample, thereby indicating the importance of the sample. A larger variance means that the sample contains richer information and is therefore more important. The output F based on layer normalization LN , calculate the attention weight W of the sample LN , W LN =ω⊙F LN . Among them, ω is a channel attention vector, whose element ω i represents the i-th element of ω, ω i is calculated by dividing the scaling factor of the ith channel by the scaling factor λ of all feature dimensions i The sum of is implemented to ensure that the sum of all scaling factors is 1. At the same time, in order to capture the global channel information, channel-based average pooling (AvgPool) is used to calculate the channel statistics F C Then, the attention weight W LN With channel statistics F C Multiply element by element and apply the sigmoid function to get the final channel attention weight E C ,E C =Sigmoid(W L ⊙F C ), the sigmoid function ensures that Ec The value of is constrained to the range (0,1) to represent the relative importance of the channel.
[0022] The spatial attention module is used to independently normalize each pixel of each sample and focus on capturing the changes in the feature map in the spatial dimension. The specific method is as follows: First, in Perform instance normalization to obtain the instance normalized feature map F IN , μ i is the mean value of the i-th pixel, σ i is the standard deviation of the ith pixel. The spatial attention scaling factor ρ is used to scale the normalized features, which allows the network to learn the importance of specific pixels and preserve or amplify feature representations. τ is used to add an offset to the normalized features, which enables the network to learn to translate or shift different pixels, thereby preserving a certain degree of the original feature representation. Through the spatial attention scaling factor ρ, the spatial attention module can learn to weight the response of specific pixels, thereby affecting the importance of the feature map. The output F based on instance normalization IN Calculate the attention weight W of the sample instance IN , W IN =γ⊙F IN . Among them, γ is a spatial attention vector, whose elements γ i represents the i-th element of γ, which is calculated by scaling the i-th spatial attention by a factor ρ i This is done by dividing by the sum of the scaling factors of all feature dimensions. γ is used to scale the result after instance normalization in order to adjust the range and expressiveness of each sample. Instance normalization normalizes the features at each spatial position in each channel, so W IN The spatial dimension becomes 1×1, while the number of channels remains C. At the same time, the spatial global information F is generated by spatial average pooling. HW Then, W IN With F HW Multiply them together and use the sigmoid function to get the relative importance E of the spatial pixels. HW , E HW =Sigmoid(W IN ⊙F HW ).
[0023] The connection details of the channel attention module and the spatial attention module are as follows. The integrated parallel attention module uses channel attention and spatial attention in parallel to fully learn the relationship between features. Output feature map of the integrated parallel attention module Parallel connections allow the network to model feature maps from both global and local perspectives, thereby comprehensively utilizing global and local information and improving the richness of feature representation.
[0024] The integrated parallel attention module can adaptively learn the importance of different features by scaling and adjusting the normalized features. Specifically, the integrated parallel attention module uses layer normalization and instance normalization to implement channel attention and spatial attention, respectively. By applying these two attention mechanisms in parallel, the integrated parallel attention module allows the network to capture and strengthen important feature information from both channel and spatial dimensions. This parallel processing avoids the interference problems that may occur in traditional sequence connection methods and ensures the consistency of the network during training and testing phases. Finally, the results of channel attention and spatial attention are combined with the original feature map through element-by-element multiplication to generate richer and more discriminative feature representations, thereby improving the overall performance of the network. As a highly flexible and effective attention mechanism, the integrated parallel attention module can be integrated into existing convolutional neural networks as a plug-and-play attention module.
[0025] The beneficial effects of the present invention are as follows: in the present invention, the integrated parallel attention module utilizes the weight concept in the normalization technology, and realizes comprehensive attention and enhancement of the feature map from the perspective of channel and space by connecting the channel attention module and the spatial attention module in parallel; the integrated parallel attention module can be integrated into various convolutional neural networks as an effective means of attention enhancement to improve the classification accuracy and robustness of the model in complex visual tasks. In this way, the integrated parallel attention module provides a powerful tool for deep learning models to better understand and process image data. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 Example image from the TrashZJ dataset.
[0027] Figure 2 It is the structure of integrating parallel attention modules.
[0028] Figure 3 This is the structure of the channel attention module.
[0029] Figure 4 This is the structure of the spatial attention module.
[0030] Figure 5 Flowchart for inserting an integrated parallel attention module (IPAM) into a ResNeXt Block.
[0031] Figure 6 A network for sorting recyclable waste.
[0032] Figure 7 Garbage feature maps generated for Grad-CAM. (a) Original image. (b) Grad-CAM visualization result of ResNeXt50. (c) Grad-CAM visualization result of ResNeXt50+IPAM. DETAILED DESCRIPTION
[0033] The present invention is further described below with reference to specific embodiments and accompanying drawings.
[0034] A garbage sorting method based on an integrated parallel attention module is disclosed. The method uses the integrated parallel attention module to construct a recyclable garbage sorting network. The recyclable garbage sorting network uses channel-spatial attention to extract key information of garbage feature maps, thereby realizing automatic recognition and classification of recyclable garbage images.
[0035] The method for constructing a recyclable garbage sorting network using an integrated parallel attention module is as follows: first, the integrated parallel attention module is inserted into ResNeXt50, and then the images in the recyclable garbage dataset TrashZJ are uniformly cropped to the same size to train the network, thereby obtaining the recyclable garbage sorting network. The method for constructing the recyclable garbage dataset TrashZJ is as follows: garbage images with backgrounds of life scenes are collected from the open source garbage image dataset, and the TrashZJ dataset is constructed. Examples of garbage images are as follows: Figure 1 shown.
[0036] The integrated parallel attention module proposed in this invention is as follows Figure 2 As shown in Figure 1, it includes a channel attention module and a spatial attention module. The integrated parallel attention module connects the two modules in parallel.
[0037] The structure of the channel attention module is as follows Figure 3 As shown in Figure 2, this module captures the interdependence between different channels, strengthens important features and suppresses irrelevant features.
[0038] The specific working principle of the channel attention module is described as follows:
[0039] The garbage feature map F for the input of dimension H×W×C in Perform layer normalization to obtain the layer normalized feature map F LN ; Layer-normalized output F LN Calculate the attention weight W of the sample LN At the same time, in order to capture the global channel information, channel-based average pooling is used to calculate the channel statistics F C Then, the attention weight W LN With channel statistics F CMultiply element by element and apply the sigmoid function to get the final channel attention weight E C .
[0040] The structure of the spatial attention module is as follows Figure 4 As shown in Figure 3, this module captures the changes in the feature map in the spatial dimension, allowing the network to focus on local features in the image.
[0041] The specific working principle of the spatial attention module is described as follows:
[0042] First, F in Perform instance normalization to obtain the instance normalized feature map F IN ; Output F based on instance normalization IN Calculate the attention weight W of the sample instance IN At the same time, the spatial global information F is generated by spatial average pooling. HW Then, W IN With F HW Multiply them together and use the sigmoid function to get the relative importance E of the spatial pixels. HW .
[0043] The channel attention module and the spatial attention module are connected in parallel to obtain the integrated parallel attention module. Output feature map of the integrated parallel attention module
[0044] The construction process of building a recyclable waste sorting network is as follows:
[0045] Insert the integrated parallel attention module into the ResNeXt block as follows Figure 5 As shown in Figure 2. Each branch of the ResNeXt block starts with a 1×1 convolutional layer, reducing the number of output channels to C. in , thereby introducing nonlinear transformation. After the 1×1 convolution, it is divided into 32 groups of 3×3 grouped convolution layers. The grouping design can increase the width of the network, thereby improving the network's ability to express features. 3×3 convolution is used to extract an abstract representation of the input features. Inserting channel and spatial attention after this helps to introduce more information on the basis of feature abstraction and to conduct deeper mining and processing of features. Therefore, the integrated parallel attention module is inserted after the 3×3 grouped convolution. Then, the dimension is increased to C through 1×1 convolution. out The learned features are combined with the input in an additive manner. The recyclable garbage sorting network structure based on the integrated parallel attention module is as follows: Figure 6 As shown. Finally, the recyclable garbage sorting network outputs the corresponding recyclable garbage category label.
[0046] The area that the neural network focuses on is used to generate a heat map through Grad-CAM to help understand the decision-making process of the network. Figure 7 The garbage feature map generated by Grad-CAM is given. Figure 7 (a) is the original image of randomly selected fiber, paper, metal, plastic and glass samples. Figure 7 (b) and (c) show the Grad-CAM visualization results of ResNeXt50 and ResNeXt50+IPAM, respectively. The colored parts represent the features extracted by the network, which are the focus of the network when performing classification tasks. It can be found that when the background is complex, such as fallen leaves, grass, and sky, these backgrounds will interfere with the classification task, and ResNeXt50 may focus on the background when classifying. When IPAM is added, the recyclable waste sorting network (ResNeXt50+IPAM) can focus on the garbage itself and improve the classification ability of the network.
[0047] The above embodiments are used to illustrate the present invention, rather than to limit the present invention. Any modifications and changes made to the present invention within the spirit and protection scope of the claims of the present invention shall fall within the protection scope of the present invention.
[0048] The above are only specific implementation methods of the present invention, which cannot be used to limit the scope of the present invention. Equivalent changes made by ordinary technicians in this technical field based on this creation, as well as changes known to technicians in this field, should still fall within the scope of the present invention.
Claims
1. A garbage sorting method based on an integrated parallel attention module, characterized in that: The integrated parallel attention module is used to construct a recyclable garbage sorting network, which uses channel-spatial attention to extract key information of garbage feature maps to achieve automatic recognition and classification of recyclable garbage images; the specific steps of the construction method of the integrated parallel attention module are as follows: S1: Building a channel attention module integrating parallel attention modules based on layer normalization; the channel attention module is used to capture the interdependence between different channels, strengthen important features while suppressing irrelevant features, and improve the network's attention to key features; S2: A spatial attention module integrating parallel attention modules is built based on instance normalization; the spatial attention module is used to independently normalize each pixel of each sample, focusing on capturing the changes in the feature map in the spatial dimension, so that the network focuses on the local features in the image; S3: Connect the channel attention module and the spatial attention module in parallel so that both of them focus on different feature dimensions of the image at the same time, thereby obtaining the integrated parallel attention module.
2. The garbage sorting method based on integrated parallel attention module according to claim 1, characterized in that: The method for constructing a recyclable garbage sorting network using an integrated parallel attention module is as follows: first, the integrated parallel attention module is inserted into ResNeXt50, and then the images in the recyclable garbage dataset TrashZJ are uniformly cropped to the same size to train the network, thereby obtaining the recyclable garbage sorting network.
3. The garbage sorting method based on integrated parallel attention module according to claim 2 is characterized in that: The TrashZJ is specifically obtained by screening and merging existing open source garbage datasets. The specific method is as follows: First, we filter out background-free garbage images from multiple public garbage datasets and merge them to build the TrashZJ dataset. TrashZJ includes five types of recyclable garbage, including clothes, glass, metal, plastic, and paper. Then, TrashZJ is further subdivided into 12 categories, including pants, skirts, tops, cardboard, paper boxes, newspapers, paper cups, plastic bags, plastic bottles, plastic basins, cans, and glass bottles.
4. The garbage sorting method based on integrated parallel attention module according to claim 1, characterized in that: In step S1, the channel attention module is used to capture the interdependence between different channels, strengthen important features and suppress irrelevant features. The specific method is as follows: First, the input garbage feature map F with the dimension of H×W×C is in Perform layer normalization to obtain the layer normalized feature map F LN , where μ is F in The mean of F in The standard deviation of are all trainable affine transformation parameters used to control scaling and translation operations; the channel attention scaling factor λ is used to measure the variance of the sample, thereby indicating the importance of the sample; Based on the layer-normalized feature map F LN Calculate the attention weight W of the sample LN , W LN =ω⊙F LN , where ω is a channel attention vector whose elements ω i represents the i-th element of ω, ω i is calculated by scaling the attention of the ith channel by a factor λ i This is done by dividing by the sum of the scaling factors of all feature dimensions to ensure that the sum of all scaling factors is 1; at the same time, channel-based average pooling is used to calculate the channel statistics F C ; Then, the attention weight W LN With channel statistics F C Multiply element by element and apply the sigmoid function to get the final channel attention weight E C ,E C =Sigmoid(W L ⊙F C ).
5. The garbage sorting method based on integrated parallel attention module according to claim 1, characterized in that: In step S2, the spatial attention module is used to independently normalize each pixel of each sample, focusing on capturing the changes in the feature map in the spatial dimension. The specific method is: First, the input garbage feature map F with the dimension of H×W×C is in Perform instance normalization to obtain the instance normalized feature map F IN , Among them, μ i is the mean value of the i-th pixel, σ i is the standard deviation of the i-th pixel; the spatial attention scaling factor ρ is used to scale the normalized features, which allows the network to learn the importance of specific pixels and retain or amplify feature representations; τ is used to add an offset to the normalized features; based on the instance-normalized feature map F IN Calculate the attention weight W of the sample instance IN , W IN =γ⊙F IN , where γ is a spatial attention vector whose elements γ i represents the i-th element of γ, γ i is calculated by scaling the i-th spatial attention by a factor ρ i This is done by dividing by the sum of the scaling factors of all feature dimensions; instance normalization normalizes the features at each spatial position of each channel, so W IN The spatial dimension becomes 1×1, while the number of channels remains C; at the same time, the spatial global information F is generated by spatial average pooling HW ; Then, W IN With F HW Multiply them together and use the sigmoid function to get the relative importance E of the spatial pixels. HW , E HW =Sigmoid(W IN ⊙F HW ).
6. The garbage sorting method based on integrated parallel attention module according to claim 1, characterized in that: In step S3, the integrated parallel attention module simultaneously focuses on different feature dimensions of the image. The specific method is: the output feature map of the integrated parallel attention module Among them, E C is the channel attention weight, E HW is based on the relative importance of spatial pixels.
Citation Information
Patent Citations
Method for realizing garbage classification by using deep learning algorithm
CN112487938A
Garbage classification system and method based on transfer learning
CN112926670A
Intelligent garbage classification method and system based on ARM architecture
CN117611915A
Attention-based image recognition method and system, electronic equipment and storage medium
CN113255821A
Recyclable garbage recognition and classification system based on deep learning
CN115457322A
