Garbage bag identification method and device, storage medium and product

Through the target detection network and deep learning algorithm, combined with the Yolov5 network and CA attention mechanism, the problem of low garbage bag identification accuracy is solved, and more efficient garbage bag identification and garbage placement accuracy are achieved.

CN118587567AInactive Publication Date: 2024-09-03JIANGXI XIAOWEI INTERNET TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410733566.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-09-03
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing garbage bag recognition technology has low accuracy and is easily affected by lighting and background. It is difficult to distinguish garbage bags from non-garbage bags by color recognition alone, leading to confusion in garbage placement.

Method used

The target detection network is used to obtain and label the garbage bag image data set, which is divided into a training set, a test set and a verification set. It is trained and tested multiple times to obtain the best weight model, and the deep learning algorithm is combined to identify the color of the garbage bag, and the Yolov5 network is used and CA attention mechanism and other technologies to improve recognition accuracy.

Benefits of technology

It achieves more accurate garbage bag identification, improves the accuracy of garbage placement, overcomes light and background interference, and reduces misidentification due to similar colors in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118587567A
    Figure CN118587567A
Patent Text Reader

Abstract

The invention discloses a garbage bag identification method and device, a storage medium and a product, and relates to the technical field of garbage identification. The method comprises the following steps: dividing a labeled data set into a training set, a test set and a verification set; training and testing the target detection network for multiple times by adopting the training set and the test set to obtain a weight model set; evaluating the weight model set by adopting the verification set to obtain an optimal weight model; evaluating the optimal weight model by adopting an evaluation data set to obtain an evaluation result, determining a negative sample in the evaluation data set according to the evaluation result, adding the negative sample into a training set and a test set, and then returning to adopt the training set and the test set to train and test the target detection network for multiple times to obtain a weight model set; obtaining a garbage bag identification model until the optimal weight model meets a set requirement; and identifying the target image by using the garbage bag identification model to obtain the color of the garbage bag in the target image. According to the invention, the garbage bag can be identified more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of garbage identification, and in particular to a garbage bag identification method, equipment, storage medium and product. Background Art

[0002] The classification and placement of garbage bags is an important part of garbage management. Due to the lack of unified classification standards and weak awareness of garbage classification, the phenomenon of chaotic garbage placement is still very common. Therefore, how to improve the accuracy of garbage placement and reduce the number of incorrect garbage placements has become an important issue facing garbage management.

[0003] At present, many color recognition technologies have been applied to garbage bag recognition, such as vision-based recognition, machine learning-based recognition, etc. However, the existing color recognition technology also has some problems, such as low recognition accuracy and high requirements for lighting and background.

[0004] On the one hand, existing color recognition technology usually relies on simple appearance features, such as the color and shape of garbage bags. These features are easily affected by factors such as lighting and background. In addition, camera shooting is prone to motion blur, resulting in low recognition accuracy.

[0005] On the other hand, since garbage bags have a single color, it is difficult to distinguish between garbage bags and non-garbage bags by color recognition alone.

[0006] Therefore, the existing use of color recognition technology to distinguish the chaotic phenomenon of garbage disposal is prone to many interferences, so in order to improve the accuracy of garbage disposal, a more accurate garbage bag identification method is needed. Summary of the invention

[0007] The purpose of the present invention is to provide a garbage bag identification method, device, storage medium and product, which can more accurately identify garbage bags.

[0008] To achieve the above object, the present invention provides the following solutions:

[0009] A garbage bag identification method, comprising:

[0010] Obtaining a data set, the data set comprising images of portable garbage bags after garbage classification according to the colors of the garbage bags;

[0011] Annotating the data set with an annotation frame to obtain an annotated data set, wherein the annotation frame selects a hand holding a garbage bag and the garbage bag;

[0012] Dividing the labeled data set into a training set, a test set, and a validation set;

[0013] The target detection network is trained and tested multiple times using a training set and a test set to obtain a weight model set; the weight model set includes a trained target detection network corresponding to a minimum loss function value, a trained target detection network with the best recognition result in the test set, and a trained target detection network obtained from the last training;

