Arbitrary angle image garbage detection method based on YOLOV5 optimization

By optimizing the YOLOv5 network structure and adding an angle prediction branch and feature extraction module, the problem that existing technologies can only generate standard angle detection boxes has been solved, thus improving the accuracy and efficiency of garbage detection at any angle.

CN117036896BActive Publication Date: 2026-05-12广州新华学院
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
广州新华学院
Filing Date
2022-04-29
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing technologies can only generate standard-angle garbage detection frames in the horizontal or vertical direction, which cannot accurately reflect the actual position and orientation of garbage objects in natural scenes, resulting in insufficient accuracy of robotic arm sorting.

Method used

By modifying the YOLOv5 detection head, adding an angle prediction convolutional network branch, optimizing the feature extraction network and loss function, and combining data annotation and enhancement processing, detection boxes with arbitrary angles can be generated.

Benefits of technology

It enables accurate detection of waste objects from any angle, improving detection accuracy and recall rate, and meeting the needs of practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117036896B_ABST
    Figure CN117036896B_ABST
Patent Text Reader

Abstract

The application discloses an arbitrary angle image garbage detection method based on YOLOV5 optimization, first, collecting garbage image data sets to complete initial data set labeling. Then, based on the original data set data enhancement processing, a new data set is obtained. Data expansion and scene diversity performance increase the precision of the model and the generalization ability of the application. Then, the YOLOV5 model is improved, the network detection head is modified, the angle prediction branch is increased, and the accurate positioning of the image arbitrary angle garbage target is realized. And by optimizing the feature extraction network and the feature connection network of YOLOV5, and increasing the coordinate attention mechanism module, the feature learning ability of the model is improved. The application can generate an arbitrary angle detection frame for the garbage target, so that the generated detection frame and the actual position of the object are more accurate, which is beneficial to the practical application of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision and intelligent waste detection and sorting, and more specifically, to a waste detection method for arbitrary angle images based on YOLOv5 optimization. Background Technology

[0002] Currently, garbage collection and sorting mainly rely on manual labor. Garbage contains a large number of bacteria, posing a significant health risk to workers. In recent years, image intelligent recognition and artificial intelligence technologies have developed rapidly. Applying image detection technology to garbage type and location identification, and then combining it with robotic arms or robots, intelligent and automated sorting of garbage can be achieved, greatly improving garbage collection efficiency and reducing labor costs and urban pollution.

[0003] Existing technology discloses a deep learning-based method for garbage detection, classification, and inference, relating to the field of computer image processing technology. It employs a combined approach of deep learning, convolutional neural networks, and inference mapping to perform garbage location detection, garbage type classification, and inference of the physical properties of garbage based on garbage images in a garbage target detection image dataset. However, this scheme can only generate standard-angle garbage detection boxes for horizontal or vertical orientations. In real-world scenarios, the angles of garbage targets are diverse and complex. If only standard-angle detection boxes can be generated, when there is an angle between the garbage target in the image and the horizontal direction, the detection boxes cannot accurately reflect the specific location and orientation of the garbage object, which is detrimental to the accurate identification and sorting by robotic arms. Furthermore, the performance and accuracy of existing detection networks are generally average, leaving room for optimization. Summary of the Invention

[0004] This invention provides a garbage detection method for images from any angle based on YOLOv5 optimization, enabling the detection of garbage objects from any angle in natural scenes.

[0005] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows:

[0006] A garbage detection method for images at arbitrary angles based on YOLOv5 optimization includes the following steps:

[0007] S1: Obtain multi-source garbage image datasets through shooting, web crawling, etc., and perform data annotation. The data annotation includes the long side of the object box and the clockwise angle value of the horizontal coordinate, where the angle value ranges from [0°, 180°). In addition, the label style is optimized through a label smoothing algorithm to improve the model training effect.

[0008] S2: Perform data augmentation and data expansion processing on the acquired garbage image dataset to obtain an enhanced dataset;

[0009] S3: Modify the YOLOV5 network detection head, add an angle prediction convolutional network branch, which is used to predict the angle of objects in the image, and optimize the YOLOV5 feature extraction network, feature connection network and loss function to obtain the YOLOV5 optimized model.

[0010] S4: Input the augmented dataset with data annotations into the YOLOV5 optimization model for training and learning, and obtain the trained YOLOV5 optimization model;

[0011] S5: Utilize the trained YOLOv5 optimization model to detect and identify trash at any angle and predict the angle of the trash.

