YOLO model garbage detection method, system, equipment, product and medium
Through the garbage detection method of the YOLO model, the problems of high computational complexity and poor detection of small objects in the prior art are solved, and efficient and accurate garbage detection is achieved.
Patent Information
- Application Number
- CN202510090618.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2045-01-21
AI Technical Summary
When existing garbage detection technology deals with garbage with irregular shapes, diverse colors and complex backgrounds, it has high computational complexity, time-consuming training and poor detection effect on small targets.
The garbage detection method of the YOLO model is adopted. By obtaining the detection data set and reclassifying it, a feature extraction convolution module, a SAC-Net module and a bounding box loss module are constructed to form an initial classification model, and the target classification model is obtained through training to achieve garbage detection.
It realizes the completion of object detection and recognition in a single step, meets the requirements of accuracy and speed, improves detection efficiency and accuracy, and reduces the computational complexity.
Smart Images

Figure CN119540782B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a YOLO model garbage detection method, system, device, product and medium. Background Art
[0002] With the acceleration of urbanization, garbage dumping areas are spread all over the world, posing a certain degree of threat to the ecological environment. Therefore, the need for accurate and real-time detection of garbage has become increasingly prominent, which has put forward higher requirements for garbage detection technology. In recent years, with the rapid development of computer vision technology, it has had a profound impact in various fields. As a key component, the research on target detection technology has also achieved rapid development. Target detection technology can automatically identify and locate specific objects in images, and can realize the automatic identification, location and quantity statistics of wild garbage.
[0003] The process of garbage detection faces some unique challenges, such as irregular shapes, diverse colors, and complex backgrounds. The methods currently used include single-stage algorithms and multi-stage algorithms. The multi-stage algorithm first generates candidate boxes through selective search, and then performs classification prediction based on the candidate boxes. Although it has good accuracy, it needs to generate candidate boxes and classification networks separately, so its computational complexity is high, training is time-consuming, and the detection effect on small targets is not good. The single-stage target detection algorithm has the advantages of being simple, direct, and easy to implement. However, it also has some disadvantages and shortcomings. First of all, it is easy to have false detections and missed detections in the detection of small targets. Compared with other algorithms, its positioning accuracy of targets is also relatively low. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems existing in the related art. To this end, the present invention provides a garbage detection method, system, device, product and medium of the YOLO model to realize automatic identification, detection, location and classification of garbage in an image.
[0005] The present invention provides a garbage detection method of a YOLO model, comprising:
[0006] S1: Obtain a test data set, and reclassify the test data set to obtain a classification set;
[0007] S2: Select a backbone network, construct a Conv convolution module, a spatial feature extraction module and a channel feature extraction module, construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and embed the feature extraction convolution module into the backbone network;
[0008] S3: Select a neck network, construct a first feature map module and a second feature map module, construct a SAC-Net module through the first feature map module and the second feature map module, embed the SAC-Net module into the neck network, and connect the neck network to the backbone network;
[0009] S4: constructing a bounding box loss module including an EIOU loss function, constructing a detection head through the bounding box loss module, and connecting the detection head to the neck network; constructing an initial classification model including the backbone network, the neck network and the detection head;
[0010] S5: configuring the initial classification model according to the classification set, training the initial classification model through the classification set to obtain a target classification model, and performing garbage detection through the target classification model.
[0011] According to the garbage detection method of the YOLO model provided by the present invention, step S1 further includes:
[0012] S11: Acquire the detection data set, analyze and summarize the target features in the detection data set, and obtain similar target features;
[0013] S12: Reclassify the detection data set according to the similar target features to obtain a classification set.
[0014] According to the garbage detection method of the YOLO model provided by the present invention, step S2 further includes:
[0015] S21: Determine the accuracy requirement, and select the backbone network according to the accuracy requirement;
[0016] S22: construct the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module; wherein the Conv convolution module, the spatial feature extraction module and the channel feature extraction module are connected in sequence; the Conv convolution module performs one Conv convolution and multiple Conv convolutions respectively; the spatial feature extraction module suppresses spatial redundancy by performing standardization, normalization and separation reconstruction in sequence, and the spatial feature extraction module extracts spatial features through point-by-point convolution, grouped convolution pooling and Softmax transformation;
[0017] S23: Determine a backbone network structure, and embed the feature extraction convolution module into the backbone network according to the backbone network structure.
[0018] According to the garbage detection method of the YOLO model provided by the present invention, step S3 further includes:
[0019] S31: determining the semantic information richness requirement and the position information accuracy requirement, selecting the neck network according to the semantic information richness requirement and the position information accuracy requirement; constructing the first feature map module and the second feature map module;
[0020] S32: constructing the SAC-Net module through the first feature map module and the second feature map module, wherein the input end of the first feature map module is connected to the input end of the second feature map module, and the output end of the first feature map module is connected to the output end of the second feature map module; embedding the SAC-Net module into the neck network; the first feature map module includes global average pooling and sigmoid function mapping, and the second feature map module includes standardization and sigmoid function mapping;
[0021] S33: Determine the backbone network image size of each layer in the backbone network and the neck network image size of each layer in the neck network, and connect the neck network to the backbone network according to the backbone network image size and the neck network image size.
[0022] According to the garbage detection method of the YOLO model provided by the present invention, step S4 further includes:
[0023] S41: construct an EIOU loss function, and construct a bounding box loss module through the EIOU loss function;
[0024] S42: constructing the detection head through the bounding box loss module, and connecting the detection head to the neck network according to the structure of the neck network;
[0025] S43: Select a classification model architecture, and construct the initial classification model including the backbone network, the neck network and the detection head according to the classification model architecture.
[0026] According to the garbage detection method of the YOLO model provided by the present invention, the classification model architecture is a YOLOv5 model architecture.
[0027] The present invention also provides a garbage detection system of the YOLO model, including:
[0028] Classification set module: used to obtain a test data set, reclassify the test data set, and obtain a classification set;
[0029] Backbone network module: used to select a backbone network, construct a Conv convolution module, a spatial feature extraction module and a channel feature extraction module, construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and embed the feature extraction convolution module into the backbone network;
[0030] Neck network module: used to select a neck network, construct a first feature map module and a second feature map module, construct a SAC-Net module through the first feature map module and the second feature map module, embed the SAC-Net module into the neck network, and connect the neck network to the backbone network;
[0031] Detection head module: used to construct a bounding box loss module including an EIOU loss function, construct a detection head through the bounding box loss module, and connect the detection head to the neck network; construct an initial classification model including the backbone network, the neck network and the detection head;
[0032] Target classification model module: used to configure the initial classification model according to the classification set, train the initial classification model through the classification set to obtain a target classification model, and perform garbage detection through the target classification model.
[0033] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the garbage detection method of the YOLO model as described above are implemented.
[0034] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the garbage detection method of the YOLO model as described in any one of the above.
[0035] The present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can perform the steps of the garbage detection method of the YOLO model as described in any one of the above-mentioned methods.
[0036] The above one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:
[0037] The garbage detection method, system, device, product and medium of the YOLO model provided by the present invention converts the garbage detection task into a classification problem, directly maps the input image to the category, position and confidence score of the target through a neural network, and completes the detection and identification of the target in a single step, while meeting the requirements of accuracy and speed. In addition, the present invention simplifies the classification of garbage, effectively improves the detection efficiency and accuracy, improves the feature extraction capability of the network through a feature extraction convolution module, and reduces the computational complexity.
[0038] In addition, the present invention enhances the robustness of the detection of target size and position through the SAC-Net module, and finally uses the bounding box loss module to improve the detection head, thereby improving the model's adaptability to changes in target shape. The various modules of the network model cooperate with each other to achieve a significant improvement in the accuracy of garbage target detection while almost no increase in the number of model parameters, thereby improving the detection performance of garbage in images. The improved network model shows high adaptability on the garbage detection dataset. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 It is a flowchart of the garbage detection method of the YOLO model provided by the present invention.
[0041] Figure 2 It is a schematic diagram of a classification set of the garbage detection method of the YOLO model provided by the present invention.
[0042] Figure 3 It is a structural schematic diagram of the garbage detection system of the YOLO model provided by the present invention.
[0043] Figure 4 It is a structural schematic diagram of a garbage detection device of the YOLO model provided by the present invention.
[0044] Reference numerals:
[0045] 100, classification set module; 200, backbone network module; 300, neck network module; 400, detection head module; 500, target classification model module; 810, processor; 820, communication interface; 830, memory; 840, communication bus. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme in the present invention will be clearly and completely described below. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but cannot be used to limit the scope of the present invention.
[0047] In the description of the embodiments of the present invention, it should be noted that the terms “first”, “second” and “third” are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0048] In the description of the embodiments of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "connected" and "connection" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in the embodiments of the present invention can be understood according to specific circumstances.
[0049] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0050] Combine the following Figures 1 to 4 Describing embodiments of the present invention:
[0051] Figure 1 A flow chart of the garbage detection method of the YOLO model provided by the present invention, wherein S1 is to obtain a detection data set, and reclassify the detection data set to obtain a classification set by reclassification; S2 is to select a backbone network, build a feature extraction convolution module and embed the feature extraction convolution module into the backbone network; S3 is to build a SAC-Net module, and obtain a neck network by embedding the SAC-Net module into a neck network; S4 is to build a detection head including an EIOU loss function, and to build an initial classification model; S5 is to train the initial classification model to obtain a target classification model.
[0052] The present invention provides a garbage detection method of a YOLO model, comprising:
[0053] S1: Acquire a test data set, and reclassify the test data set to obtain a classification set;
[0054] Furthermore, the purpose of this stage is to reclassify the original detection data set that is too redundant and has a large number of repeated features, so as to obtain a more concise classification set that can effectively improve the classification and detection efficiency of the classification model, and provide materials for training the target classification model; wherein step S1 further includes:
[0055] S11: Acquire the detection data set, analyze and summarize the target features in the detection data set, and obtain similar target features;
[0056] S12: Reclassify the detection data set according to the similar target features to obtain a classification set.
[0057] With respect to the above steps, the specific implementation methods in this embodiment are as follows:
[0058] First, we obtain an existing detection dataset. Here, the detection dataset selected is the TACO dataset, which contains 1,500 images and 4,784 samples, including 60 categories in total and divided into 28 major categories. However, there are a large number of similar features between many categories in the TACO dataset, that is, similar target features. In addition, the background environment in which the garbage is located is diverse, so these similar target features will interfere with the accuracy of classifying the garbage in the image. For example, for the classification model, it is difficult to correctly classify glass bottles and plastic bottles with similar features in many cases where the lighting is complex or the background is cluttered. In addition, overly detailed classification is not necessary in many occasions. For example, when counting the distribution of garbage in the venue to arrange a cleaning plan, there is no need to worry about whether the discarded bottles are plastic bottles or glass bottles.
[0059] We then analyze and summarize the target features in the test data set to obtain similar target features. For example, plastic bottles and glass bottles share a large number of similar target features related to the appearance of the bottles. Then, we reclassify the test data set based on the similar target features to obtain a classification set. Here, the garbage types and sample size of each type in the reclassified classification set are as follows: Figure 2 As shown, in this embodiment, the 60 types of garbage in the original detection data set are reclassified into 8 types of garbage, including bottles, bottle caps, cans, cups, plastic bags, straws, boxes and others. In the actual application process, the types of garbage included in the classification set can be flexibly set according to the needs of the on-site environment.
[0060] S2: Select a backbone network, construct a Conv convolution module, a spatial feature extraction module and a channel feature extraction module, construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and embed the feature extraction convolution module into the backbone network;
[0061] Furthermore, the purpose of this stage is to select a suitable backbone network according to the accuracy requirements and construct a feature extraction convolution module, so that the backbone network can extract richer features through the feature extraction module, and improve the accuracy and operation speed of the backbone network feature extraction, wherein step S2 further includes:
[0062] S21: Determine the accuracy requirement, and select the backbone network according to the accuracy requirement;
[0063] S22: construct the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module; wherein the Conv convolution module, the spatial feature extraction module and the channel feature extraction module are connected in sequence; the Conv convolution module performs one Conv convolution and multiple Conv convolutions respectively; the spatial feature extraction module suppresses spatial redundancy by performing standardization, normalization and separation reconstruction in sequence, and the spatial feature extraction module extracts spatial features through point-by-point convolution, grouped convolution pooling and Softmax transformation;
[0064] S23: Determine a backbone network structure, and embed the feature extraction convolution module into the backbone network according to the backbone network structure.
[0065] With respect to the above steps, the specific implementation methods in this embodiment are as follows:
[0066] First, determine the accuracy requirements based on actual needs and the characteristics of the classification model. Here, since the classification in the classification set is more concise, it is necessary to classify and identify garbage with higher accuracy, and the accuracy requirements are higher. Therefore, here we choose CSPDarknet53 as the backbone network, which has high computing power requirements but also high classification accuracy. In addition, since we have simplified the classification, the complexity of the classification model will also be reduced. Therefore, although CSPDarknet53 has high computing power requirements, the computing power requirements of the target classification model obtained in the end will not be increased.
[0067] Then, a feature extraction convolution module is constructed, and the Conv convolution module, the spatial feature extraction module and the channel feature extraction module in the feature extraction convolution module are connected in sequence. Among them, the Conv convolution module includes a first Conv convolution module, a second Conv convolution module and a fusion module. The input end of the first Conv convolution module is connected to the input end of the second Conv convolution module, the output end of the first Conv convolution module and the output end of the second Conv convolution module are connected to the fusion module, and the input image information is simultaneously input into the first Conv convolution module and the second Conv convolution module. Among them, only one Conv convolution is performed in the first Conv convolution module, thereby retaining the relatively rich original feature information in the input image; while the second Conv convolution module performs multiple Conv convolutions, and multiple Conv convolutions can extract relatively rich spatial feature information at the cost of sacrificing the original features and causing the loss of small targets, thereby improving the positioning accuracy. Subsequently, the feature information extracted from the first Conv convolution module and the second Conv convolution module is fused in the fusion module to obtain the first feature information having both the original feature information and the spatial feature information.
[0068] Then, the first feature information is input into the spatial feature extraction module. Here, the spatial feature extraction module can suppress spatial redundancy by separating and reconstructing. Specifically, the input first feature information X is first standardized to obtain the standardized first feature information :
[0069]
[0070] Among them, GN() is standardized by the standardization function, is the first transformation coefficient, which is a trainable parameter assigned by the backbone network and used to characterize the richness of spatial information. is the mean value of the pixels in the first feature information, and the pixel standard deviation is the standard deviation of the pixels in the first feature information, It is a user-defined stability constant used to ensure the stability of calculation and avoid infinite values. is the second transformation coefficient, which is also assigned by the backbone network and is trainable.
[0071] Then, the first transform coefficient is normalized to obtain the normalized first transform coefficient :
[0072]
[0073] Where C is the number of channels in the first feature information, For the The first transform coefficient in the channels, is the first transform coefficient in the i-th channel. Then the first transform coefficient is normalized by the sigmoid function The values are mapped to the range (0, 1) and filtered by the threshold filter function:
[0074]
[0075] in, () represents the sigmoid function, Gate() represents the threshold filter function, and the threshold of the threshold filter function is set to 0.5, that is, the value above the threshold is assigned to 1, and the value below the threshold is assigned to 0, and W represents the filtering result. Then separate and reconstruct:
[0076]
[0077] The information weight can be obtained by the ratio of the mapping results above and below the threshold in the filtering results of the threshold filtering function. and non-information weights , the information weight and non-information weights Multiplying the first feature information in turn can obtain the information weighted feature information and non-informative weighted feature information ,here Indicates the multiplication of feature information. Then weight the feature information Split to get the first sub-information And the second sub-information , weighted feature information for non-information Split to get the third sub-information And the fourth child information In this embodiment, the first sub-information, the second sub-information, the third sub-information and the fourth sub-information are then cross-reconstructed to obtain the first cross-feature information. and the second cross feature information ,here Indicates the addition of feature information; finally, the first cross feature information and the second cross feature information are combined to obtain the spatial refinement feature information ,here Indicates merging, spatially refined feature information reduces feature redundancy in space, and the spatially refined feature information has richer feature information.
[0078] Then, the spatially refined feature information is input into the channel feature extraction module, which includes an upper branch, a lower branch, a pooling module, and a Softmax transformation module, and the upper branch and the lower branch are in parallel. The spatially refined feature information is input into the upper branch and the lower branch respectively. In the upper branch, the spatially refined feature information passes through a 1x1 convolution kernel and becomes the upper branch convolution information. Then, the upper branch convolution information is subjected to point-by-point convolution and group convolution respectively, and the first upper branch convolution information and the second upper branch convolution information are obtained respectively; then, the first upper branch convolution information and the second upper branch convolution information are summed to obtain the target upper branch convolution information. .
[0079] In the lower branch, the spatially refined feature information passes through a 1x1 convolution kernel and becomes the lower branch convolution information. Then, the lower branch convolution information is convolved point by point to obtain the lower branch point by point convolution information. The lower branch point by point convolution information is concatenated with the lower branch convolution information to obtain the target lower branch convolution information. Then, the target upper branch convolution information and the target lower branch convolution information are input into the pooling module respectively. The pooling module performs pooling on the target upper branch convolution information and the target lower branch convolution information, and obtains the upper branch pooling information and the lower branch pooling information respectively. Then, the upper branch pooling information and the lower branch pooling information are input into the Softmax transformation module. The Softmax transformation module performs Softmax transformation on the upper branch pooling information and the upper branch pooling information, and obtains the upper branch weight vector respectively. and the weight vector of the lower branch Then, the channel refinement feature information Y output by the feature extraction convolution module can be obtained by weighted addition:
[0080]
[0081] Finally, the backbone network structure is determined, and the feature extraction convolution module is embedded into the backbone network according to the backbone network structure. In this embodiment, the embedding position of the feature extraction convolution module is after the conv module of the backbone network. In this application, since the garbage is reclassified and the types of garbage are simplified, the differences between the new types of garbage are large, so this application needs to further improve the accuracy of garbage classification, so as to avoid garbage being classified into wrong types with large differences.
[0082] Generally speaking, improving accuracy will inevitably increase computing time and consumption of computing resources. However, in the feature extraction convolution module, the spatial feature extraction module suppresses spatial redundancy through the separation and reconstruction method, and the channel feature extraction module reduces channel redundancy through the transformation and fusion method. This allows the feature extraction convolution module to reduce the consumption of computing resources by suppressing spatial redundancy and channel redundancy. The Conv convolution module can obtain the first feature information that has both original feature information and spatial feature information, thereby improving the classification accuracy and positioning accuracy of the classification model, and the channel feature extraction module and the spatial feature extraction module can also further strengthen the first feature information, so that the classification model can more accurately capture the key features of the garbage such as shape, color, texture, etc., while also suppressing redundant information in the background and reducing the computational burden.
[0083] S3: Select a neck network, construct a first feature map module and a second feature map module, construct a SAC-Net (Soft Actor Critic-Net) module through the first feature map module and the second feature map module, embed the SAC-Net module into the neck network, and connect the neck network to the backbone network;
[0084] Furthermore, the purpose of this stage is to select the neck network, construct the SAC-Net module and improve the neck network through the SAC-Net module, and connect the improved neck network to the backbone network, wherein step S3 further includes:
[0085] S31: determining the semantic information richness requirement and the position information accuracy requirement, selecting the neck network according to the semantic information richness requirement and the position information accuracy requirement; constructing the first feature map module and the second feature map module;
[0086] S32: constructing the SAC-Net module through the first feature map module and the second feature map module, wherein the input end of the first feature map module is connected to the input end of the second feature map module, and the output end of the first feature map module is connected to the output end of the second feature map module; embedding the SAC-Net module into the neck network; the first feature map module includes global average pooling and sigmoid function mapping, and the second feature map module includes standardization and sigmoid function mapping;
[0087] S33: Determine the backbone network image size of each layer in the backbone network and the neck network image size of each layer in the neck network, and connect the neck network to the backbone network according to the backbone network image size and the neck network image size.
[0088] First, determine the semantic information richness requirements and the location information accuracy requirements, and select the neck network based on the semantic information richness requirements and the location information accuracy requirements; here, because the requirements for the richness of semantic information and the accuracy of location information in this application are relatively high, FPN (Feature Pyramid Networks) and PAN (Path Aggregation Network) are selected to connect to form the neck network, that is, a top-down + bottom-up feature extraction method, so as to obtain the advantages of FPN and PAN at the same time, and meet the semantic information richness requirements and location information accuracy requirements at the same time.
[0089] Next, a SAC-Net module is constructed. SA-Net, as a hybrid attention mechanism, can achieve mapping in two dimensions, channel and space. The SAC-Net module includes a first feature map module and a second feature map module, wherein the input end of the first feature map module is connected to the input end of the second feature map module, and the output end of the first feature map module is connected to the output end of the second feature map module, that is, the first feature map module and the second feature map module are in a parallel relationship. After performing Conv convolution on the image information input to the SAC-Net module to extract features and obtain the second feature information, the second feature information is respectively input into the first feature map module and the second feature map module, and the second feature information is grouped according to the channel dimension in the first feature map module and the second feature map module, and divided into multiple sub-features, and multiple first channel sub-features are obtained in turn. and multiple second channel sub-features .
[0090] Subsequently, in the first feature map module, all first channel sub-features are firstly globally averaged pooled to obtain the pooled first channel sub-feature s:
[0091]
[0092] Where H is the height of the first channel sub-feature, W is the width of the first channel sub-feature, is the height of the first channel sub-feature pixels, the width of the first channel sub-feature The first channel sub-feature of the pooled first channel sub-feature is then mapped through the sigmoid function and multiplied with the first channel sub-feature to obtain the target first channel sub-feature :
[0093]
[0094] in, is the first mapping parameter and , where G represents the number of groups, represents the number of channels in the SAC-Net module, represents the set of real numbers, is the second mapping parameter and , the first mapping parameter and the second mapping parameter are given by the neck network and are trainable.
[0095] At the same time, in the second feature map module, all second channel sub-features are first standardized, then mapped by the sigmoid function and multiplied with the second channel sub-features to obtain the target second channel sub-features :
[0096]
[0097] in, is the third mapping parameter and , is the fourth mapping parameter and GN() is standardized by the standardization function. The third and fourth mapping parameters are assigned by the neck network and are trainable. Then, the target first channel sub-feature and the target second channel sub-feature are concatenated to obtain the target feature information. , the size of the target feature information remains unchanged and the interaction between the target first channel sub-feature and the target second channel sub-feature can be guaranteed. The SAC-Net module is embedded in the neck network. In this embodiment, the embedding position of the SAC-Net module is between the C3 module of the neck network and the splicing module of the next output branch.
[0098] Finally, determine the image size of the backbone network of each layer in the backbone network and the image size of the neck network of each layer in the neck network, and connect the neck network to the backbone network according to the image size of the backbone network and the image size of the neck network. In this embodiment, the image size of the backbone network and the image size of the neck network selected for connection are both 128×80×80, 256×40×40, and 512×20×20. According to the principle of equal image size, the layers corresponding to the above three groups of data in the backbone network and the layers corresponding to the above three groups of data in the neck network are connected one by one. In the image size, taking 128×80×80 as an example, 128 is the number of channels in the SAC-Net module, the first 80 is the width of the image, and the second 80 is the height of the image. The neck network embedded in the SAC-Net module further allocates different weight information to the space and channel of the feature information, so that the classification model pays more attention to the image area where the garbage target exists, and enhances the robustness of the classification model to the change of object size and position.
[0099] S4: constructing a bounding box loss module including an EIOU loss function, constructing a detection head through the bounding box loss module, and connecting the detection head to the neck network; constructing an initial classification model including the backbone network, the neck network and the detection head;
[0100] Furthermore, the purpose of this stage is to construct a bounding box loss module through the EIOU loss function, construct a detection head through the bounding box loss module, select a classification model architecture and construct an initial classification model according to the classification model architecture, wherein step S4 further includes:
[0101] S41: construct an EIOU loss function, and construct a bounding box loss module through the EIOU loss function;
[0102] S42: constructing the detection head through the bounding box loss module, and connecting the detection head to the neck network according to the structure of the neck network;
[0103] S43: Select a classification model architecture, and construct the initial classification model including the backbone network, the neck network and the detection head according to the classification model architecture.
[0104] First, we construct the EIOU loss function. Here, since the size and position of garbage objects in garbage images vary, and the CIOU loss function usually used in the detection head does not consider the aspect ratio of the prediction box, the EIOU loss function is used to solve the ambiguity of the aspect ratio definition in the CIOU loss function. The expression is:
[0105]
[0106] in, represents the center point of the prediction box, represents the center point of the ground-truth box, () represents the Euclidean distance between two points, is the midpoint of the width of the real box, is the midpoint of the height of the real frame, is the midpoint of the prediction box width, is the midpoint of the height of the prediction box, is the width of the closed area formed by the union of the predicted box and the true box, is the length of the closed area formed by the union of the predicted box and the true box, Represents the area of the closed region formed by the intersection of the predicted box and the true box. Represents the area of the closed region formed by the union of the predicted box and the true box.
[0107] Then, a bounding box loss module is constructed through the EIOU loss function, and a detection head is constructed through the bounding box loss module. The detection head is connected to a suitable position of the neck network according to the structure of the neck network. In this embodiment, the detection head is connected to the output position of the neck network. Finally, a classification model architecture is selected. In this embodiment, the selected classification model architecture is YOLOv5. An initial classification model including a backbone network, a neck network and a detection head is constructed according to the YOLOv5 model architecture.
[0108] S5: configuring the initial classification model according to the classification set, training the initial classification model through the classification set to obtain a target classification model, and performing garbage detection through the target classification model.
[0109] Furthermore, the purpose of this stage is to configure the initial classification model and train the initial classification model to obtain the target classification model. Specifically, firstly, a configuration file is written for the initial classification model according to the classification set so that its internal parameters can adapt to the classification set, then the training and verification paths are replaced with the paths of the classification set, and then the format of the content in the classification set is converted to a format that can match the initial classification model. Then, the initial classification model is started and initialized through the configuration file, and the converted classification set is input into the initial classification model. The initial classification model is trained and iterated through the classification set so that the performance of the initial classification model can reach the expected level, and the target classification model is obtained. The target classification model can realize garbage detection and map images containing garbage to garbage categories, locations and confidence scores.
[0110] The present invention also verifies the effectiveness of the garbage detection method of the YOLO model. Here, the training environment is built using the Ubuntu 20.04.3 operating system, cuda11.3 is implemented through the Python language, the deep learning framework Pytorch 3.9.3 is used to build the classification model, and Python 3.8 is used to compile. In the hardware environment, the CPU is i9-11900 CPU@3.50GHz and the training card is a single RTX 3080Ti. The experimental parameter settings are shown in Table 1.
[0111] Table 1 Experimental parameter settings
[0112]
[0113] After training, the detection effect of the target classification model is compared with other mainstream target detection models. The results are shown in Table 2:
[0114] Table 2 Comparison of detection effects of target classification model and other target detection models
[0115]
[0116] Among them, GFLOPS is the computing requirement of the model. The smaller its value is, the better the real-time performance of the model is. mAP@0.5 is the mAP value when the intersection-over-union loss is 0.5. The calculation method of the category average precision mAP is as follows: First, calculate the precision P and recall R of the target classification model for each category:
[0117]
[0118]
[0119] Among them, TP represents the number of positive samples that are correctly identified, FP represents the number of negative samples that are incorrectly identified; FN represents the number of positive samples that are incorrectly identified. Then, the precision-recall curve of each category is drawn based on the precision and recall rates. , and then calculate the average accuracy of each category through the precision-recall curve of each category:
[0120]
[0121]
[0122] Where N represents the number of categories. () represents the sum, and AP is the area value of the precision-recall curve of each category. It can be seen from the experiment that the present invention has the highest category average accuracy while having a high computing speed, which effectively proves that the present invention can greatly improve the garbage target detection accuracy while almost not increasing the number of model parameters, thereby improving the detection performance of garbage in the image and effectively improving the detection efficiency and accuracy.
[0123] The garbage detection system of the YOLO model provided by the present invention is described below. The garbage detection system of the YOLO model described below and the garbage detection method of the YOLO model described above can correspond to each other.
[0124] Figure 3 The schematic diagram of the structure of the garbage detection system of the YOLO model is shown as follows: Figure 3 As shown, the garbage detection method for executing the YOLO model as described above includes:
[0125] Classification set module 100: used to obtain a detection data set, reclassify the detection data set, and obtain a classification set;
[0126] Backbone network module 200: used to select a backbone network, construct a Conv convolution module, a spatial feature extraction module and a channel feature extraction module, construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and embed the feature extraction convolution module into the backbone network;
[0127] Neck network module 300: used to select a neck network, construct a first feature map module and a second feature map module, construct a SAC-Net module through the first feature map module and the second feature map module, embed the SAC-Net module into the neck network, and connect the neck network to the backbone network;
[0128] Detection head module 400: used to construct a bounding box loss module including an EIOU loss function, construct a detection head through the bounding box loss module, and connect the detection head to the neck network; construct an initial classification model including the backbone network, the neck network and the detection head;
[0129] Target classification model module 500: configured according to the classification set, trained the initial classification model through the classification set to obtain a target classification model, and performed garbage detection through the target classification model.
[0130] on the other hand, Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the garbage detection method of the YOLO model, and the method includes:
[0131] S1: Obtain a test data set, and reclassify the test data set to obtain a classification set;
[0132] S2: Select a backbone network, construct a Conv convolution module, a spatial feature extraction module and a channel feature extraction module, construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and embed the feature extraction convolution module into the backbone network;
[0133] S3: Select a neck network, construct a first feature map module and a second feature map module, construct a SAC-Net module through the first feature map module and the second feature map module, embed the SAC-Net module into the neck network, and connect the neck network to the backbone network;
[0134] S4: constructing a bounding box loss module including an EIOU loss function, constructing a detection head through the bounding box loss module, and connecting the detection head to the neck network; constructing an initial classification model including the backbone network, the neck network and the detection head;
[0135] S5: configuring the initial classification model according to the classification set, training the initial classification model through the classification set to obtain a target classification model, and performing garbage detection through the target classification model.
[0136] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0137] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, the computer can execute the garbage detection method of the YOLO model provided by the above methods, the method comprising:
[0138] S1: Acquire a test data set, and reclassify the test data set to obtain a classification set;
[0139] S2: Select a backbone network, construct a Conv convolution module, a spatial feature extraction module and a channel feature extraction module, construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and embed the feature extraction convolution module into the backbone network;
[0140] S3: Select a neck network, construct a first feature map module and a second feature map module, construct a SAC-Net module through the first feature map module and the second feature map module, embed the SAC-Net module into the neck network, and connect the neck network to the backbone network;
[0141] S4: constructing a bounding box loss module including an EIOU loss function, constructing a detection head through the bounding box loss module, and connecting the detection head to the neck network; constructing an initial classification model including the backbone network, the neck network and the detection head;
[0142] S5: configuring the initial classification model according to the classification set, training the initial classification model through the classification set to obtain a target classification model, and performing garbage detection through the target classification model.
[0143] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the garbage detection method of the YOLO model provided by the above methods, the method comprising:
[0144] S1: Obtain a test data set, and reclassify the test data set to obtain a classification set;
[0145] S2: Select a backbone network, construct a Conv convolution module, a spatial feature extraction module and a channel feature extraction module, construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and embed the feature extraction convolution module into the backbone network;
[0146] S3: Select a neck network, construct a first feature map module and a second feature map module, construct a SAC-Net module through the first feature map module and the second feature map module, embed the SAC-Net module into the neck network, and connect the neck network to the backbone network;
[0147] S4: constructing a bounding box loss module including an EIOU loss function, constructing a detection head through the bounding box loss module, and connecting the detection head to the neck network; constructing an initial classification model including the backbone network, the neck network and the detection head;
[0148] S5: configuring the initial classification model according to the classification set, training the initial classification model through the classification set to obtain a target classification model, and performing garbage detection through the target classification model.
[0149] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0150] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. The garbage detection method of the YOLO model is characterized by: include: S1: Obtain a test data set, and reclassify the test data set to obtain a classification set; S2: Select a backbone network, construct a Conv convolution module, a spatial feature extraction module and a channel feature extraction module, construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and embed the feature extraction convolution module into the backbone network; S3: Select a neck network, construct a first feature map module and a second feature map module, construct a SAC-Net module through the first feature map module and the second feature map module, embed the SAC-Net module into the neck network, and connect the neck network to the backbone network; S4: constructing a bounding box loss module including an EIOU loss function, constructing a detection head through the bounding box loss module, and connecting the detection head to the neck network; constructing an initial classification model including the backbone network, the neck network and the detection head; S5: configuring the initial classification model according to the classification set, training the initial classification model through the classification set to obtain a target classification model, and performing garbage detection through the target classification model.
2. The garbage detection method of the YOLO model according to claim 1, characterized in that: Step S1 further comprises: S11: Acquire the detection data set, analyze and summarize the target features in the detection data set, and obtain similar target features; S12: Reclassify the detection data set according to the similar target features to obtain a classification set.
3. The garbage detection method of the YOLO model according to claim 1, characterized in that: Step S2 further comprises: S21: Determine the accuracy requirement, and select the backbone network according to the accuracy requirement; S22: construct the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module; wherein the Conv convolution module, the spatial feature extraction module and the channel feature extraction module are connected in sequence; the Conv convolution module performs one Conv convolution and multiple Conv convolutions respectively; the spatial feature extraction module suppresses spatial redundancy by performing standardization, normalization and separation reconstruction in sequence, and the spatial feature extraction module extracts spatial features through point-by-point convolution, grouped convolution pooling and Softmax transformation; S23: Determine a backbone network structure, and embed the feature extraction convolution module into the backbone network according to the backbone network structure.
4. The garbage detection method of the YOLO model according to claim 1, characterized in that: Step S3 further comprises: S31: determining the semantic information richness requirement and the position information accuracy requirement, selecting the neck network according to the semantic information richness requirement and the position information accuracy requirement; constructing the first feature map module and the second feature map module; S32: constructing the SAC-Net module through the first feature map module and the second feature map module, wherein the input end of the first feature map module is connected to the input end of the second feature map module, and the output end of the first feature map module is connected to the output end of the second feature map module; embedding the SAC-Net module into the neck network; the first feature map module includes global average pooling and sigmoid function mapping, and the second feature map module includes standardization and sigmoid function mapping; S33: Determine the backbone network image size of each layer in the backbone network and the neck network image size of each layer in the neck network, and connect the neck network to the backbone network according to the backbone network image size and the neck network image size.
5. The garbage detection method of the YOLO model according to claim 1, characterized in that: Step S4 further comprises: S41: construct an EIOU loss function, and construct a bounding box loss module through the EIOU loss function; S42: constructing the detection head through the bounding box loss module, and connecting the detection head to the neck network according to the structure of the neck network; S43: Select a classification model architecture, and construct the initial classification model including the backbone network, the neck network and the detection head according to the classification model architecture.
6. The garbage detection method of the YOLO model according to claim 5, characterized in that: The classification model architecture is the YOLOv5 model architecture.
7. A YOLO model garbage detection system, used to execute the YOLO model garbage detection method according to any one of claims 1 to 6, characterized in that: include: Classification set module: used to obtain a test data set, reclassify the test data set, and obtain a classification set; Backbone network module: used to select a backbone network, construct a Conv convolution module, a spatial feature extraction module and a channel feature extraction module, construct a feature extraction convolution module through the Conv convolution module, the spatial feature extraction module and the channel feature extraction module, and embed the feature extraction convolution module into the backbone network; Neck network module: used to select a neck network, construct a first feature map module and a second feature map module, construct a SAC-Net module through the first feature map module and the second feature map module, embed the SAC-Net module into the neck network, and connect the neck network to the backbone network; Detection head module: used to construct a bounding box loss module including an EIOU loss function, construct a detection head through the bounding box loss module, and connect the detection head to the neck network; construct an initial classification model including the backbone network, the neck network and the detection head; Target classification model module: used to configure the initial classification model according to the classification set, train the initial classification model through the classification set to obtain a target classification model, and perform garbage detection through the target classification model.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the garbage detection method of the YOLO model as described in any one of claims 1 to 6 are implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the garbage detection method of the YOLO model as described in any one of claims 1 to 6 are implemented.
10. A computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, characterized in that: When the program instructions are executed by a computer, the computer can perform the steps of the garbage detection method of the YOLO model as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Small target floating garbage detection method based on improved YOLOv7 model
CN117292313A
Low-illumination target detection method based on MSFAF-Net
CN117456330A