A garbage detection method in a complex scene based on an improved YOLOv8 model

CN117710771BActive Publication Date: 2026-09-22ZHEJIANG FORESTRY UNIVERSITY
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311749151.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-19
Publication Date
2026-09-22
Estimated Expiration
2043-12-19

AI Technical Summary

Technical Problem

这些特点会导致模型很难提取到有用的特征信息来分辨目标,最终造成目标的错检与漏检

Benefits of technology

[0031]1.本发明针对模型对复杂场景下垃圾目标的关注偏移问题,首先,引入注意力机制对垃圾目标进行加权校准,从而在训练过程中关注到关键特征信息,提高模型在复杂场景下的定位与识别能力。然后,考虑到各通道注意力特征对模型贡献的不均衡情况,设计注意特征融合模块。通过原特征与洗牌后的特征进行自适应实例规范化融合,使各通道的注意力特征得到有效利用。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117710771B_ABST
    Figure CN117710771B_ABST
Patent Text Reader

Abstract

The application discloses an automatic garbage detection method in a complex scene, which comprises the following steps: acquiring garbage images through a camera in a natural scene; performing data enhancement preprocessing on the images; introducing a normalization attention module into a YOLOv8 model to calibrate the attention degree of the model to a target; using an attention fusion module to complement the attention weight of each channel; capturing fine-grained features through an instance boundary reinforcement module to improve the representation ability of the model; using a sliding loss function to dynamically weight difficult samples; inputting the preprocessed image data into the improved model for training and testing to obtain an optimal model; and finally inputting a to-be-detected image into the optimal model to calculate a detection result. The automatic garbage detection and recognition method based on the improved YOLOv8 in the complex scene can ensure accurate positioning and recognition of garbage in a complex natural scene, and has a good application prospect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural image target detection, and relates to an automatic garbage detection method, particularly a garbage identification and detection technology for complex scenes. Background Technology

[0002] In recent years, with the acceleration of industrialization, the improvement of people's consumption levels, and the diversification of consumption patterns, the amount of urban household waste has shown a linear growth trend. Therefore, how to curb the ever-increasing amount of waste has become a serious global social problem. It is well known that the fundamental solution to the urban waste problem lies in "reduction," "harmlessness," and "resource recovery," and waste sorting is a necessary prerequisite and a key measure to achieve a circular economy. However, current waste sorting management has certain shortcomings. On the one hand, due to a lack of awareness or the absence of mandatory government constraints, residents' willingness to sort waste is not strong, thus increasing the difficulty of waste disposal and sorting. On the other hand, current waste disposal and sorting work mainly relies on manual labor. This method suffers from low sorting efficiency, high workload, and poor sanitation, easily harming the physical and mental health of workers and affecting the normal operation of waste sorting management. Therefore, how to guide people to correctly sort waste and how to change the current waste sorting work model are particularly important. With the rapid development of artificial intelligence technology, intelligent sorting provides a new and effective solution to the current waste sorting problem.

[0003] Object detection technology has become a research hotspot in the field of computer vision. Because it can identify and locate objects in images or videos, it is widely used in engineering practice. Similarly, applying object detection technology to garbage classification can significantly improve classification efficiency. Traditional object detection algorithms extract object features through feature operators, but these methods only extract low-level features (such as color, texture, and shape) of objects in specific scenarios, resulting in poor robustness. Furthermore, they suffer from low detection accuracy and slow speed, thus limiting their application scope. With the rise of deep learning technology, Convolutional Neural Networks (CNNs) have broken through the technical bottleneck of feature extraction in traditional object detection algorithms. Their powerful hierarchical representation capabilities have shone brightly in various detection tasks. CNNs can overcome the subjectivity and limitations of traditional manual feature extraction by employing efficient image recognition techniques to capture high-level semantic features of targets that are easily distinguishable by computers, thereby improving recognition accuracy and efficiency.

