A garbage detection method, device and related medium based on scene attention

By building a garbage detection network based on scene attention, the problem of high false alarm rate in traditional methods in garbage detection is solved, and higher detection accuracy and more accurate garbage status judgment are achieved.

CN115035474BActive Publication Date: 2025-03-14WUHAN WANWUYUN DIGITAL OPERATION CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210705842.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-21
Publication Date
2025-03-14
Estimated Expiration
2042-06-21

AI Technical Summary

Technical Problem

Traditional target detection methods have a large number of false positives in garbage detection, making it difficult to accurately judge the type of garbage and the garbage status in the scene.

Method used

A garbage detection method based on scene attention is adopted, and historical garbage images are acquired and marked. A scene understanding object detection network is built with the improved Yolov5 network and scene attention mechanism. Multi-objective training is used for outputting scene confidence as the garbage detection result.

Benefits of technology

It improves the accuracy of garbage detection, reduces the false alarm rate, can accurately judge the garbage status in different scenarios, and saves the cost of personnel scheduling and processing tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115035474B_ABST
    Figure CN115035474B_ABST
Patent Text Reader

Abstract

The present invention discloses a garbage detection method, device and related media based on scene attention, the method comprising: obtaining historical garbage images, and marking the historical garbage images; inputting the marked historical garbage images into an improved Yolov5 network and a scene attention mechanism for learning to construct a scene understanding target detection network; performing multi-target training on the scene understanding target detection network using a loss function; detecting the designated garbage images through the trained scene understanding target detection network to obtain the corresponding scene confidence, and using the scene confidence as the garbage detection result. The present invention combines the Yolov5 network and the scene attention mechanism to construct a scene understanding target detection network based on scene confidence, thereby combining the scene corresponding to the garbage image for detection, so as to improve the garbage detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer software technology, and in particular to a garbage detection method and device based on scene attention and related media. Background Art

[0002] Most of the current deep learning methods for detecting garbage use target detection networks, which mark the location and category information of garbage, use the network for training, and then determine whether there is garbage in the image. However, this detection method still has certain defects. Specifically:

[0003] Garbage-related events are difficult to quantify and define: Garbage-related abnormal events, such as overflowing trash cans, are detected based on the method of judging events based on the detected target. For example, if garbage is detected, an alarm will be issued that the trash can is overflowing. However, since the relevant attributes of garbage, such as volume, size, and category, are not considered, an alarm will be issued even if a piece of paper is detected in the trash can.

[0004] The types of garbage are not clearly defined: Since garbage is essentially the same as everyday objects, manual labeling cannot accurately determine whether the target is garbage, resulting in false positives such as identifying a "portable plastic bag" as "garbage." In addition, the specific category of the target will change in different image scenes. For example, in an elevator, a plastic bag held by hand will not be defined as garbage, but a garbage bag dropped on the ground will be defined as garbage.

[0005] Therefore, how to overcome the defect that traditional target detection methods only detect garbage and cause a large number of false positives is a problem that technical personnel in this field need to solve. Summary of the invention

[0006] The embodiments of the present invention provide a method, apparatus, computer device and storage medium for garbage detection based on scene attention, aiming to improve the accuracy of garbage detection.

[0007] In a first aspect, an embodiment of the present invention provides a method for detecting garbage based on scene attention, comprising:

[0008] Acquire historical garbage images, and label the historical garbage images;

[0009] The annotated historical garbage images are input into the improved Yolov5 network and scene attention mechanism for learning to construct a scene understanding object detection network;

[0010] Performing multi-object training on the scene understanding object detection network using a loss function;

[0011] The designated junk image is detected through the trained scene understanding target detection network to obtain the corresponding scene confidence, and the scene confidence is used as the junk detection result.

[0012] In a second aspect, an embodiment of the present invention provides a garbage detection device based on scene attention, comprising:

[0013] An image annotation unit, used for acquiring historical junk images and annotating the historical junk images;

[0014] The network construction unit is used to input the annotated historical garbage images into the improved Yolov5 network and scene attention mechanism for learning, so as to construct a scene understanding object detection network;

[0015] A network training unit, configured to perform multi-target training on the scene understanding target detection network using a loss function;

[0016] The garbage detection unit is used to detect the specified garbage image through the trained scene understanding target detection network, obtain the corresponding scene confidence, and use the scene confidence as the garbage detection result.