[0014] Using the validation set to evaluate the weight model set to obtain the best weight model;

[0015] The optimal weight model is evaluated using an evaluation data set to obtain an evaluation result, and negative samples in the evaluation data set are determined according to the evaluation result and added to the training set and the test set, and then the step of training and testing the target detection network multiple times using the training set and the test set to obtain a weight model set is returned until the optimal weight model meets the set requirements, and the optimal weight model that meets the set requirements is determined to be a garbage bag recognition model; the evaluation data set includes pictures of objects with the same color as the garbage bags in the data set;

[0016] The garbage bag recognition model is used to recognize the target image and obtain the color of the garbage bag in the target image.

[0017] Optionally, the target detection network is a Yolov5 network, comprising: an input layer, a Backbone network, a Neck network and an output layer connected in sequence;

[0018] The Backbone network includes: C1 module, C2 module, C3 module, C4 module and C5 module;

[0019] The C1 module includes a first CBS submodule, a second CBS submodule and a first CASP submodule connected in sequence; the C2 module, the C3 module and the C4 module each include a third CBS submodule and a second CASP submodule connected in sequence; the C5 module includes a fourth CBS submodule, three maximum pooling layers each connected to the fourth CBS submodule, and a first concat submodule each connected to the three maximum pooling layers and the fourth CBS submodule;

[0020] The input end of the first CBS submodule is connected to the output end of the input layer, the output end of the first CASP submodule is connected to the input end of the third CBS submodule in the C2 module; the output end of the second CASP submodule in the C2 module is connected to the input end of the third CBS submodule in the C3 module; the output end of the second CASP submodule in the C3 module is connected to the input end of the third CBS submodule in the C4 module; the output end of the second CASP submodule in the C4 module is connected to the input end of the fourth CBS submodule in the C5 module;

[0021] The Neck network includes: an M1 module, an M2 module, an M3 module, an N1 module, a second concat submodule, an N3 module, a third concat submodule and an N5 module;

[0022] The M1 module, the M2 module and the M3 module all include a fifth CBS submodule, a third CASP submodule and an upsampling module connected in sequence; the N1 module, the N3 module and the N5 module all include a sixth CBS submodule and a fourth CASP submodule connected in sequence;

[0023] The input end of the fifth CBS submodule in the M1 module is connected to the output end of the first concat submodule in the C5 module; the up-sampled output end in the M1 module is connected to the input end of the fifth CBS submodule of the M2 module and the input end of the third concat submodule respectively;

[0024] The input end of the fifth CBS submodule in the M2 module is connected to the output end of the second CASP submodule in the C3 module; the output end of the upsampling in the M2 module is connected to the input end of the fifth CBS submodule in the M3 module and the input end of the second concat submodule respectively;

[0025] The input end of the fifth CBS submodule in the M3 module is connected to the output end of the first CASP submodule; the output end of the upsampling in the M3 module is connected to the input end of the sixth CBS submodule in the N1 module; the output end of the fourth CASP submodule in the N1 module is respectively connected to the input end of the second concat submodule and the input end of the output layer; the output end of the second concat submodule is connected to the input end of the sixth CBS submodule in the N3 module; the output end of the fourth CASP submodule in the N3 module is respectively connected to the input end of the third concat submodule and the input end of the output layer; the output end of the third concat submodule is connected to the input end of the sixth CBS submodule in the N5 module; the output end of the fourth CASP submodule in the N5 module is connected to the input end of the output layer.

[0026] Optionally, the first CASP submodule, the second CASP submodule, the third CASP submodule and the fourth CASP submodule all include: a seventh CBS submodule, an eighth CBS submodule, a Resx submodule, a CA attention mechanism, a fourth concat submodule and a ninth CBS submodule; the input end of the seventh CBS submodule is connected to the input end of the eighth CBS submodule, the output end of the seventh CBS submodule is connected to the input end of the Resx submodule, the output end of the Resx submodule is connected to the input end of the fourth concat submodule, and the output end of the fourth concat submodule is connected to the input end of the ninth CBS submodule; the output end of the eighth CBS submodule is connected to the input end of the CA attention mechanism, and the input end of the CA attention mechanism is connected to the input end of the fourth concat submodule.