[0004] Currently, CNN-based object detection algorithms have shown initial success in waste classification research, significantly promoting the rapid development of intelligent waste classification management. However, research on waste detection in complex scenarios is still in its early stages. Even though existing studies have proposed solutions, the sheer size of the proposed models places immense computational pressure on resource-constrained devices. This contradicts the real-time requirements of waste detection tasks. Furthermore, besides the challenges posed by complex environments (background, lighting, and debris), the irregular characteristics of waste (intra-class differences, inter-class similarities) constantly impact detection efficiency. These characteristics make it difficult for models to extract useful feature information to distinguish targets, ultimately leading to false positives and false negatives. Therefore, designing an efficient waste detection algorithm for complex scenarios is essential. Summary of the Invention

[0005] The purpose of this invention is to provide a waste detection method for complex scenarios based on deep learning technology, which overcomes the robustness limitations of existing research in the field of waste detection and effectively improves the ability to locate and identify waste targets in the natural environment.

[0006] The present invention provides an automatic garbage detection method for complex scenarios based on an improved YOLOv8, comprising the following steps:

[0007] (1) First, garbage image data is collected in natural scenes by camera and the dataset is preprocessed.

[0008] (2) In view of the challenges of garbage detection in complex scenarios and the lack of research in this task area, a garbage detection model for complex scenarios based on improved YOLOv8 is proposed. The improvement methods include introducing a normalized attention module (NAM) to calibrate the model’s attention to the target; designing an attention feature fusion (AFF) module to complement the attention weights of each channel; establishing a boundary instance enhancement (IBR) module to capture the fine-grained features of garbage; and using the Slide Loss function to dynamically weight difficult garbage samples.

[0009] (3) The preprocessed garbage image data is fed into the improved YOLOv8 model for training and validation, and the model is tested in a test set. The final performance of the model is evaluated through multiple evaluation metrics.

[0010] (4) Input the garbage image to be detected into the best improved model obtained by training, and output the detection result through forward calculation.

[0011] Furthermore, the preprocessing method described in step 1 is specifically as follows:

[0012] (1.1) Before the experiment, the corresponding categories of garbage targets in each image were first set; then, the data was amplified by performing operations such as mirroring, flipping, translating, shearing, affine transformation, and rotation on the image set; then, the image annotation software LableImg was used to annotate the detection boxes and categories of garbage targets in the images; finally, the dataset was randomly divided into training set and test set in a ratio of 8:2.

[0013] (1.2) Set up a data preprocessing method for the training model. Use the Mosaic data augmentation algorithm to randomly crop and scale every four garbage images input to the network, and stitch them together in the order of top left, top right, bottom left, and bottom right to form a new image data. This enables the model to learn rich background information of the image data and enhances its robustness.

[0014] (1.3) Use an adaptive image scaling method to scale the original image to a resolution of 640*h or w*640 (where h and w are both less than or equal to 640 pixels). To ensure a uniform 640*640 size is input into the network, black borders are added to complete the length or width of the scaled image. This reduces the computational load of the model and improves the training efficiency.

[0015] Furthermore, the garbage detection method for complex scenarios based on the improved YOLOv8 described in step 2 is as follows:

[0016] (2.1) A Normalized Attention (NAM) mechanism is introduced and embedded into the feature fusion network to calibrate the model's attention to the target within deep, high-semantic information and suppress environmental noise interference. NAM uses channel weight sparsity penalty to calibrate the dimensionality of the feature map. Specifically, for an input feature, batch normalization is first performed to extract the scaling factor of the dimension; then, the standard deviation of each dimension scaling factor is calculated as the dimension weight contribution value; next, the feature information is recalibrated by matrix multiplying the weight values ​​with the normalized features; finally, the attention weight coefficients are calculated using the Sigmoid activation function and multiplied with the input features to obtain the final attention feature map. The calculation of normalization and weight values ​​are shown below:

[0017] in for The input features of the layer and They are respectively The mean and variance, and yes Learn the hyperparameters of the feature distribution of the dimensionality. It is a hyperparameter with a fixed value.

[0018] (2.2) After introducing the Attention Feature Fusion (AFF) module into the attention module, the weight contributions of the attention features from each channel are combined, enabling the model to fully utilize attention to focus on the main information of the target. The working principle of AFF is very simple, using only two simple operators: channel shuffle and adaptive instance normalization (AdaIN). Specifically, for the input attention feature M1, the channel features of M1 are first shuffled and mixed through a channel shuffle operation, reshaping them into another set of attention features M2, which can be represented as:

[0019] Then, the AdaIN operator is used to transfer the style pattern of M2 to the content features of M1. Attention features with different weights in the corresponding channels of M1 and M2 are then transferred and fused to obtain the output feature M3 with significant target attention. The calculation of M3 is as follows: in and This is for calculating the variance and mean.

[0020] (2.3) Establish a boundary instance enhancement module (IBR), embedding the IBR into the feature extraction network to capture fine-grained features of garbage by combining strong gradient information and semantic information. The IBR captures target boundary information by integrating gradient cues from shared convolutions around the convolutions. It mainly consists of shared convolutions, local descriptors, semantic projectors, and double normalization layers. Specifically, for a given input feature... First, a 3×3 ordinary convolution pair is used. The local receptive field region is sampled, and the sampled values ​​are weighted and summed to obtain the shared feature weight matrix. , The calculation formula is as follows: in This represents the local receptive field region where the convolution operation is performed. This represents the filter used for sampling features. Indicates in The first in The weight values ​​at each position are determined; then, to obtain gradient-level detail information, the weight values ​​located at the center of the local receptive field region are set to 0, and a feature matrix with rich boundary information is obtained by calculating the gradient difference. , The calculation formula is as follows: in, The weight value represents the location of the center of the local receptive field region. It is a learnable parameter used to measure the importance of gradient information; at the same time, in order to compensate for the low semantic information deficiency caused by gradient features in differential convolution, the features of shared convolution are utilized. To learn how to summarize abstract semantic information , The calculation formula is as follows: in, It is a learnable parameter used to learn the importance of projection semantics; then, double normalization is used. and right , Perform feature alignment and summation. and The calculation formula is as follows:

[0021]

[0022]

[0023] in, for The input features of the layer and They are respectively The mean and variance, and yes Learn the hyperparameters of the feature distribution of the dimensionality. It is a hyperparameter with a fixed value. for The input features of the layer and They are respectively The mean and variance, and yes Learn the hyperparameters of the feature distribution of the dimensionality. It is a hyperparameter with a fixed value; ultimately, the output features are obtained. , It can be represented as:

[0024]

[0025] (2.4) A Slide Loss function with an adaptive threshold is introduced to learn and optimize hard samples, allowing the model to pay more attention to these samples during training and output more accurate results. The difference between easy and hard samples lies in the IoU value between the predicted and ground truth boxes. Hard samples have bounding boxes with unclear classifications, located in the transition region between the foreground and background. Although the loss of hard samples is larger, their number is relatively small, making them less likely to be noticed by the model during training. Therefore, higher learning weights need to be assigned to hard samples. The Slide Loss method takes the average IoU value of all bounding boxes as the threshold. , will be less than The bounding box is used as a negative sample, which is greater than The bounding boxes are used as positive samples, and the area around the threshold is defined as a region prone to generating difficult samples. Then, the difficult samples are weighted using a weighted Slide function.

[0026] Furthermore, the training, validation, and testing methods for the improved YOLOv8 model described in step 3 are as follows:

[0027] (3.1) Input the preprocessed garbage dataset from step 1 into the improved YOLOv8 network from step 2 for training. Set an iteration cycle of 300 rounds. After each iteration, use the validation set to verify the performance of the model generated in each iteration, and save the optimal model weight file by comparison.

[0028] (3.2) After the training iteration is completed, the best model obtained in the final training in (3.1) is tested using the test set. The performance of the improved model is evaluated by the number of model parameters, computational cost, accuracy, recall, average precision and detection speed.

[0029] Furthermore, the method for detecting garbage images in complex scenes using the improved model described in step 4 is as follows: First, the image to be detected is input into the model. The model will adaptively scale to 640*640 according to method (1.3) and load it into (3.1) to obtain the optimal model weights. The image is input into the model weights and linear and nonlinear calculations are performed using convolution kernels and activation functions respectively. Then, three detection branches are used to generate classification and regression results for targets of different scales. Finally, non-maximum suppression is used to retain the result with the highest classification score for each garbage target to obtain the final detection result.

[0030] This invention has the following characteristics:

[0031] 1. This invention addresses the problem of model attention bias towards garbage targets in complex scenes. First, an attention mechanism is introduced to weightedly calibrate garbage targets, thereby focusing on key feature information during training and improving the model's localization and recognition capabilities in complex scenes. Then, considering the uneven contribution of attention features from different channels to the model, an attention feature fusion module is designed. Adaptive instance normalization fusion is performed between the original features and the shuffled features, ensuring effective utilization of the attention features from each channel.

[0032] 2. This invention addresses the challenge of feature extraction caused by the irregular features of garbage in complex scenarios by proposing an instance boundary enhancement module. By fusing gradient information obtained from gradient difference calculations into the strong semantic information of the feature map, highly recognizable target boundary features are highlighted, enhancing the model's feature representation capability.

[0033] 3. This invention addresses the imbalance between easy and difficult samples by employing a Slide Loss function to optimize weight allocation. It differentiates between positive and negative samples through an adaptive learning threshold parameter, smoothly processing the weights to dynamically allocate weights to difficult samples, thereby improving the accuracy of difficult sample identification.

[0034] 4. The proposed algorithm for detecting waste in complex scenarios can quickly and accurately detect and identify waste, and has significant advantages in lightweight deployment. Attached Figure Description

[0035] Figure 1 This is a flowchart of the garbage detection algorithm proposed in this invention.

[0036] Figure 2 This is a structural diagram of the normalized attention mechanism used in this invention.

[0037] Figure 3 This is a schematic diagram of the attention feature fusion module proposed in this invention.

[0038] Figure 4 This is a schematic diagram of the instance boundary reinforcement module proposed in this invention.

[0039] Figure 5 This is a structural diagram of the element module C2f_IBR in the feature fusion network proposed in this invention.

[0040] Figure 6 The weight classification strategy is the Slide Loss loss function used in this invention.

[0041] Figure 7 This is a structural diagram of the HGCS-Det model proposed in this invention.

[0042] Figure 8This invention utilizes HGCS-Det to generate a heatmap of interest on garbage images.

[0043] Figure 9 This invention uses HGCS-Det to visualize feature maps on garbage images.

[0044] Figure 10 The curves show the comparison of training accuracy between the HGCS-Det proposed in this invention and mainstream networks.

[0045] Figure 11 Examples of images of trash collected in the natural environment.

[0046] Figure 12 This is a detection result image of garbage collected in the natural environment. Detailed Implementation

[0047] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0048] This invention proposes a garbage detection algorithm suitable for complex scenarios, combining... Figures 1 to 12 Detailed explanation is as follows:

[0049] like Figure 1 The flowchart illustrates the proposed garbage detection algorithm for complex scenes based on an improved YOLOv8 network. First, garbage image data is acquired in a natural scene using a camera, and the dataset is preprocessed. Second, the YOLOv8 model is improved to suit garbage detection tasks in complex scenes. Improvements include introducing a Normalized Attention Module (NAM) to calibrate the model's attention to the target; designing an Attention Fusion Module (AFF) to complement the attention weights of each channel; establishing an Intensified Boundary Instance Enhancement Module (IBR) to capture fine-grained features of the garbage; and using a Slide Loss function to dynamically weight difficult garbage samples. Then, the image data is input into the improved YOLOv8 model at a fixed size of 640*640 for training and validation, and tested using a test set. Finally, the garbage image to be detected is input into the model weights of the proposed automatic garbage detection method for complex scenes, and the detection result is output through forward calculation.

[0050] like Figure 2The diagram shows the structure of the normalized attention mechanism used in this invention. Normalized Attention (NAM) uses the contribution of selected dimensional weights as a standard to measure the salient features of an image. A scaling factor based on batch normalization is used to measure the importance of each dimensional feature weight, suppressing unimportant channel or pixel information in the image and enhancing the target feature representation. Similar to the CBAM attention integration method, NAM consists of channel attention and spatial attention sub-modules. The channel attention module uses channel weight sparsity penalty to calibrate the channel information of the feature map. The spatial attention module uses spatial weight sparsity penalty to calibrate the spatial information of the feature map.