[0012] Preferably, in step S1, a multi-source garbage image dataset is obtained through methods such as shooting, web crawling, etc.

[0013] Preferably, in step S1, when annotating the object frame by the clockwise angle between its longer side and the horizontal coordinate, for waste types with a large length-to-width ratio, an angle smoothing method is used to process the label:

[0014]

[0015] In the formula, x represents the angle label value, b is a constant used to control the peak position of angle smoothing, a is the peak value of the smoothing function, and l and s represent the length of the long side and the length of the short side of the object box. For object boxes with an aspect ratio less than 5, no processing is performed on the angle label. For those with an aspect ratio greater than 5, Gaussian function processing is performed. After processing, g(x) achieves the highest value at the position of the true angle label value of the sample, and decreases within a certain nearest neighbor range. Beyond the nearest neighbor range, it tends to 0. The nearest neighbor range and the smoothing amplitude are controlled by the aspect ratio value and do not exceed 8.

[0016] Preferably, the data annotation in step S1 further includes the object category, object center coordinates, object bounding box length, and object bounding box length in the image.

[0017] Preferably, in step S2, the acquired garbage image dataset undergoes data augmentation and data expansion processing, specifically as follows:

[0018] The acquired garbage image dataset was augmented and diversified by means of angle transformation and flipping, and "salt and pepper noise" was used to process the garbage images.

[0019] Preferably, in step S3, the YOLOv5 network detection head is modified by adding an angle prediction convolutional network branch, specifically as follows:

[0020] Convolutional neural network branches are added to the three network detection heads of YOLOv5. The number of convolutional kernel channels of the added convolutional neural networks is equal to the number of angle categories, i.e., 180. The size of each modified convolutional neural network is: (256, na*(nc+5+n_angle), 1, 1), (512, na*(nc+5+n_angle), 1, 1), (1024, na*(nc+5+n_angle), 1, 1), where na is the number of detection boxes output by each detection head, nc represents the number of detected categories, and n_angle represents the predicted angle categories.

[0021] Preferably, optimizing the YOLOv5 feature extraction network in step S3 specifically involves:

[0022] The BottleneckCSP module in the feature extraction network is optimized. The BottleneckCSP module is obtained by stacking and connecting Bottleneck modules. The optimization of the BottleneckCSP module specifically involves:

[0023] The feature layers of the middle layer of the BottleneckCSP module are merged with the feature layers of the last layer of the BottleneckCSP module to obtain the optimized BottleneckCSP module, which is named HD-BottleneckCSP module.

[0024] Preferably, optimizing the YOLOv5 feature connection network in step S3 specifically involves:

[0025] In YOLOv5, the connections between the detection heads of each network are enhanced by adding feature maps from shallow networks and a CA-Attention module based on coordinate attention mechanism.

[0026] Preferably, the optimization of the YOLOv5 loss function in step S3 specifically involves:

[0027] Formula for calculating the bounding box regression loss:

[0028] loss giou =1-GIOU(A,B)

[0029] Formulas for calculating confidence loss function and category loss function:

[0030]

[0031]

[0032] in, and λ represents whether the j-th prediction box in the i-th cell corresponds to the presence or absence of a target. noobj These are the weighting coefficients; and c i This indicates whether there are actual and predicted values ​​for the target, and the value can be either 0 or 1. and p i (c) represents the true value and the predicted result of the target category, respectively;

[0033] Angle loss function:

[0034]

[0035] In the formula, 'a' represents the angle label, and 'angles' represents the range of angle values, from 0° to 180°. This means that the angle label 'a' is first processed using the g(x) smoothing function and then converted into an angle value probability, p. i (a) represents the probability of predicting angle a;

[0036] By assigning weights to the four loss functions, we obtain the final loss function calculation formula:

[0037] Loss=0.1*loss(giou)+loss(obj)+0.5*loss(cls)+0.8*loss(angle).

[0038] Preferably, before inputting the augmented dataset with data annotations into the YOLOv5 optimized model for training in step S4, the following steps are also performed:

[0039] Extract the Backbone network part of the YOLOV5 optimized model, build a classification model, pre-train it on a large-scale garbage image classification dataset without bounding boxes, obtain the pre-trained weights, and load the pre-trained weights into the Backbone network part of the YOLOV5 optimized model during training.

[0040] Preferably, the specific steps of step S4 are as follows:

[0041] Set up the environment required for training the YOLOv5 optimization model, load the augmented dataset with data annotations into the model for training, with 60% as the training set, 20% as the validation set, and 20% as the test set. At the same time, stratified sampling is performed during the data partitioning process, that is, the proportion of each category of data on the training set, validation set, and test set is similar.

[0042] Set the hyperparameters for training the network model, including the model learning rate, the dataset size for each training session, the maximum number of training epochs, the weight decay coefficient, the warm-up learning momentum, and the initial warm-up learning rate;

[0043] After training, a well-trained optimized YOLOv5 model is obtained.

[0044] Compared with the prior art, the beneficial effects of the technical solution of the present invention are:

[0045] To address the issue that the original YOLOv5 network structure can only generate standard-angle target detection boxes in the horizontal or vertical direction, this invention modifies the YOLOv5 detection head and label style, and adds a target box angle prediction network branch structure. This allows for the generation of detection boxes at arbitrary angles for garbage targets, making the generated detection boxes more accurately cover the actual location of the object, which is beneficial for the practical application of the model. Attached Figure Description

[0046] Figure 1 This is a schematic diagram of the method flow of the present invention.

[0047] Figure 2 This is a schematic diagram of the network detection head of YOLOV5 of the present invention.

[0048] Figure 3 This is a schematic diagram of the HD-Bottleneck CSP module structure.

[0049] Figure 4 This is a schematic diagram of the YOLOV5_CHDB network structure.

[0050] Figure 5 This is a schematic diagram of the CA-Attention module structure.

[0051] Figure 6 This is a schematic diagram of the waste detection results provided for an example. Detailed Implementation

[0052] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent.

[0053] To better illustrate this embodiment, some parts in the accompanying drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions.

[0054] It will be understood by those skilled in the art that certain well-known structures and their descriptions may be omitted in the accompanying drawings.

[0055] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0056] Example 1

[0057] A garbage detection method for images at arbitrary angles based on YOLOv5 optimization, such as... Figure 1 As shown, it includes the following steps:

[0058] S1: Obtain a multi-source garbage image dataset through shooting, web crawling, etc., and perform data annotation. The data annotation includes the long side of the object box and the clockwise angle value of the horizontal coordinate, where the angle value ranges from [0°, 180°). The label style is optimized through a label smoothing algorithm to improve the model training effect.

[0059] S2: Perform data augmentation and data expansion processing on the acquired garbage image dataset to obtain an enhanced dataset;

[0060] S3: Modify the YOLOV5 network detection head, add an angle prediction convolutional network branch, which is used to predict the angle of objects in the image, and optimize the YOLOV5 feature extraction network, feature connection network and loss function to obtain the YOLOV5 optimized model.

[0061] S4: Input the augmented dataset with data annotations into the YOLOV5 optimization model for training and learning, and obtain the trained YOLOV5 optimization model;

[0062] S5: Utilize the trained YOLOv5 optimization model to detect and identify trash at any angle and predict the angle of the trash.

[0063] Example 2

[0064] This embodiment, based on Embodiment 1, continues to disclose the following content:

[0065] In step S1, a multi-source garbage image dataset is obtained through methods such as shooting, web crawling, etc.

[0066] In step S1, when labeling the clockwise angle between the long side and the horizontal coordinate of the object frame, for waste types with a large aspect ratio, the traditional method of classifying angles and setting them as "one-hot" angle labels is difficult to predict angles. This embodiment uses an angle smoothing method to process the labels. This involves replacing the traditional "one-hot" encoding format in the classification with a denser angle label value format. To ensure that the densely processed labels conform to the original label patterns, the following formula is used for conversion:

[0067]

[0068] In the formula, x represents the angle label value, b is a constant used to control the peak position of angle smoothing, and a is the peak value of the smoothing function. In the formula, l and s represent the lengths of the long and short sides of the object box. For object boxes with an aspect ratio less than 5, no processing is performed on the angle labels. For those greater than 5, Gaussian function processing is applied. After processing, g(x) achieves its highest value at the position of the true angle label value in the sample, and decreases within a certain nearest neighbor range, approaching 0 beyond that range. The nearest neighbor range and smoothing amplitude are controlled by the aspect ratio and cannot exceed 8. This achieves angle value smoothing and improves the model's ability to learn angles.

[0069] The data annotation in step S1 also includes the object category, object center coordinates, object bounding box length, and object bounding box length in the image.