[0027] Optionally, the first CBS submodule, the second CBS submodule, the third CBS submodule, the fourth CBS submodule, the fifth CBS submodule, the sixth CBS submodule, the seventh CBS submodule, the eighth CBS submodule and the ninth CBS submodule all include: a first convolution, a second convolution, a BN layer, a Silu activation function and a third convolution connected in sequence.

[0028] Optionally, the Resx submodule includes a tenth CBS submodule, a CBS module and a jump connection; the output end of the tenth CBS submodule is connected to the input end of the CBS module and the input end of the jump connection, and the output end of the CBS module is connected to the input end of the jump connection.

[0029] A computer device comprises: a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-mentioned garbage bag identification method.

[0030] A computer-readable storage medium stores a computer program, which implements the above-mentioned garbage bag identification method when executed by a processor.

[0031] A computer program product includes a computer program, and when the computer program is executed by a processor, the garbage bag identification method described above is implemented.

[0032] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0033] The present invention obtains a data set, which includes images of portable garbage bags after garbage classification according to the color of the garbage bags; the data set is annotated with a labeling frame to obtain a labeled data set, and the labeling frame selects the hand carrying the garbage bag and the garbage bag; the labeled data set is divided into a training set, a test set and a validation set; the target detection network is trained and tested multiple times with the training set and the test set to obtain a weight model set; the weight model set includes the trained target detection network corresponding to the minimum loss function value, the trained target detection network with the best recognition result in the test set, and the trained target detection network obtained by the last training; the weight model set is evaluated with the validation set to obtain the best weight model; the evaluation data set is used to evaluate the weight model set The optimal weight model is evaluated to obtain an evaluation result, and negative samples in the evaluation data set are determined according to the evaluation result and the negative samples are added to the training set and the test set, and then the step of training and testing the target detection network multiple times using the training set and the test set to obtain a weight model set is returned until the optimal weight model meets the set requirements, and the optimal weight model that meets the set requirements is determined to be a garbage bag recognition model; the evaluation data set includes pictures of objects with the same color as the garbage bags in the data set; the garbage bag recognition model is used to recognize the target image to obtain the color of the garbage bag in the target image, and a deep learning algorithm is used to recognize the garbage bag using a target detection method, so that the garbage bag can be more accurately recognized and the accuracy of garbage placement can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0035] Figure 1 A flow chart of a method for identifying a garbage bag provided by an embodiment of the present invention;

[0036] Figure 2 A flowchart of a method for identifying a garbage bag provided by an embodiment of the present invention;

[0037] Figure 3 A structural block diagram of the Yolov5 network provided in an embodiment of the present invention;

[0038] Figure 4 A residual structure block diagram provided by an embodiment of the present invention;

[0039] Figure 5 A structural block diagram of the CA attention mechanism provided by an embodiment of the present invention;

[0040] Figure 6 A structural block diagram of the C5 module provided in an embodiment of the present invention;

[0041] Figure 7 A structural block diagram of the CASP submodule provided in an embodiment of the present invention;

[0042] Figure 8 A structural block diagram of a CBS submodule provided in an embodiment of the present invention;

[0043] Fig. 9 A structural block diagram of the Resx submodule provided in an embodiment of the present invention;

[0044] Fig.10 This is a diagram of the internal structure of a computer device. DETAILED DESCRIPTION

[0045] 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 only 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.

[0046] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0047] like Figure 1 As shown, an embodiment of the present invention provides a garbage bag identification method, comprising:

[0048] Step 101: Acquire a data set, wherein the data set includes images of portable garbage bags after garbage classification according to the colors of the garbage bags.

[0049] Step 102: annotating the data set with an annotation frame to obtain an annotated data set, wherein the annotation frame selects the hand holding the garbage bag and the garbage bag.