[0051] like Figure 3 The diagram shows a schematic of the attention feature fusion module proposed in this invention. The attention feature fusion (AFF) module is a parameter-free attention enhancement module. It is implemented using only two simple operators: channel shuffle and adaptive instance normalization (AdaIN). First, the channel features of the original feature are shuffled and mixed through the channel shuffle operation, reshaping them into another set of attention features. Then, the AdaIN operator is used to fuse the original feature with the reshaped feature to obtain the output feature with significant target attention.

[0052] like Figure 4 This is a schematic diagram of the instance boundary enhancement module proposed in this invention. The instance boundary enhancement module (IBR) integrates gradient cues from shared convolutions around the convolutions to capture target boundary information, enhancing the model's feature representation capability. The IBR mainly consists of shared convolutions, local descriptors, a semantic projector, and a double normalization layer. The local descriptor is a gradient difference mechanism, specifically a central difference convolution, generated by gradient aggregation from the shared convolutions. The semantic projector obtains feature semantic information by learning the feature maps of the shared convolutions. The double normalization layer consists of two independent batch normalization (BN) layers used to align the output features.

[0053] like Figure 5 This is a structural diagram of the element module C2f_IBR in the feature fusion network proposed in this invention. Specifically, the convolutions in Bottleneck are replaced with IBR modules to form the C2f_IBR module. C2f_IBR retains the original C2f cross-stage hierarchical structure and enhances the network's modeling capability by fusing rich boundary information and gradient flow combination information.

[0054] like Figure 6 The diagram illustrates the weight classification strategy of the Slide Loss function used in this invention. The Slide Loss function is a positive and negative sample weight optimization strategy introduced in the BCEWithLogitsLoss classification function. The Slide Loss method takes the average of the intersection-over-union (IoU) values ​​of all bounding boxes as the threshold. , will be less than The bounding box is used as a negative sample, which is greater than The bounding boxes are used as positive samples, and the area around the threshold is defined as a region prone to generating difficult samples. Then, a weighted sliding function is used to weight the difficult samples.

[0055] This invention proposes the HGCS-Det network based on YOLOv8. For example... Figure 7 The diagram shows the structure of the HGCS-Det model proposed in this invention. First, an attention mechanism (NAM) is embedded after the C2f module in the Neck section to focus on key features within deep, high-semantic information and suppress useless information. Simultaneously, an attention feature fusion module is used to integrate the attention feature weights of each channel, enhancing the model's focus on the target. Then, to obtain fine-grained features of garbage and facilitate the differentiation of irregular garbage targets, a boundary instance enhancement module is applied to the backbone network's feature extraction layer. Specifically, the convolutions in the Bottleneck are replaced with IBR modules to form the C2f_IBR module. C2f_IBR enhances the network's modeling ability by fusing rich boundary information with gradient flow combination information. Finally, a Slide weight function with adaptive thresholds is introduced, making the model pay more attention to difficult samples during training.

[0056] To analyze the contribution of each improvement strategy to enhancing model performance, ablation experiments were conducted to evaluate the effectiveness of the improvement strategies. For fair comparison, the same dataset and experimental environment were used in all experiments. YOLOv8n was used as the baseline network, and the following were successively introduced to optimize and improve YOLOv8n: the attention mechanism NAM, the attention feature fusion module AFF, the instance boundary enhancement module IBR, and the loss function Slide Loss. The ablation experiment results are shown in Table 1. The average precision achieved by each improvement strategy reached 92.9%, 93.2%, 92.7%, and 92.7%, respectively, all exceeding YOLOv8n. Finally, the HGCS-Det model, combining all the improvement strategies, achieved excellent detection performance of 92.6% precision, 87.8% recall, and 93.6% average precision while maintaining the low computational cost of YOLOv8n, representing improvements of 0.9%, 1.0%, and 1.3% compared to YOLOv8n, respectively.

[0057] Table 1: Ablation Experiment

[0058] √ 3.02M 8.2G 91.7% 86.8% 92.3% 95 √ √ 3.02M 8.2G 92.5% 86.4% 92.9% 88 √ √ √ 3.02M 8.2G 92.1% 87.8% 93.2% 86 √ √ 3.02M 8.2G 92.0% 86.7% 92.7% 92 √ √ 3.02M 8.2G 91.2% 87.9& 92.7% 93 √ √ √ √ √ 3.02M 8.2G 92.6% 87.8% 93.6% 86