[0070] In step S2, the acquired garbage image dataset undergoes data augmentation and data expansion processing, specifically as follows:

[0071] The acquired garbage image dataset is expanded and diversified by means of angle transformation and flipping, and "salt and pepper noise" is used to process the garbage images to increase the difficulty of feature extraction, thereby improving the model's generalization ability and practical application ability.

[0072] Example 3

[0073] Based on Examples 1 and 2, this embodiment continues to disclose the following content:

[0074] In step S3, the YOLOv5 network detection head is modified by adding an angle prediction convolutional network branch, such as... Figure 2 As shown, specifically:

[0075] Convolutional neural network branches are added to the three network detection heads of YOLOv5. The number of convolutional kernel channels of the added convolutional neural networks is equal to the number of angle categories, i.e., 180. The size of each modified convolutional neural network is: (256, na*(nc+5+n_angle), 1, 1), (512, na*(nc+5+n_angle), 1, 1), (1024, na*(nc+5+n_angle), 1, 1), where na is the number of detection boxes output by each detection head, nc represents the number of detected categories, and n_angle represents the predicted angle categories.

[0076] The optimization of the YOLOv5 feature extraction network in step S3 is specifically as follows:

[0077] The BottleneckCSP module in the feature extraction network is optimized. The BottleneckCSP module is obtained by stacking and connecting Bottleneck modules. As the number of Bottlens increases, shallow features are lost to some extent. The optimization of the BottleneckCSP module specifically involves:

[0078] The feature layers of the middle and last layers of the BottleneckCSP module are merged to obtain the optimized BottleneckCSP module, named HD-BottleneckCSP module. This results in richer feature maps. Because Bottleneck has residual block connections, excessive feature merging can lead to feature redundancy. Therefore, the feature layers in HD-BottleneckCSP are connected using an "alternating layer merging" method. Figure 3 As shown, Figure 3 The output of the middle layer, the Bottleneck module. The HD-BottleneckCSP is a basic feature extraction module used in stacked layers for image feature extraction. The input is the output of the previous layer, and the output is the input of the next layer.

[0079] The optimization of the YOLOv5 feature connection network in step S3 specifically involves:

[0080] For the YOLOv5 network feature connection network structure, to further improve the effective connection of feature information, feature maps from shallow networks and a CA-Attention module based on coordinate attention mechanism are added to the connections between the detection heads of each network in YOLOv5. The CA-Attention module is as follows: Figure 5 As shown, the CA-Attention mechanism obtains two 1D vectors by performing average pooling on the horizontal and vertical directions respectively. In terms of spatial dimension, it uses Concat and a Conv2d convolutional network to compress the channels, and then uses Batch Normalization and Non-linearity to encode the spatial information in the vertical and horizontal directions. Then, it processes the data through a 1x1 Conv2d convolutional module to obtain a weight matrix of the same size as the input feature map, and then normalizes and weights it, thereby achieving optimized extraction of feature map information.

[0081] Since the YOLOv5 network does not involve angle prediction, it only includes bounding box regression loss, confidence prediction loss, and category loss. This embodiment adds an angle loss function to this. Weights are then assigned to the four loss functions to obtain the final loss function of the image garbage detection model. The optimization of the YOLOv5 loss function in step S3 specifically involves:

[0082] Formula for calculating the bounding box regression loss:

[0083] loss giou =1-GIOU(A,B)

[0084] In the formula, A and B represent the target bounding box and the detection bounding box, respectively.

[0085] Formulas for calculating confidence loss function and category loss function:

[0086]

[0087]

[0088] in, and λ represents whether the j-th prediction box in the i-th cell corresponds to the presence or absence of a target. noobj These are the weighting coefficients; and c i This indicates whether there are actual and predicted values ​​for the target, and the value can be either 0 or 1. and p i (c) represents the true value and the predicted result of the target category, respectively;

[0089] Angle loss function:

[0090]

[0091] In the formula, 'a' represents the angle label, and 'angles' represents the range of angle values, from 0° to 180°. This means that the angle label 'a' is first processed using the g(x) smoothing function and then converted into an angle value probability, p. i (a) represents the probability of predicting angle a;

[0092] By assigning weights to the four loss functions, we obtain the final loss function calculation formula:

[0093] Loss=0.1*loss(giou)+loss(obj)+0.5*loss(cls)+0.8*loss(angle).