[0050] Step 103: Divide the labeled data set into a training set, a test set, and a validation set.

[0051] Step 104: Use the training set and the test set to train and test the target detection network multiple times to obtain a weight model set; the weight model set includes the trained target detection network corresponding to the minimum loss function value, the trained target detection network with the best recognition result in the test set, and the trained target detection network obtained from the last training.

[0052] Step 105: Use the validation set to evaluate the weight model set to obtain the best weight model.

[0053] Step 106: Use the evaluation data set to evaluate the best weight model to obtain an evaluation result, and determine the negative samples in the evaluation data set based on the evaluation result and add the negative samples to the training set and the test set, and then return to the step of using the training set and the test set to train and test the target detection network multiple times to obtain a weight model set, until the best weight model meets the set requirements, and determine that the best weight model that meets the set requirements is the garbage bag recognition model; the evaluation data set includes pictures of objects with the same color as the garbage bags in the data set.

[0054] Step 107: Use the garbage bag recognition model to recognize the target image and obtain the color of the garbage bag in the target image.

[0055] In practical applications, a data set is obtained, and the data set is annotated using an annotation box to obtain an annotated data set, specifically including:

[0056] Step 1: Obtain the data set. Use the camera to collect videos of residents carrying garbage bags to throw away garbage. Extract the key frame images in the video and save them. The image data is divided into four categories:

[0057] Red garbage bags represent hazardous waste.

[0058] Green garbage bags represent food waste.

[0059] Blue trash bags represent recyclables.

[0060] Gray trash bags represent other trash.

[0061] Step 2: Label the data. Use labelimg labeling software to mark the image with a rectangular box. The labeling format is yolo format. When labeling, add hand feature data (the hand holding the garbage bag) in the labeling box to increase the tolerance of garbage bag color recognition and reduce the impact caused by too few garbage bag features.

[0062] In practical applications, such as Figure 3 As shown, the target detection network is a Yolov5 network including: an input layer, a Backbone network, a Neck network and an output layer connected in sequence. Figure 3 In the middle, ↑ represents downsampling, and the image size is reduced, and ↓ represents upsampling, and the image size is increased.

[0063] The Backbone network includes: C1 module C1, C2 module C2, C3 module C3, C4 module C4 and C5 module C5; the C1 module C1 includes a first CBS submodule, a second CBS submodule and a first CASP submodule connected in sequence; the C2 module C2, the C3 module C3 and the C4 module C4 all include a third CBS submodule and a second CASP submodule connected in sequence; Figure 6 As shown, the C5 module C5 includes a fourth CBS submodule, three maximum pooling layers each connected to the fourth CBS submodule, and a first concat submodule each connected to the three maximum pooling layers and the fourth CBS submodule; the input end of the first CBS submodule is connected to the output end of the input layer, and the output end of the first CASP submodule is connected to the input end of the third CBS submodule in the C2 module C2; ​​the output end of the second CASP submodule in the C2 module C2 is connected to the input end of the third CBS submodule in the C3 module C3; the output end of the second CASP submodule in the C3 module C3 is connected to the input end of the third CBS submodule in the C4 module C4; the output end of the second CASP submodule in the C4 module C4 is connected to the input end of the fourth CBS submodule in the C5 module C5.