[0059] like Figure 8The figure shows the attention heatmap of HGCS-Det applied to garbage images using this invention. As can be seen from the figure, the HGCS-Det model effectively suppresses the influence of noise information (background, pebbles, branches, etc.), improving both the coverage and attention level of the target region, and significantly enhancing the global (outline and texture) attention to garbage targets. These results demonstrate that the proposed HGCS-Det can effectively calibrate the model's attention to targets, accurately locating and identifying garbage targets in complex scenes. This also indirectly proves that the model has strong generalization performance when applied to complex scenes.

[0060] like Figure 9 The image shows a visualized feature map of a garbage image using HGCS-Det, as presented in this invention. As can be seen from the image, HGCS-Det effectively highlights the distinct features (outline, shape, texture) of the garbage target, providing more feature details and suppressing complex background information. This demonstrates that HGCS-Det is superior in feature representation capabilities.

[0061] like Figure 10 The figure shows a comparison curve of the training accuracy of HGCS-Det proposed in this invention with mainstream networks. As can be seen from the figure, the mAP curve of HGCS-Det rises steadily and converges rapidly until it tends to fit the model, ultimately achieving a better mAP value than other models.

[0062] To verify the superiority of this invention over other advanced object detection algorithms, comparative experiments were added to study the performance of lightweight and near-lightweight versions of the most advanced single-stage object detection algorithms on the same garbage dataset. The comparison results are shown in Table 2. The HGCS-Det model of this invention achieved the highest average accuracy of 93.6%, with 3.02M parameters, 8.2G computation, and a detection speed of 86 FPS. Compared to other advanced detection algorithms, it exhibits superior detection performance, achieving a trade-off between detection accuracy and speed. Furthermore, the model size is suitable for deployment on hardware modules, making it practically applicable.

[0063] Table 2: Performance Comparison of Each Model

[0064] YOLOv5n 1.80M 4.3G 87.3% 102 YOLOX-tiny 5.04M 15.3G 91.2% 82 YOLOv6n 4.31M 11.1G 91.8% 87 YOLOv7-tiny 6.09M 13.4G 90.6% 98 YOLOv8n 3.02M 8.2G 92.3% 95 YOLOv5s 7.10M 16.2G 90.9% 84 YOLOXs 8.95M 26.8G 91.6% 68 YOLOv6s 17.20M 44.1G 93.0% 74 YOLOv8s 11.15M 28.7G 93.6% 77 HGCS-Det 3.02M 8.2G 93.6% 86

[0065] The following is combined Figure 11 and Figure 12 Here is an application example:

[0066] like Figure 11The image shown is an example of garbage images in a natural scene obtained by the image acquisition module. This image set contains 30 categories of household waste images: apple cores, banana peels, batteries, books, button batteries, capsules, cigarette boxes, cigarette butts, lunch boxes, paper cups, modulator tubes, glass bottles, masks, mercury thermometers, mobile phones, cardboard boxes, pencils, plastic bottles, remote controls, tea leaves, shoes, canned goods, rice, toothbrushes, pants, shirts, vegetable leaves, waste paper, and watermelon rinds. To verify the robustness of the proposed method in real-world scenarios, the actual digital images to be detected (a), (b), (c), and (d) are input into the weights of the trained improved YOLOv8 model, and the visualization detection results are output through calculation.

[0067] Test results as follows Figure 12 As shown, various types of trash in the image can be effectively located and detected, effectively suppressing interference from complex environments.

Claims