[0017] In a third aspect, an embodiment of the present invention provides a computer 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 scene attention-based garbage detection method as described in the first aspect is implemented.

[0018] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the scene attention-based garbage detection method as described in the first aspect is implemented.

[0019] The embodiment of the present invention provides a method, device, computer equipment and storage medium for garbage detection based on scene attention, the method comprising: obtaining historical garbage images and annotating the historical garbage images; inputting the annotated historical garbage images into the improved Yolov5 network and scene attention mechanism for learning to construct a scene understanding target detection network; performing multi-target training on the scene understanding target detection network using a loss function; detecting the specified garbage images through the trained scene understanding target detection network to obtain the corresponding scene confidence, and using the scene confidence as the garbage detection result. The embodiment of the present invention combines the Yolov5 network and the scene attention mechanism to construct a scene understanding target detection network based on scene confidence, thereby combining the scene corresponding to the garbage image for detection, which can improve the accuracy of garbage detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0021] Figure 1 A flow chart of a garbage detection method based on scene attention provided by an embodiment of the present invention;

[0022] Figure 2 A schematic diagram of a sub-process of a garbage detection method based on scene attention provided by an embodiment of the present invention;

[0023] Figure 3 A schematic block diagram of a garbage detection device based on scene attention provided by an embodiment of the present invention;

[0024] Figure 4 A sub-schematic block diagram of a garbage detection device based on scene attention provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0025] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0026] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0027] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0028] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0029] See below Figure 1, Figure 1 A flow chart of a garbage detection method based on scene attention provided in an embodiment of the present invention specifically includes: steps S101 to S104.

[0030] S101, obtaining historical junk images, and marking the historical junk images;

[0031] S102, inputting the annotated historical garbage images into the improved Yolov5 network and scene attention mechanism for learning, so as to construct a scene understanding target detection network;

[0032] S103, performing multi-target training on the scene understanding target detection network using a loss function;

[0033] S104. Detect the designated junk image through the trained scene understanding target detection network to obtain the corresponding scene confidence, and use the scene confidence as the junk detection result.

[0034] In this embodiment, the labeled historical garbage is first used to learn and train a scene understanding target detection network including an improved Yolov5 network and a scene attention mechanism, and multi-target training is performed on the scene understanding target detection network through a loss function to optimize the scene understanding target detection network parameters and improve the detection accuracy of the scene understanding target detection network, so as to detect the specified garbage images using the scene understanding target detection network.

[0035] Compared with the traditional target detection network, this embodiment can automatically determine whether there is a situation such as overflowing trash cans in combination with the image scene, thereby overcoming the disadvantage of a large number of false alarms caused by only detecting trash in the traditional target detection method. And according to the scene confidence output by the scene understanding target detection network, cleaning staff can be dispatched accurately and quickly to clean up the trash, saving the cost of personnel scheduling and processing tasks, and reducing staff and increasing efficiency for the property.

[0036] In this embodiment, when acquiring and annotating historical garbage images, video streams or surveillance video file frame extraction methods can be used to acquire the images, and as training sets, images of various lighting intensities, distances, etc. need to be collected. The targets in the labeled training data set include, but are not limited to, domestic garbage, construction garbage, garbage cans, pedestrians, cars, tricycles, stone piers, roads, grass, etc.

[0037] This embodiment makes a judgment based on the current garbage picture of the scene confidence. Taking the overflowing trash can as an example, the scene understanding target detection network detects domestic garbage and pedestrians in the garbage image, and determines the spatial position relationship and visual features between domestic garbage and pedestrians through position coding. At the same time, combined with the scene features of the entire picture, it can avoid alarming pedestrians carrying garbage bags as scattered garbage. Similarly, if domestic garbage and trash cans are detected, according to their position relationship and visual features and the scene features of the entire picture, an alarm can be issued as a full trash can. However, if a cleaning worker is detected or a tricycle is being transported, the confidence of the event of the overflowing trash can will be reduced accordingly. In addition, since the category definition of garbage in different scenes is unclear, when pedestrians and garbage bags are detected, the scene understanding target detection network will judge that it may be a pedestrian carrying a plastic bag based on the spatial position relationship coding, and output a lower confidence of the garbage scattering event.