[0064] The Neck network includes: an M1 module M1, an M2 module M2, an M3 module M3, an N1 module N1, a second concat submodule N2, an N3 module N3, a third concat submodule N4 and an N5 module N5; the M1 module M1, the M2 module M2 and the M3 module M3 all include a fifth CBS submodule, a third CASP submodule and upsampling connected in sequence; the N1 module N1, the N3 module N3 and the N5 module N5 all include a sixth CBS submodule and a fourth CASP submodule connected in sequence The input end of the fifth CBS submodule in the M1 module M1 is connected to the output end of the first concat submodule in the C5 module C5; the up-sampled output end in the M1 module M1 is respectively connected to the input end of the fifth CBS submodule in the M2 module M2 and the input end of the third concat submodule N4; the input end of the fifth CBS submodule in the M2 module M2 is connected to the output end of the second CASP submodule in the C3 module C3; the up-sampled output end in the M2 module M2 is connected to the output end of the second CASP submodule in the C3 module C3; They are respectively connected to the input end of the fifth CBS submodule in the M3 module M3 and the input end of the second concat submodule N2; the input end of the fifth CBS submodule in the M3 module M3 is connected to the output end of the first CASP submodule; the output end of the upsampling in the M3 module M3 is connected to the input end of the sixth CBS submodule in the N1 module N1; the output end of the fourth CASP submodule in the N1 module N1 is respectively connected to the input end of the second concat submodule N2 and the input end of the output layer; the output end of the second concat submodule N2 is connected to the input end of the sixth CBS submodule in the N3 module N3; the output end of the fourth CASP submodule in the N3 module N3 is respectively connected to the input end of the third concat submodule N4 and the input end of the output layer; the output end of the third concat submodule N4 is connected to the input end of the sixth CBS submodule in the N5 module N5; the output end of the fourth CASP submodule in the N5 module N5 is connected to the input end of the output layer.

[0065] In practical applications, the input layer includes: Mosaic data enhancement, adaptive anchor box calculation and adaptive image scaling connected in sequence.

[0066] In actual applications, the output layer includes: three Detect modules and a filter box + NMS module connected to the three Detect modules; the first Detect module is connected to the output end of the fourth CASP submodule in the N5 module N5, the second Detect module is connected to the output end of the fourth CASP submodule in the N3 module N3, and the third Detec module is connected to the output end of the fourth CASP submodule in the N1 module N1.

[0067] In practical applications, such as Figure 7 As shown, the first CASP submodule, the second CASP submodule, the third CASP submodule and the fourth CASP submodule all include: a seventh CBS submodule, an eighth CBS submodule, a Resx submodule, a CA attention mechanism, a fourth concat submodule and a ninth CBS submodule; the input end of the seventh CBS submodule is connected to the input end of the eighth CBS submodule, the output end of the seventh CBS submodule is connected to the input end of the Resx submodule, the output end of the Resx submodule is connected to the input end of the fourth concat submodule, and the output end of the fourth concat submodule is connected to the input end of the ninth CBS submodule; the output end of the eighth CBS submodule is connected to the input end of the CA attention mechanism, and the input end of the CA attention mechanism is connected to the input end of the fourth concat submodule.

[0068] In practical applications, such as Figure 8 As shown, the first CBS submodule, the second CBS submodule, the third CBS submodule, the fourth CBS submodule, the fifth CBS submodule, the sixth CBS submodule, the seventh CBS submodule, the eighth CBS submodule and the ninth CBS submodule all include: a first convolution, a second convolution, a BN layer, a Silu activation function and a third convolution connected in sequence.

[0069] In practical applications, the Resx submodule is a multiple residual module with the following structure: Fig. 9 As shown, it includes a tenth CBS submodule, a CBS module and a jump connection; the output end of the tenth CBS submodule is connected to the input end of the CBS module and the input end of the jump connection, and the output end of the CBS module is connected to the input end of the jump connection.

[0070] In practical applications, the target detection network is trained and tested multiple times using training sets and test sets to obtain a weight model set, including:

[0071] Step 4-1: Image preprocessing.

[0072] The images in the training set and test set are preprocessed through the input layer before being sent to the Backbone network. The preprocessing includes: Mosaic data enhancement, adaptive anchor box calculation and adaptive image scaling. Mosaic data enhancement can simulate complex environments with small samples, and adaptive image scaling can retain image features to the greatest extent.

[0073] Step 4-2: Feature extraction.