1. A garbage detection method for complex scenarios based on an improved YOLOv8 model, characterized in that, The steps include the following: a. First, collect garbage image data in natural scenes using a camera, and then preprocess the dataset; b. Construct a garbage detection model for complex scenarios based on an improved YOLOv8 model. The improved YOLOv8 model includes a backbone feature extraction network, a feature fusion network, and a detection head. To simultaneously address the fine-grained irregular features of garbage targets and the imbalance between easy and difficult samples during training, while maintaining a lightweight model, the following collaborative improvement method is adopted: b1. A normalized attention module (NAM) is introduced into the feature fusion network to calibrate the attention of the feature map by penalizing the sparsity of the dimension weights, so as to suppress the environmental noise interference information in the image in complex scenes and calibrate the model's attention to garbage targets. b2. An attention fusion module (AFF) is introduced after the normalized attention module (NAM). The attention fusion module first performs a channel shuffle operation on the input first attention feature map (M1) to generate a second attention feature map (M2). Then, the adaptive instance normalization (AdaIN) operator is used to transfer the style of the second attention feature map (M2) to the content features of the first attention feature map (M1) to fuse the attention weights of different channels and obtain the output features with enhanced target attention. b3. A boundary instance enhancement module (IBR) is established in the backbone feature extraction network. The boundary instance enhancement module (IBR) consists of a shared convolution, a local descriptor, a semantic projector, and a double normalization layer; wherein, the shared convolution is used to extract the shared feature weight matrix ( The local descriptor extracts a feature matrix with boundary gradient information by setting the weights at the center of the local receptive field to 0 and calculating the gradient difference. The semantic projector uses learnable parameters ( ) for the shared feature weight matrix ( Projection is performed to extract the abstract semantic feature matrix. The dual normalization layers respectively normalize the feature matrix ( ) and the abstract semantic feature matrix ( After feature alignment, the features are added together to capture fine-grained feature information of the garbage target; b4. During the training phase, a sliding loss function is used, which uses the average intersection-over-union (IoU) ratio of all bounding boxes as an adaptive threshold. The weighted sliding function is used to determine the intersection-union ratio at the threshold ( Dynamically assign higher training weights to difficult samples near the target location; c. The preprocessed garbage image data is fed into the improved YOLOv8 model for training and validation, and tested using a test set. The final performance of the model is evaluated through six evaluation metrics. d. Input the garbage image to be detected into the improved YOLOv8 model trained in step c above, and output the detection result through forward calculation.

2. The garbage detection method for complex scenarios based on the improved YOLOv8 model as described in claim 1, characterized in that, The data preprocessing described in step a includes: augmenting the data by performing mirroring, flipping, translation, cropping, affine transformation, and rotation operations on the dataset; labeling the garbage targets in the images using the image annotation software LableImg; randomly dividing the dataset into training and testing sets at an 8:2 ratio; and randomly cropping and scaling every four garbage images input to the network using the Mosaic data augmentation algorithm, stitching them together in the order of top left, top right, bottom left, and bottom right to form a new image dataset. The adaptive image scaling method scales the original image to a resolution of h*640 pixels or 640*w pixels proportionally, where h and w are both less than or equal to 640 pixels. Images with h and w less than 640 pixels are padded with black borders to achieve a uniform size of 640*640.

3. The garbage detection method for complex scenarios based on the improved YOLOv8 model as described in claim 1, characterized in that, The normalized attention method described in step b includes calibrating the attention of the feature map by selecting the contribution of dimensional weights as a standard for measuring the salient features of the image; Normalized attention utilizes dimensionality weight sparsity penalty to calibrate the dimensionality information of the feature map. Specifically, it measures the importance of each dimensional feature weight using a normalized scaling factor to suppress unimportant channel or pixel information in the image and enhance the target feature representation. For a given input feature... First, batch normalization is performed to extract the scaling factor of the dimensions. ; Then, calculate the scaling factor for each dimension. Standard deviation as the contribution value of dimension weight Next, by adjusting the weight values The channel feature information is recalibrated by matrix multiplication with the normalized features; finally, the attention weight coefficients are calculated using the Sigmoid activation function and then multiplied with the input features. Multiplication yields the final attention feature map. ; where normalization and weight values The calculations are shown in the following formulas. in for The input features of the layer and They are respectively The mean and variance, and yes Learn the hyperparameters of the feature distribution of the dimensionality. It is a hyperparameter with a fixed value.