[0038] This embodiment can accurately and effectively detect various garbage alarm scenarios such as overflowing garbage bins, scattered garbage, and large garbage piles through deep learning, thereby achieving the goal of reducing costs and increasing efficiency. In addition, this embodiment can also be combined with existing business in the property industry, such as processing situations where garbage trucks are working and cleaning staff are cleaning. In these scenarios, the model will output a lower alarm score, which can be transferred to manual review, effectively eliminating the trouble caused by false alarms to the project, and identifying alarm events in a more humane way.

[0039] In one embodiment, if Figure 2 As shown, the step S102 includes: steps S201 to S206.

[0040] S201, inputting the labeled historical garbage image into the improved Yolov5 network, and predicting and outputting the target frame features corresponding to the historical garbage image by the improved Yolov5 network; wherein the target frame features include the target frame position coordinates, the target frame confidence and the target category;

[0041] In this step, the Yolov5 network can predict and output the corresponding target box position coordinates (b i ), target confidence (p i ) and category (c i ), but considering that the three regression targets in the existing Yolov5 network are highly coupled, the recognition results will affect each other, and the efficiency and accuracy are low. Therefore, this step improves the Yolov5 network to improve the prediction efficiency and accuracy.

[0042] In a specific embodiment, the step S201 includes:

[0043] The coupled head in the Yolov5 network is replaced with a separable head, and the separable head is used to predict and output the historical junk image; wherein the separable head includes three convolutional layers for predicting the target frame position coordinates, the target frame confidence and the target frame category respectively.

[0044] That is to say, this embodiment replaces the coupling head in the Yolov5 network with a separable head, so that the target frame position coordinates, target frame confidence and target frame category are respectively identified by using three convolutional layers, which can speed up the model convergence and improve the recognition accuracy. The coupling head represents a convolutional layer in the Yolov5 network that simultaneously regresses the position coordinates and the category of the target confidence, and the separable head represents three convolutional layers that are separated and predict the three targets respectively, that is, this embodiment uses three parallel convolutional layers to replace the original convolutional layer. Although both the improved model and the unimproved Yolov5 network can be recognized, the improvement is to predict the three targets separately, and the advantages are: speeding up the training speed, avoiding the mutual influence of the three results, and improving the recognition accuracy. The specific recognition process can be that the first convolution layer in the separable head only outputs the position coordinates of the target box (x1, y1, x2, y2), the second convolution layer only outputs the target confidence (p) of the target box, and the third convolution layer only outputs the target category (c) of the target box, while one convolution layer of the original coupled head outputs three results (x1, y1, x2, y2, p, c) at the same time.

[0045] S202, extracting global features from the target frame features through a scene understanding branch convolutional neural network to obtain corresponding scene features;

[0046] In this step, after the Yolov5 network outputs the target frame features, the scene understanding branch convolutional neural network is used to extract the global features, and the scene features f are obtained after passing through the global pooling layer. scene , the scene feature can specifically be a 1024-dimensional vector.

[0047] In a specific embodiment, the step S202 includes:

[0048] The target frame features are extracted in sequence through a first convolutional layer, a first activation function layer, and a first global feature pooling layer to obtain the scene features.

[0049] In another specific embodiment, the target frame features are output by the p5 layer in the Yolov5 network. The Yolov5 network includes p1 layer, p2 layer, p3 layer, p4 layer, and p5 layer. The p1 layer, p2 layer, p3 layer, p4 layer, and p5 layer respectively represent the features of different downsampling scales, representing the output results of the network from shallow to deep. The deeper the feature, the smaller the size of its feature map and the more abstract the extracted feature, expressing deeper features. In detail, if the input image is a 640*640 image, the feature of P1 is shallow, and its downsampling ratio is 1 / 2, and the size is 320*320; P2 uses multiple convolutional layers and downsampling layers to extract features based on P1, and the feature map size is 160*160. By analogy, the downsampling ratio of P3 is 1 / 8, the feature map size is 80*80, the downsampling ratio of P4 is 1 / 16, the feature map size is 40*40, the downsampling ratio of P5 is 1 / 32, the feature map size is 20*20. P5 is the deepest layer of features, with the largest receptive field and can best reflect global information.

[0050] S203, based on the target frame position coordinates, extracting the target frame visual features corresponding to the target frame features through a path aggregation network;

[0051] In this step, the features of the target frame position are intercepted on the feature map extracted by the path aggregation network (PAN), and the target visual features f are obtained after passing through the convolutional neural network and the global pooling layer. i , specifically, it can be a vector of 512 dimensions.