[0074] After the image is preprocessed, it is sent to the Backbone network. The Backbone network is composed of a residual structure and a CA attention mechanism to obtain image features of different scales. The features of different scales are then sent to the Neck network to fuse the features of different scales through upsampling and downsampling. Then, three feature maps of different scales are output through the FPN structure. The three feature maps store the category information, center point information, and width and height information of the image. Figure 4 As shown in the figure, the residual structure is as follows: after the feature map passes through the convolutional network, two branches are generated. One branch extracts features through multiple convolutions (Conv) + batch normalization (BN). After extracting the features, it is directly added to the other branch to form a residual connection. The batch normalization layer after the convolution layer helps to stabilize the network training. +: indicates a skip connection, which directly adds the output of the previous layer to the output of the current layer to form a residual connection. Figure 5 As shown in the figure, the key components of the CA attention mechanism include: global average pooling, fully connected layers or convolutional layers, and Sigmoid activation function. Global Average Pooling (GAP): Perform a global average operation on the feature map of each channel to obtain a single global statistical value. This helps capture the global information of the channel. Fully connected layers or convolutional layers: Use one-dimensional or two-dimensional convolutional layers to process global statistical values ​​to learn complex dependencies between channels. These layers usually contain nonlinear activation functions such as ReLU. Sigmoid activation function: The output layer uses the Sigmoid function to limit the learned channel weight values ​​between 0 and 1, so that the weights of the channels can be normalized. The workflow of the CA attention mechanism is: 1. Feature extraction: First, the input feature map is extracted through a convolutional layer or a pooling layer. 2. Global information capture: Then, GAP is used to capture the global information of each channel. 3. Weight learning: Then, the dependencies between channels are learned through a fully connected layer or a convolutional layer, and a nonlinear activation function is used to enhance the expressiveness of the model. 4. Attention weight assignment: Finally, the Sigmoid function applies the learned weight value to each channel of the original feature map to achieve adaptive adjustment of the features.

[0075] Step 4-3: Calculate the loss function based on the training set, adjust the model parameters according to the loss function, and then use the test set to test the model with updated parameters.

[0076] By comparing with the real box information (annotated box) of the image in the training set, the loss function is calculated. The loss function calculates the predicted center point, width and height loss and category loss respectively. The predicted center point and width and height loss use CIOU loss, and the formula is: Among them, IOU represents the intersection-over-union ratio between adjacent boxes, d is the distance between the predicted box (obtained from the three feature maps obtained in step 4-2) and the center point of the real box, and c is the diagonal distance between the predicted box and the minimum circumscribed rectangle of the real box. Α and v are both influencing factors used to adjust the loss function to take into account the shape and direction of the target box.

[0077] The calculation formula of α is (w G ,h G ) and (w P ,h P ) are the width and height of the real box and the predicted box respectively.

[0078] The category loss is calculated based on the labeled true category and the predicted category (obtained from the three feature maps obtained in step 4-2).

[0079] The training parameters are: the number of iterations is 300 rounds, that is, repeating steps 4-1 to 4-3 300 times, the batch size is 64, the initial learning rate is 0.01, the hardware is RTX4060ti, and 300 rounds of training are performed on this data.

[0080] After training is completed, the model with the smallest loss function, the model with the best effect in the test set, and the model saved in the last round are saved separately. These three models are evaluated on the validation set to obtain the best model, which is also the optimal weight model.

[0081] In practical applications, the best weight model is evaluated using an evaluation data set to obtain an evaluation result, and negative samples in the evaluation data set are determined according to the evaluation result and added to the training set and the test set, and then the step of training and testing the target detection network multiple times using the training set and the test set to obtain a weight model set is returned until the best weight model meets the set requirements, and the best weight model that meets the set requirements is determined to be a garbage bag recognition model, specifically including:

[0082] Collect objects that are similar in shape and color to garbage bags, and take pictures with a camera to create a dataset without labeled boxes.

[0083] Use image data with similar colors for verification. Data that fails the verification will be merged into the original data set as negative samples (unlabeled data) for iterative training. After the negative samples are prepared, return to the training set and test set to train and test the target detection network multiple times to obtain a weight model set until a satisfactory effect is achieved.

[0084] In practical applications, the garbage bag recognition model is used to identify the target image and obtain the color of the garbage bag in the target image, including:

[0085] In the whole system, the edge device uses the opencv library to call the USB camera to obtain the target image, and the target image is sent to the model to obtain the model output result. In order to avoid misjudgment, a memory pool is set in the system to store each detection result in the memory pool. Each color of garbage bag corresponds to a different memory pool. When a garbage bag object of the same color is detected three times in a row in a memory pool, it is determined to be a garbage bag, and then the corresponding color bin door opening signal is sent to let residents throw garbage in the designated garbage bin, so as to correctly urge residents to sort garbage. Because it is a video stream in actual use, that is, a picture frame over time, it is a different picture. The specific processing process of the garbage bag recognition model is to read the image frame through opencv, send the picture into the garbage bag recognition model to obtain three feature maps of different scales, first filter out the anchor frame with low confidence according to the confidence, and then filter out the repeated frames through NMS (Non-Maximum Suppression), and finally get the garbage bag recognition result.

[0086] In actual applications, the garbage bag recognition model can be deployed on the edge device. Compared with the traditional cloud server deployment, the edge deployment can ensure real-time performance, save network load and reduce costs.

[0087] The present invention has the following technical effects:

[0088] By adding hand feature data to the labeled data, the problem of difficulty in recognition caused by too few surface features of garbage bags captured by the camera was overcome, greatly improving the model recognition accuracy.

[0089] Since pictures with similar colors are used as the validation set and the misidentified pictures are used as negative samples for iterative training, the interference caused by similar colors in complex environments is reduced.

[0090] The model is deployed on the edge device and can run offline recognition, avoiding the traffic consumption caused by traditional cloud server reasoning.

[0091] By identifying garbage bags and opening the corresponding bin doors, residents are guided to sort their garbage correctly, which invisibly improves their environmental awareness.

[0092] In one embodiment, a computer device is also provided, including a memory and a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the garbage bag identification method described in the above method embodiments when executing the computer program. The computer device may be a database, and its internal structure diagram may be as follows: Fig.10 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store pending transactions. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data processing method is implemented.

[0093] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the garbage bag identification method described in the above method embodiments is implemented.

[0094] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the garbage bag identification method described in the above method embodiments.

[0095] It should be noted that the object information (including but not limited to object device information, object personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the object or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards.

[0096] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited thereto.

[0097] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0098] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A garbage bag identification method, characterized in that: include: Obtaining a data set, the data set comprising images of portable garbage bags after garbage classification according to the colors of the garbage bags; Annotating the data set with an annotation frame to obtain an annotated data set, wherein the annotation frame selects a hand holding a garbage bag and the garbage bag; Dividing the labeled data set into a training set, a test set, and a validation set; The target detection network is trained and tested multiple times using a training set and a test set to obtain a weight model set; the weight model set includes a trained target detection network corresponding to a minimum loss function value, a trained target detection network with the best recognition result in the test set, and a trained target detection network obtained from the last training; Using the validation set to evaluate the weight model set to obtain the best weight model; The optimal weight model is evaluated using an evaluation data set to obtain an evaluation result, and negative samples in the evaluation data set are determined according to the evaluation result and added to the training set and the test set, and then the step of training and testing the target detection network multiple times using the training set and the test set to obtain a weight model set is returned until the optimal weight model meets the set requirements, and the optimal weight model that meets the set requirements is determined to be a garbage bag recognition model; the evaluation data set includes pictures of objects with the same color as the garbage bags in the data set; The garbage bag recognition model is used to recognize the target image and obtain the color of the garbage bag in the target image.

