Search

CN-117036896-B - YOLOV5 optimization-based arbitrary-angle image garbage detection method

CN117036896BCN 117036896 BCN117036896 BCN 117036896BCN-117036896-B

Abstract

The application discloses a method for detecting image garbage at any angle based on YOLOV optimization, which comprises the steps of firstly collecting garbage image data sets to finish initial data set labeling. And then, carrying out data enhancement processing based on the original data set to obtain a new data set. The data amplification and scene diversity increasing performance improves the precision of the model and the generalization capability of the application. Then, the YOLOV model is improved, and the angle prediction branch is added by modifying the network detection head, so that the accurate positioning of the image garbage target at any angle is realized. And the feature extraction network and the feature connection network of YOLOV are optimized, and a coordinate attention mechanism module is added, so that the feature learning capability of the model is improved. The application can generate the detection frame with any angle aiming at the garbage target, so that the generated detection frame and the actual position of the object are more accurately covered, and the application is beneficial to the actual application of the model.

Inventors

  • YANG WEIZHI
  • ZHAO XIAOLEI

Assignees

  • 广州新华学院

Dates

Publication Date
20260512
Application Date
20220429

Claims (9)

  1. 1. The image garbage detection method based on YOLOV optimization at any angle is characterized by comprising the following steps of: S1, acquiring a multi-source garbage image dataset through shooting and acquisition and a crawler, and performing data annotation, wherein the data annotation comprises clockwise angle values of a long side and an abscissa of an object frame, the angle value range is [0 degrees, 180 degrees ], and a label pattern is optimized through a label smoothing algorithm; s2, carrying out data enhancement and data expansion processing on the obtained garbage image data set to obtain an enhanced data set; s3, modifying a network detection head of YOLOV, adding an angle prediction convolution network branch, wherein the angle prediction convolution network branch is used for predicting the angle of an object in an image, and optimizing a feature extraction network, a feature connection network and a loss function of YOLOV5 to obtain a YOLOV5 optimization model; S4, inputting the enhancement data set containing the data labels into the YOLOV optimization model for training and learning to obtain a trained YOLOV5 optimization model; s5, detecting and identifying garbage at any angle by using a trained YOLOV optimization model and predicting the angle of the garbage; step S1, when the clockwise angle value of the long side and the abscissa of the object frame is marked, the label is processed by adopting an angle smoothing method: where x represents an angle label value, b is a constant, a is a peak value of a smoothing function, and b is a constant for controlling a peak position of angle smoothing, And The length of the long side and the length of the short side of the object frame are represented, the angle label of the object frame with the length-width ratio smaller than 5 is not processed, the highest value of g (x) is obtained at the position of the true angle label value of the sample after being processed by Gaussian function processing, the g (x) is reduced in a certain neighbor range, the value of the g (x) tends to 0 when the g (x) exceeds the neighbor range, and the neighbor range and the smooth amplitude are controlled by the value of the length-width ratio and do not exceed 8 at the maximum.
  2. 2. The method for detecting image garbage at any angle based on YOLOV optimization as set forth in claim 1, wherein the data annotation in step S1 further includes an object category, an object center coordinate, an object frame long side length, and an object frame short side length in the image.
  3. 3. The method for detecting the image garbage at any angle based on YOLOV optimization according to claim 1, wherein in step S2, the acquired garbage image dataset is subjected to data enhancement and data expansion, specifically: and carrying out data expansion and diversification on the obtained garbage image data set through angle transformation and overturning, and processing the garbage image by using 'salt and pepper noise'.
  4. 4. The method for detecting image garbage at any angle based on YOLOV optimization according to claim 1, wherein the network detection head of YOLOV is modified in step S3, and angle prediction convolution network branches are added, specifically: Adding convolutional neural network branches into 3 network detection heads of YOLOV, wherein the number of convolutional kernel channels of the added convolutional neural network is an angle class number, namely 180, the modified size of each convolutional neural network is (256, na (nc+5+n_angle), 1), (512, na (nc+5+n_angle), 1), (1024, na (nc+5+n_angle), 1), wherein na is the number of detection frames output by each detection head, nc represents the number of detected classes, and n_angle represents the predicted angle class.
  5. 5. The method for detecting image garbage at any angle based on YOLOV optimization according to claim 1, wherein the feature extraction network of YOLOV5 is optimized in step S3, specifically: the method comprises the steps of optimizing BottleneckCSP modules in a feature extraction network, wherein BottleneckCSP modules are obtained by stacking and connecting Bottleneck modules, and the steps of optimizing BottleneckCSP modules are specifically as follows: And converging the characteristic layer of the Bottleneck module in the middle layer of the BottleneckCSP module with the characteristic layer of the Bottleneck module in the last layer to obtain an optimized BottleneckCSP module, which is named as an HD-BottleneckCSP module.
  6. 6. The method for detecting image garbage at any angle based on YOLOV optimization according to claim 1, wherein the feature connection network of YOLOV5 is optimized in step S3, specifically: the connection between the network detection heads in YOLOV adds a feature map in the shallow network and a CA-Attention module based on a coordinate attention mechanism.
  7. 7. The method for detecting image garbage at any angle based on YOLOV optimization according to claim 1, wherein the loss function of YOLOV5 is optimized in step S3, specifically: The target frame regression loss calculation formula: confidence loss function and category loss function calculation formula: Wherein, the And The jth prediction box representing the ith bin corresponds to the presence or absence of an object, Is a weight coefficient; And The true value and the predicted value of the target are shown whether to exist, and the values are 0 or 1; And Respectively representing the true value and the prediction result of the target class; Angle loss function: wherein a represents an angle label, angles represents a range of values of angles from 0 DEG to 180 DEG, The method is characterized in that the angle label a is firstly processed by g (x) smoothing function and converted into the probability of angle value, Then the probability of being predicted as angle a is represented; Weight values are set for the four loss functions respectively, and a final loss function calculation formula is obtained: 。
  8. 8. The method for detecting image garbage at any angle based on YOLOV optimization according to claim 1, wherein before inputting the enhancement data set containing the data label to the YOLOV5 optimization model for training and learning in step S3, the following steps are further performed: Extracting a Backbone network part of the YOLOV optimization model, establishing a classification model, pre-training on a large-scale garbage image classification data set without a labeling frame to obtain pre-training weights, and loading the pre-training weights into the Backbone network part of the YOLOV optimization model when the YOLOV optimization model is trained.
  9. 9. The method for detecting image garbage at any angle based on YOLOV optimization according to claim 1, wherein the specific steps of step S4 are as follows: Setting up YOLOV an environment required by model training, loading an enhanced data set containing data labels into a model for training, wherein 60% of the enhanced data set is used as a training set, 20% of the enhanced data set is used as a verification set, and 20% of the enhanced data set is used as a test set, and simultaneously, carrying out layered sampling in the data dividing process, namely, the proportion of each category of data on the training set, the verification set and the test set is similar; setting super parameters of network model training, including model learning rate, data set size of each training, maximum training round number, weight attenuation coefficient, preheating learning momentum and preheating initial learning rate; after training and learning, a trained YOLOV optimization model is obtained.