4. The garbage detection method for complex scenarios based on the improved YOLOv8 model as described in claim 1, characterized in that, The attention feature fusion method described in step b includes fusing attention feature maps from different channels using a parameterless feature processing operator to integrate the weight contributions of all attention features and fully utilize attention to extract target features; for input attention features First, the channel shuffle operation will... The channel features are shuffled and mixed, and reshaped into another set of attention features. , This can be expressed as, Then, the Adaptive Instance Normalization (AdaIN) operator is used to... style migration to Among the content features, and Attention features with different weights in the corresponding channels are fused to obtain output features with significant target attention. , The calculation is as follows: in and This is for calculating the variance and mean.

5. The garbage detection method for complex scenarios based on the improved YOLOv8 model as described in claim 1, characterized in that, The instance boundary enhancement method described in step b includes capturing target boundary information by integrating gradient cues from shared convolutions around the convolutions to capture fine-grained feature information of the target. Instance boundary enhancement mainly consists of shared convolutions, local descriptors, semantic projectors, and double normalization layers; for a given input feature First, a 3×3 ordinary convolution pair is used. The local receptive field region is sampled, and the sampled values ​​are weighted and summed to obtain the shared feature weight matrix. , The calculation formula is as follows: in This represents the local receptive field region where the convolution operation is performed. This represents the filter used for sampling features. Indicates in The first in The weight values ​​at each position are determined; then, to obtain gradient-level detail information, the weight values ​​located at the center of the local receptive field region are set to 0, and a feature matrix with rich boundary information is obtained by calculating the gradient difference. , The calculation formula is as follows: in, The weight value represents the location of the center of the local receptive field region. It is a learnable parameter used to measure the importance of gradient information; at the same time, in order to compensate for the low semantic information deficiency caused by gradient features in differential convolution, the features of shared convolution are utilized. To learn how to summarize abstract semantic information , The calculation formula is as follows: in, It is a learnable parameter used to learn the importance of projection semantics; then, double normalization is used. and right , Perform feature alignment and summation. and The calculation formula is as follows: in, for The input features of the layer and They are respectively The mean and variance, and yes Learn the hyperparameters of the feature distribution of the dimensionality. It is a hyperparameter with a fixed value. for The input features of the layer and They are respectively The mean and variance, and yes Learn the hyperparameters of the feature distribution of the dimensionality. It is a hyperparameter with a fixed value; ultimately, the output features are obtained. , This can be expressed as, 6. The garbage detection method for complex scenarios based on the improved YOLOv8 model as described in claim 1, characterized in that, The sliding loss function in step b includes dynamically assigning training weight contribution values ​​to easy and hard samples by adaptively learning a threshold parameter; the difference between easy and hard samples lies in the intersection-union ratio (IU) of the predicted and ground truth bounding boxes; the sliding loss function uses the average IU of all bounding boxes as the threshold. , will be less than The bounding box is used as a negative sample, which is greater than The bounding boxes are used as positive samples, and the area around the threshold is defined as a region prone to generating difficult samples. Then, a weighted sliding function is used to weight the difficult samples. The formula for calculating the weighted sliding function is shown below.

7. The garbage detection method for complex scenarios based on the improved YOLOv8 model as described in claim 1, characterized in that, The training, validation, and testing method for the improved YOLOv8 model described in step c includes inputting the preprocessed garbage dataset into the improved network for training over 300 iteration cycles. After each iteration, the performance of the model generated in each iteration is verified using a test set. The optimal model is obtained after 300 training and testing iterations. The optimal model obtained from the final training is then tested using the test set. The model performance is evaluated by the number of parameters, computational cost, accuracy, recall, average precision, and detection speed.

8. The garbage detection method for complex scenarios based on the improved YOLOv8 model as described in claim 1, characterized in that, Step d describes the method for detecting garbage images using the model of the present invention, which includes: adaptively scaling the image to be detected to a resolution of 640*640 pixels and loading it into the model of the present invention; inputting the image into the model weights and performing calculations using convolution kernels and activation functions; and using three detection branches to generate classification and regression results for targets of different scales. The nonmaximum suppression method is used to retain the detection result with the highest classification score for each garbage target; finally, the final detection result is obtained.

Citation Information

Patent Citations

  • Arbitrary style migration method based on multi-attention network

    CN114170066A

  • Multi-target garbage detection method based on improved YOLOv5 model

    CN116452950A

  • Traffic sign detection method based on normalized attention mechanism YOLOv7

    CN116740674A