[0052] In a specific embodiment, the step S203 includes:

[0053] Based on the target frame position coordinates, mapping the corresponding target frame to the feature map;

[0054] The target features of the feature map are extracted sequentially through a second convolutional layer, a second activation function layer, and a second global feature pooling layer, and the target features are used as the target frame visual features.

[0055] In this embodiment, for each target frame, there is a target frame position (x1, y1, x2, y2). By mapping the target position to the feature map, the position of the target frame on the feature map can be calculated according to the downsampling ratio of the feature map. For example, if the downsampling ratio of the feature map is 1 / 16, the position of the target frame mapped to the feature map becomes (x1 / 16, y1 / 16, x2 / 16, y2 / 16). According to the mapped position, the feature map of the target is cropped, and after the feature map for the position is extracted, a convolution layer (output dimension is 512) + an activation function layer + a global feature pooling layer is used to extract the visual features of the target frame f. i .

[0056] S204, encoding the target frame position coordinates to obtain corresponding target frame position features;

[0057] In this step, the position coordinates b of the encoding target box are i , get the position feature g of each target box i , specifically, it can be a vector of 512 dimensions.

[0058] In this step, for each target box, its position coordinates are (x1, y1, x2, y2), so a target box can be represented by 4 floating-point numbers. Using a convolution layer (input dimension is 4, output dimension is 512) + activation function layer, the target box position feature g can be obtained. i .

[0059] S205, inputting the target confidence, target frame visual features and target frame position features into an attention model, and fusing and outputting corresponding fusion features by the attention model;

[0060] In this step, the target confidence p i , target box visual features f i , target frame position feature g i Input into the attention module to obtain the corresponding fusion features.

[0061] In a specific embodiment, the step S205 includes:

[0062] The target frame position coordinates, the target frame visual features and the target frame position features are fused into the fused features according to the following formula:

[0063]

[0064] In the formula, expresses element-by-element multiplication, d represents the extracted vector dimension, F, G, and P represent the target frame visual feature vector matrix, the target frame position coordinate vector matrix, and the target frame position feature vector matrix, respectively. T Represents the transpose multiplication of matrix F and matrix G.

[0065] S206: Concatenate the fusion feature with the scene feature, and input the concatenation result into a fully connected layer, which outputs a final scene confidence.

[0066] In this step, after obtaining the fusion feature, it is combined with the scene feature f scene The linear layer is a fully connected layer that calculates the scene score corresponding to the vector obtained by the concatenation. For example, the feature calculated by the attention module has a dimension of 512, which is the same as fscene The vector (dimension is 1024) is concatenated, and the resulting vector dimension is 1024+512=1536. Then the input dimension of the fully connected layer is 1536, and the corresponding output dimension is 1.

[0067] In this embodiment, by setting a scene understanding branch, a separable target detection head, and an attention module, etc., the target features and global features in the garbage image are associated, so that garbage detection can be achieved more accurately and quickly.

[0068] In one embodiment, the step S103 includes:

[0069] According to the following formula, the loss function L is used to perform multi-target training on the scene understanding target detection network:

[0070] L=L yolov5 +L scene

[0071] Where, L yolov5 is the loss function of the Yolov5 network, L scene Calculate the scene confidence loss function, Among them, y i represents the real scene category of the corresponding historical garbage image, s i Represents the scene category score output by the scene understanding target detection network, and i is the predicted multiple categories.

[0072] In this embodiment, the above loss function is used to optimize and update the scene understanding target detection network. The loss function specifically includes the loss function of the Yolov5 network and the scene confidence loss function. For the scene confidence loss function, the binary cross entropy (BCE) loss can be used to calculate the scene confidence score under non-mutually exclusive conditions. This embodiment mixes multiple losses and drives the scene understanding target detection network training on the principle of minimizing losses until the losses converge, and then saves the optimal result for forward reasoning.

[0073] Figure 3 A schematic block diagram of a garbage detection device 300 based on scene attention provided by an embodiment of the present invention, the device 300 includes:

[0074] An image annotation unit 301 is used to obtain historical junk images and annotate the historical junk images;

[0075] A network construction unit 302 is used to input the annotated historical garbage images into the improved Yolov5 network and the scene attention mechanism for learning, so as to construct a scene understanding target detection network;

[0076] A network training unit 303, configured to perform multi-target training on the scene understanding target detection network using a loss function;