Description

YOLOV5 optimization-based arbitrary-angle image garbage detection method Technical Field The invention relates to the field of computer vision and intelligent garbage detection and sorting, in particular to a YOLOV-optimization-based arbitrary-angle image garbage detection method. Background At present, garbage cleaning and sorting are mainly carried out manually, and a large amount of bacteria exist in garbage, so that the health of operators is greatly influenced. In recent years, image intelligent recognition and artificial intelligent technology are rapidly developed, an image detection technology is applied to garbage type recognition and position recognition, and then a robot hand or a robot is combined, so that intelligent automatic sorting of garbage objects is completed, garbage cleaning efficiency is greatly improved, and labor cost and urban pollution are reduced. The prior art discloses a garbage detection classification and inference method based on deep learning, and relates to the technical field of computer image processing. And realizing the technology of garbage position detection, garbage type classification and garbage physical property inference according to the garbage pictures in the picture dataset of garbage target detection by using a combined deep learning, convolution neural network and inference mapping method. But this solution can only produce a standard angle rubbish detection box, either horizontal or vertical. In an actual natural scene, the angles of the garbage targets are various and complex. If only a detection frame with a standard angle can be generated, when the angle exists between the garbage target in the image and the horizontal direction, the detection frame can not accurately reflect the specific position and direction of the garbage object, and the accurate recognition and sorting of the robot hand are not facilitated. Meanwhile, the existing detection network has common performance and detection precision, and a certain optimization space exists. Disclosure of Invention The invention provides a YOLOV-optimization-based arbitrary angle image garbage detection method, which is used for realizing the detection of arbitrary angles of garbage object images in a natural scene. In order to solve the technical problems, the technical scheme of the invention is as follows: A YOLOV-optimization-based arbitrary-angle image garbage detection method comprises the following steps: S1, acquiring a multi-source garbage image dataset through shooting and acquisition, reptiles and the like, and performing data annotation, wherein the data annotation comprises an angle value clockwise between a long side of an object frame and an abscissa, the angle value range is [0 degrees, 180 degrees ], and the label style is optimized through a label smoothing algorithm, so that the model training effect is improved; s2, carrying out data enhancement and data expansion processing on the obtained garbage image data set to obtain an enhanced data set; s3, modifying a network detection head of YOLOV, adding an angle prediction convolution network branch, wherein the angle prediction convolution network branch is used for predicting the angle of an object in an image, and optimizing a feature extraction network, a feature connection network and a loss function of YOLOV5 to obtain a YOLOV5 optimization model; S4, inputting the enhancement data set containing the data labels into the YOLOV optimization model for training and learning to obtain a trained YOLOV5 optimization model; and S5, detecting and identifying garbage at any angle by using the trained YOLOV optimization model and predicting the angle of the garbage. Preferably, in step S1, a multi-source garbage image dataset is acquired through shooting acquisition, crawler, etc. Preferably, in the step S1, when the clockwise angle value between the long side and the abscissa of the object frame is marked, for the garbage category with a larger aspect ratio, an angle smoothing method is adopted to process the label: Wherein x is a constant value of an angle label, b is a constant value for controlling the peak position of angle smoothing, a is a peak value of a smoothing function, l and s are lengths of long sides and short sides of an object frame, the angle label of the object frame with the length-width ratio smaller than 5 is not processed, and g (x) is obtained to be the highest value at the position of a sample true angle label value after being processed by a Gaussian function and is reduced in a certain neighbor range, the value of the neighbor range tends to be 0 when the value exceeds the neighbor range, and the smoothing amplitude is controlled by the value of the length-width ratio and is not more than 8 at the maximum. Preferably, the data annotation in step S1 further includes an object category, an object center coordinate, a length of a long side of the object frame, and a length of a short side of the object frame in the ima