2. The garbage bag identification method according to claim 1, characterized in that: The target detection network is a Yolov5 network, including: an input layer, a Backbone network, a Neck network and an output layer connected in sequence; The Backbone network includes: C1 module, C2 module, C3 module, C4 module and C5 module; The C1 module includes a first CBS submodule, a second CBS submodule and a first CASP submodule connected in sequence; the C2 module, the C3 module and the C4 module each include a third CBS submodule and a second CASP submodule connected in sequence; the C5 module includes a fourth CBS submodule, three maximum pooling layers each connected to the fourth CBS submodule, and a first concat submodule each connected to the three maximum pooling layers and the fourth CBS submodule; The input end of the first CBS submodule is connected to the output end of the input layer, the output end of the first CASP submodule is connected to the input end of the third CBS submodule in the C2 module; the output end of the second CASP submodule in the C2 module is connected to the input end of the third CBS submodule in the C3 module; the output end of the second CASP submodule in the C3 module is connected to the input end of the third CBS submodule in the C4 module; the output end of the second CASP submodule in the C4 module is connected to the input end of the fourth CBS submodule in the C5 module; The Neck network includes: an M1 module, an M2 module, an M3 module, an N1 module, a second concat submodule, an N3 module, a third concat submodule and an N5 module; The M1 module, the M2 module and the M3 module all include a fifth CBS submodule, a third CASP submodule and an upsampling module connected in sequence; the N1 module, the N3 module and the N5 module all include a sixth CBS submodule and a fourth CASP submodule connected in sequence; The input end of the fifth CBS submodule in the M1 module is connected to the output end of the first concat submodule in the C5 module; the up-sampled output end in the M1 module is connected to the input end of the fifth CBS submodule of the M2 module and the input end of the third concat submodule respectively; The input end of the fifth CBS submodule in the M2 module is connected to the output end of the second CASP submodule in the C3 module; the output end of the upsampling in the M2 module is connected to the input end of the fifth CBS submodule in the M3 module and the input end of the second concat submodule respectively; The input end of the fifth CBS submodule in the M3 module is connected to the output end of the first CASP submodule; the output end of the upsampling in the M3 module is connected to the input end of the sixth CBS submodule in the N1 module; the output end of the fourth CASP submodule in the N1 module is respectively connected to the input end of the second concat submodule and the input end of the output layer; the output end of the second concat submodule is connected to the input end of the sixth CBS submodule in the N3 module; the output end of the fourth CASP submodule in the N3 module is respectively connected to the input end of the third concat submodule and the input end of the output layer; the output end of the third concat submodule is connected to the input end of the sixth CBS submodule in the N5 module; the output end of the fourth CASP submodule in the N5 module is connected to the input end of the output layer.

3. The garbage bag identification method according to claim 2, characterized in that: The first CASP submodule, the second CASP submodule, the third CASP submodule and the fourth CASP submodule all include: a seventh CBS submodule, an eighth CBS submodule, a Resx submodule, a CA attention mechanism, a fourth concat submodule and a ninth CBS submodule; the input end of the seventh CBS submodule is connected to the input end of the eighth CBS submodule, the output end of the seventh CBS submodule is connected to the input end of the Resx submodule, the output end of the Resx submodule is connected to the input end of the fourth concat submodule, and the output end of the fourth concat submodule is connected to the input end of the ninth CBS submodule; the output end of the eighth CBS submodule is connected to the input end of the CA attention mechanism, and the input end of the CA attention mechanism is connected to the input end of the fourth concat submodule.

4. The garbage bag identification method according to claim 3, characterized in that: The first CBS submodule, the second CBS submodule, the third CBS submodule, the fourth CBS submodule, the fifth CBS submodule, the sixth CBS submodule, the seventh CBS submodule, the eighth CBS submodule and the ninth CBS submodule each include: a first convolution, a second convolution, a BN layer, a Silu activation function and a third convolution connected in sequence.

5. The garbage bag identification method according to claim 3, characterized in that: The Resx submodule includes a tenth CBS submodule, a CBS module and a jump connection; the output end of the tenth CBS submodule is connected to the input end of the CBS module and the input end of the jump connection, and the output end of the CBS module is connected to the input end of the jump connection.

6. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the garbage bag identification method according to any one of claims 1 to 5.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the garbage bag identification method according to any one of claims 1 to 5 is implemented.

8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the garbage bag identification method according to any one of claims 1 to 5 is implemented.