[0077] The garbage detection unit 304 is used to detect the specified garbage image through the trained scene understanding target detection network, obtain the corresponding scene confidence, and use the scene confidence as the garbage detection result.

[0078] In one embodiment, if Figure 4 As shown, the network construction unit 302 includes:

[0079] The prediction output unit 401 is used to input the labeled historical garbage image into the improved Yolov5 network, and the improved Yolov5 network predicts and outputs the target frame features corresponding to the historical garbage image; wherein the target frame features include the target frame position coordinates, the target frame confidence and the target category;

[0080] A first extraction unit 402 is used to extract global features from the target frame features through a scene understanding branch convolutional neural network to obtain corresponding scene features;

[0081] A second extraction unit 403 is used to extract the target frame visual features corresponding to the target frame features through a path aggregation network based on the target frame position coordinates;

[0082] The encoding unit 404 is used to encode the target frame position coordinates to obtain corresponding target frame position features;

[0083] A feature fusion unit 405 is used to input the target confidence, target frame visual features and target frame position features into an attention model, and the attention model fuses and outputs corresponding fusion features;

[0084] The feature concatenation unit 406 is used to concatenate the fusion feature with the scene feature, and input the concatenation result into a fully connected layer, and the fully connected layer outputs the final scene confidence.

[0085] In one embodiment, the prediction output unit 401 includes:

[0086] A replacement unit is used to replace the coupled head in the Yolov5 network with a separable head, and use the separable head to predict and output the historical junk image; wherein the separable head includes three convolutional layers for predicting the target frame position coordinates, the target frame confidence and the target frame category respectively.

[0087] In one embodiment, the first extraction unit 402 includes:

[0088] The scene feature extraction unit is used to extract the target frame feature through a first convolution layer, a first activation function layer and a first global feature pooling layer in sequence to obtain the scene feature.

[0089] In one embodiment, the second extraction unit 403 includes:

[0090] A mapping unit, used to map the corresponding target frame to the feature map based on the position coordinates of the target frame;

[0091] The visual feature extraction unit is used to extract the target features of the feature map through the second convolution layer, the second activation function layer and the second global feature pooling layer in sequence, and use the target features as the target frame visual features.

[0092] In one embodiment, the feature fusion unit 405 includes:

[0093] The fusion feature acquisition unit is used to fuse the target frame position coordinates, the target frame visual features and the target frame position features into the fusion feature according to the following formula:

[0094]

[0095] In the formula, expresses element-by-element multiplication, d represents the extracted vector dimension, F, G, and P represent the target frame visual feature vector matrix, the target frame position coordinate vector matrix, and the target frame position feature vector matrix, respectively. T Represents the transpose multiplication of matrix F and matrix G.

[0096] In one embodiment, the network training unit 303 includes:

[0097] The multi-objective training unit is used to perform multi-objective training on the scene understanding object detection network using a loss function L according to the following formula:

[0098] L=L yolov5 +L scene

[0099] Where, L yolov5 is the loss function of the Yolov5 network, L scene Calculate the scene confidence loss function, Among them, y i represents the real scene category of the corresponding historical garbage image, s i Represents the scene category score output by the scene understanding target detection network, and i is the predicted multiple categories.

[0100] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.

[0101] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0102] The embodiment of the present invention also provides a computer device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the computer device may also include various network interfaces, power supplies and other components.

[0103] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.

[0104] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

Claims

1. A garbage detection method based on scene attention, characterized in that: include: Acquire historical garbage images, and label the historical garbage images; The annotated historical garbage images are input into the improved Yolov5 network and scene attention mechanism for learning to construct a scene understanding object detection network; Performing multi-object training on the scene understanding object detection network using a loss function; Detect the specified junk image through the trained scene understanding target detection network to obtain the corresponding scene confidence, and use the scene confidence as the junk detection result; The labeled historical garbage images are input into the improved Yolov5 network and the scene attention mechanism for learning to construct a scene understanding target detection network, including: Inputting the labeled historical garbage image into the improved Yolov5 network, and predicting and outputting the target frame features corresponding to the historical garbage image by the improved Yolov5 network; wherein the target frame features include the target frame position coordinates, the target frame confidence and the target category; Extracting global features from the target frame features through a scene understanding branch convolutional neural network to obtain corresponding scene features; Based on the target frame position coordinates, extracting the target frame visual features corresponding to the target frame features through a path aggregation network; Encoding the target frame position coordinates to obtain corresponding target frame position features; Inputting the target frame confidence, target frame visual features and target frame position features into an attention model, and fusing and outputting corresponding fusion features by the attention model; The fusion feature is concatenated with the scene feature, and the concatenation result is input into a fully connected layer, which outputs the final scene confidence.