[0094] The final network structure obtained by combining the above optimizations is named YOLOV5_CHDB. A schematic diagram of the YOLOV5_CHDB structure is shown below. Figure 4 As shown, Figure 4In this paper, the YOLOV5_CHDB model implements angle prediction by modifying the detector head structure. Furthermore, it replaces the traditional BottleneckCSP module in YOLOV5 with the HD-BottleneckCSP (HDBCSP) module described in this paper, and optimizes the network connectivity (e.g., ...). Figure 4 The optimized model (shown in the optimization box) adds a long jump connection and a coordinate attention module (CA-Attention) to improve the network's detection capabilities. The optimized model improves the mean average precision (mAP) by 9.4% and the target recall by 6.5%, demonstrating good performance.

[0095] Before inputting the augmented dataset with data annotations into the YOLOv5 optimized model for training in step S4, the following steps are also performed:

[0096] The Backbone network part of the YOLOv5 optimized model is extracted to build a classification model. It is pre-trained on a large-scale garbage image classification dataset without bounding boxes to obtain pre-trained weights. These pre-trained weights are then loaded into the Backbone network part of the YOLOv5 optimized model during training. These pre-trained weights serve as prior knowledge for the image garbage detection model, which is beneficial for the training and learning of the object detection model.

[0097] The pre-trained weights obtained in the above steps are loaded into the backbone of the YOLOV5_CHDB model. The model is then trained on the image garbage detection dataset described in steps S1 and S2 to obtain the final image garbage detection model. The main steps are as follows:

[0098] (1) Set up the environment required for training the YOLOV5_CHDB model, and load the augmented data into the model for training. Use 60% as the training set, 20% as the validation set, and 20% as the test set. To ensure that the distribution of the datasets is similar, stratified sampling is performed during the data partitioning process, that is, the proportion of each category of data in the training set, validation set, and test set is similar.

[0099] (2) Set the hyperparameters for training the network model. Some hyperparameters are set as follows:

[0100] Model learning rate lr0:0.01; batch-size for each training session:8; maximum number of training epochs:1000; weight decay coefficient:0.0003; warmup momentum:0.8; initial warmup learning rate:warmup bias_lr:0.1.

[0101] Tests showed that, compared to the original YOLOv5 network which can only generate horizontal or vertical detection boxes, this method can generate garbage detection boxes at any angle. Furthermore, the optimization scheme proposed in this method improves the mean precision and recall by 9.4% and 6.5% respectively compared to the original method, demonstrating good application value.

[0102] Test results as follows Figure 6 As shown, using the YOLOv5_CHDB method, we can accurately locate and classify litter objects in natural scenes. Compared with traditional methods, it can generate detection results at any angle based on the specific orientation of the litter object, meeting the needs of practical industrial applications.

[0103] The same or similar labels correspond to the same or similar parts;

[0104] The terms used to describe positional relationships in the accompanying drawings are for illustrative purposes only and should not be construed as limiting this patent.

[0105] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A garbage detection method for images at any angle based on YOLOv5 optimization, characterized in that, Includes the following steps: S1: Collect and crawl multi-source garbage image datasets by shooting and labeling them. The data labels include the long side of the object box and the clockwise angle value of the horizontal coordinate, where the angle value ranges from [0°, 180°). The label style is optimized by label smoothing algorithm. S2: Perform data augmentation and data expansion processing on the acquired garbage image dataset to obtain an enhanced dataset; S3: Modify the YOLOV5 network detection head, add an angle prediction convolutional network branch, which is used to predict the angle of objects in the image, and optimize the YOLOV5 feature extraction network, feature connection network and loss function to obtain the YOLOV5 optimized model. S4: Input the augmented dataset with data annotations into the YOLOV5 optimization model for training and learning, and obtain the trained YOLOV5 optimization model; S5: Utilize the trained YOLOv5 optimization model to detect and identify trash at any angle and predict the angle of the trash; Step S1 involves processing the label using an angle smoothing method when determining the clockwise angle between the longer side of the labeled object frame and the x-coordinate. In the formula, x represents the angle label value, b is a constant used to control the peak position of angle smoothing, and a is the peak value of the smoothing function. and The lengths of the long and short sides of the object frame are represented. For object frames with an aspect ratio less than 5, the angle labels are not processed. For those with an aspect ratio greater than 5, a Gaussian function is applied to process them so that g(x) reaches its highest value at the position of the true angle label value of the sample, and decreases within a certain nearest neighbor range. Beyond the nearest neighbor range, it tends to 0. The nearest neighbor range and the smoothing amplitude are controlled by the aspect ratio value and do not exceed 8.

2. The garbage detection method for arbitrary angle images based on YOLOv5 optimization according to claim 1, characterized in that, The data annotation in step S1 also includes the object category in the image, the coordinates of the object's center, the length of the object's long side, and the length of the object's short side.

3. The garbage detection method for arbitrary angle images based on YOLOv5 optimization according to claim 1, characterized in that, Step S2 involves data augmentation and data expansion processing on the acquired garbage image dataset, specifically as follows: The acquired garbage image dataset was augmented and diversified by angle transformation and flipping, and "salt and pepper noise" was used to process the garbage images.

4. The garbage detection method for arbitrary angle images based on YOLOv5 optimization according to claim 1, characterized in that, In step S3, the YOLOv5 network detection head is modified by adding an angle prediction convolutional network branch, specifically: Convolutional neural network branches are added to the three network detection heads of YOLOv5. The number of convolutional kernel channels of the added convolutional neural networks is equal to the number of angle categories, i.e., 180. The modified dimensions of each convolutional neural network are: (256, na*(nc+5 +n_angle), 1, 1), (512, na*(nc+5 +n_angle), 1, 1), (1024, na*(nc+5 +n_angle), 1, 1), where na is the number of detection boxes output by each detection head, nc represents the number of detected categories, and n_angle represents the predicted angle categories.

5. The garbage detection method for arbitrary angle images based on YOLOv5 optimization according to claim 1, characterized in that, Step S3 optimizes the YOLOv5 feature extraction network, specifically as follows: The BottleneckCSP module in the feature extraction network is optimized. The BottleneckCSP module is obtained by stacking and connecting Bottleneck modules. The optimization of the BottleneckCSP module specifically involves: The feature layers of the middle layer of the BottleneckCSP module are merged with the feature layers of the last layer of the BottleneckCSP module to obtain the optimized BottleneckCSP module, which is named HD-BottleneckCSP module.

6. The garbage detection method for arbitrary angle images based on YOLOv5 optimization according to claim 1, characterized in that, Step S3 optimizes the feature connection network of YOLOv5, specifically as follows: In YOLOv5, the connections between the detection heads of each network are enhanced by adding feature maps from shallow networks and a CA-Attention module based on coordinate attention mechanism.

7. The garbage detection method for arbitrary angle images based on YOLOv5 optimization according to claim 1, characterized in that, Step S3 optimizes the loss function of YOLOv5, specifically as follows: Formula for calculating the bounding box regression loss: Formulas for calculating confidence loss function and category loss function: in, and This indicates whether the j-th prediction box in the i-th cell corresponds to the presence or absence of a target. These are the weighting coefficients; and This indicates whether there are actual and predicted values ​​for the target, and the value can be either 0 or 1. and These represent the true value and the predicted result of the target category, respectively. Angle loss function: In the formula, 'a' represents the angle label, and 'angles' represents the range of angle values, from 0° to 180°. This means that the angle label 'a' is first processed using the g(x) smoothing function and then converted into an angle value probability. This indicates the probability of predicting angle 'a'. By assigning weights to the four loss functions, we obtain the final loss function calculation formula: 。 8. The garbage detection method for arbitrary angle images based on YOLOv5 optimization according to claim 1, characterized in that, Before inputting the augmented dataset with data annotations into the YOLOv5 optimized model for training in step S3, the following steps are also performed: Extract the backbone network part of the YOLOv5 optimized model, build a classification model, pre-train it on a large-scale garbage image classification dataset without bounding boxes, obtain pre-trained weights, and load the pre-trained weights into the backbone network part of the YOLOv5 optimized model during training.

9. The garbage detection method for arbitrary angle images based on YOLOv5 optimization according to claim 1, characterized in that, The specific steps of step S4 are as follows: Set up the environment required for training the YOLOv5 optimization model, load the augmented dataset with data annotations into the model for training, with 60% as the training set, 20% as the validation set, and 20% as the test set. At the same time, stratified sampling is performed during the data partitioning process, that is, the proportion of each category of data on the training set, validation set, and test set is similar. Set the hyperparameters for training the network model, including the model learning rate, the dataset size for each training session, the maximum number of training epochs, the weight decay coefficient, the warm-up learning momentum, and the initial warm-up learning rate; After training, a well-trained optimized YOLOv5 model is obtained.