2. The method for garbage detection based on scene attention according to claim 1, characterized in that: The step of inputting the labeled historical garbage image into the improved Yolov5 network, and predicting and outputting the target frame features corresponding to the historical garbage image by the improved Yolov5 network includes: The coupled head in the Yolov5 network is replaced with a separable head, and the separable head is used to predict and output the historical junk image; wherein the separable head includes three convolutional layers for predicting the target frame position coordinates, the target frame confidence and the target frame category respectively.

3. The method for garbage detection based on scene attention according to claim 1, characterized in that: The extracting global features from the target frame features through the scene understanding branch convolutional neural network to obtain corresponding scene features includes: The target frame features are extracted in sequence through a first convolutional layer, a first activation function layer, and a first global feature pooling layer to obtain the scene features.

4. The method for garbage detection based on scene attention according to claim 1, characterized in that: The step of extracting the target frame visual features corresponding to the target frame features through a path aggregation network based on the target frame position coordinates includes: Based on the target frame position coordinates, mapping the corresponding target frame to the feature map; The target features of the feature map are extracted sequentially through a second convolutional layer, a second activation function layer, and a second global feature pooling layer, and the target features are used as the target frame visual features.

5. The method for garbage detection based on scene attention according to claim 1, characterized in that: The step of inputting the target frame confidence, the target frame visual features and the target frame position features into the attention model, and fusing the attention model to output corresponding fusion features, comprises: The target frame position coordinates, the target frame visual features and the target frame position features are fused into the fused features according to the following formula: In the formula, expresses element-by-element multiplication, d represents the extracted vector dimension, F, G, and P represent the target frame visual feature vector matrix, the target frame position coordinate vector matrix, and the target frame position feature vector matrix, respectively. T Represents the transpose multiplication of matrix F and matrix G.

6. The method for garbage detection based on scene attention according to claim 1, characterized in that: The using a loss function to perform multi-target training on the scene understanding target detection network includes: According to the following formula, the loss function L is used to perform multi-target training on the scene understanding target detection network: L=L yolov5 +L scene Where, L yolov5 is the loss function of the Yolov5 network, L scene Calculate the scene confidence loss function, Among them, y i represents the real scene category of the corresponding historical garbage image, s i Represents the scene category score output by the scene understanding target detection network, and i is the predicted multiple categories.

7. A garbage detection device based on scene attention, characterized in that: include: An image annotation unit, used for acquiring historical junk images and annotating the historical junk images; The network construction unit is used to input the annotated historical garbage images into the improved Yolov5 network and scene attention mechanism for learning, so as to construct a scene understanding object detection network; A network training unit, configured to perform multi-target training on the scene understanding target detection network using a loss function; A garbage detection unit, used to detect a specified garbage image through a trained scene understanding target detection network, obtain a corresponding scene confidence, and use the scene confidence as a garbage detection result; The network construction unit includes: A prediction output unit, used for inputting the labeled historical junk image into the improved Yolov5 network, and predicting and outputting the target frame features corresponding to the historical junk image by the improved Yolov5 network; wherein the target frame features include the target frame position coordinates, the target frame confidence and the target category; A first extraction unit is used to extract global features from the target frame features through a scene understanding branch convolutional neural network to obtain corresponding scene features; A second extraction unit is used to extract the target frame visual features corresponding to the target frame features through a path aggregation network based on the target frame position coordinates; An encoding unit, used for encoding the target frame position coordinates to obtain corresponding target frame position features; A feature fusion unit, used for inputting the target frame confidence, the target frame visual feature and the target frame position feature into an attention model, and the attention model fuses and outputs a corresponding fusion feature; A feature splicing unit is used to splice the fusion feature with the scene feature, and input the splicing result into a fully connected layer, and the fully connected layer outputs the final scene confidence.

8. A computer device, characterized in that: It includes 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 scene attention-based garbage detection method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the scene attention-based garbage detection method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Event detection method and device, electronic equipment and storage medium

    CN112507813A