Training method for garbage classification model, garbage classification method and device

By resampling the garbage image sample set and training the smooth-aware model, the loss value is smoothed, and the overfitting problem caused by label noise in the existing garbage classification model is solved, and the accuracy and robustness of the model are improved.

CN114187470BActive Publication Date: 2025-06-24中原动力智能机器人有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111358578.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-12
Publication Date
2025-06-24
Estimated Expiration
2041-11-12

AI Technical Summary

Technical Problem

The existing garbage classification model reduces the accuracy of the model on clean test data due to label noise.

Method used

By resampling the pre-labeled garbage image sample set, an equalized sample set is obtained, and the initial smooth-aware model and garbage classification model are trained based on the sample set. The smooth-aware model is used to smooth the loss value, and the model parameters are updated until the convergence condition is reached.

Benefits of technology

It improves the accuracy of the classification results of the model, overcomes the disadvantages of artificial selection of hyperparameters, and reduces the risk of model overfitting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114187470B_ABST
    Figure CN114187470B_ABST
Patent Text Reader

Abstract

The present application discloses a training method, a garbage classification method and a device for a garbage classification model. By resampling a pre-annotated garbage image sample set, a balanced sample set is obtained; based on the garbage image sample set and the balanced sample set, a preset initial smooth perception model is trained until the initial smooth perception model reaches a first preset convergence condition, and a target smooth perception model is obtained; based on the garbage image sample set, an iterative training is performed on a preset first garbage classification model to obtain a first loss value, and the target smooth perception model is used to smooth the first loss value to obtain a second loss value; finally, according to the second loss value, the model parameters of the first garbage classification model are updated until the first garbage classification model reaches a second preset convergence condition, and a target garbage classification model is obtained, thereby improving the accuracy of the classification result of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of robots, and in particular, to a method for training a garbage classification model, a garbage classification method, and a device. Background Art

[0002] Garbage classification is the core function of intelligent cleaning robots. The types of garbage in the collected pictures are inferred through a deep convolutional neural network, and devices such as robotic arms are used to clean different types of garbage according to the inference results. The inference ability of the deep convolutional neural network directly determines the garbage classification performance of intelligent cleaning robots.

[0003] The training set of the garbage classification model usually contains hundreds of thousands or even millions of training samples, and several annotators are required to label the types of garbage in the training samples. Since the types of some garbage are easily confused and there are differences in the cognition of the annotators, a certain proportion of the sample types are mislabeled, and there is a large amount of label noise, which leads to overfitting of the deep convolutional neural network to the dataset with noise, and thus greatly reduces the accuracy of the model on clean test data. Summary of the Invention

[0004] The present application provides a method for training a garbage classification model, a garbage classification method, and a device to solve the technical problem that the existing garbage classification model has low classification result accuracy.

[0005] To solve the above technical problem, an embodiment of the present application provides a method for training a garbage classification model, including:

[0006] Resampling the pre-annotated garbage image sample set to obtain a balanced sample set;

[0007] Based on the garbage image sample set and the balanced sample set, training a preset initial smoothed perception model until the initial smoothed perception model reaches a first preset convergence condition to obtain a target smoothed perception model;

[0008] Based on the garbage image sample set, iteratively training a preset first garbage classification model to obtain a first loss value;

[0009] Using the target smoothed perception model to smooth the first loss value to obtain a second loss value;

[0010] According to the second loss value, updating the model parameters of the first garbage classification model until the first garbage classification model reaches a second preset convergence condition to obtain a target garbage classification model.

[0011] In this embodiment, by resampling a pre-annotated garbage image sample set, an equilibrium sample set is obtained to improve the precision and recall rate of positive and negative samples. Based on the garbage image sample set and the equilibrium sample set, a preset initial smooth perception model is trained until the initial smooth perception model reaches a first preset convergence condition, and a target smooth perception model is obtained, so that the target smooth perception model learns the corresponding smooth coefficient. Based on the garbage image sample set, an iterative training is performed on a preset first garbage classification model to obtain a first loss value, and the target smooth perception model is used to smooth the first loss value to obtain a second loss value, so as to solve the problem that label noise easily causes model overfitting through smoothing and improve the model accuracy. Finally, according to the second loss value, the model parameters of the first garbage classification model are updated until the first garbage classification model reaches a second preset convergence condition, and a target garbage classification model is obtained, thereby being able to automatically learn the hyperparameters of the training sample smooth perception network from the training data, overcoming the drawbacks of manual selection and improving the accuracy of the classification result of the model.

[0012] In one embodiment, the training of the preset initial smooth perception model based on the garbage image sample set and the equilibrium sample set until the initial smooth perception model reaches a first preset convergence condition to obtain a target smooth perception model includes:

[0013] Based on the garbage image sample set, a preset second garbage classification model is trained to obtain a third loss value, and the model structure of the second garbage classification model is the same as that of the first garbage classification model;

[0014] The initial smooth perception model is used to smooth the third loss value to obtain a fourth loss value;

[0015] According to the fourth loss value, the model parameters of the second garbage classification model are updated to obtain a second target garbage classification model;

[0016] Based on the equilibrium sample set, the second garbage classification model is trained to obtain a fifth loss value;

[0017] According to the fifth loss value, the model parameters of the initial smooth perception model are updated until the initial smooth perception model reaches the first preset convergence condition, and a target smooth perception model is obtained.

[0018] In this embodiment, a second garbage classification model with the same structure as the first garbage classification model is copied to simulate the classification training process of the first garbage classification model and cooperate with the initial smooth perception model for training, so that the target smooth perception model learns the smooth coefficient to avoid human experience factors and make the model processing process more objective.

[0019] In one embodiment, iteratively training a preset first garbage classification model based on the garbage image sample set to obtain a first loss value includes:

[0020] Using the first garbage classification model to perform garbage classification recognition on each garbage image sample in the garbage image sample set to obtain the garbage classification result of each garbage image sample;

[0021] Based on a first loss function, calculating the first loss value according to the garbage classification result, and the first loss function is:

[0022]

[0023] where N represents the total amount of the garbage image samples, Loss i represents the loss function of the i-th garbage image sample, represents the sign function when the i-th garbage image sample belongs to the j-th category, represents the probability when the i-th garbage image sample belongs to the j-th category.

[0024] In this embodiment, cross entropy is used as the loss function. For the gradient of the last layer weights, it is no longer related to the derivative of the activation function and is only proportional to the difference between the output value and the true value. At this time, the convergence is relatively fast, which speeds up the update of the entire weight matrix.

[0025] In one embodiment, using the first garbage classification model to perform garbage classification recognition on each garbage image sample in the garbage image sample set to obtain the garbage classification result of each garbage image sample includes:

[0026] Using the first garbage classification model to determine the confidence scores when the garbage image sample belongs to each category;

[0027] Performing normalization processing on the confidence scores to obtain the probabilities when the garbage image sample belongs to each category.

[0028] In this embodiment, by performing normalization processing on the confidence scores, the multi-classification task of the garbage classification model is realized.

[0029] In one embodiment, using the target smoothing perception model to perform smoothing processing on the first loss value to obtain a second loss value includes:

[0030] Using the target smoothing perception model to determine the smoothing coefficient corresponding to the first loss value;

[0031] Based on a second loss function, calculating the second loss value according to the smoothing coefficient, and the second loss function is:

[0032]

[0033] Among them, N represents the total number of garbage image samples in the garbage image sample set, and Loss i represents the loss function of the i-th garbage image sample, represents the sign function when the i-th garbage image sample belongs to the j-th category, represents the probability when the i-th garbage image sample belongs to the j-th category, and ε j represents the smoothing coefficient of the j-th category.

[0034] In this embodiment, by adding a smoothing coefficient, the first loss value is smoothed. Different from the traditional loss value that uses empirical tuning, the smoothing process can make the adjustment process of the loss value more objective, thereby improving the classification performance of the model.

[0035] In a second aspect, an embodiment of the present application provides a garbage classification method, including:

[0036] Obtain a garbage image;

[0037] Based on the target garbage classification model, classify and identify the garbage image to obtain initial classification data, and the target garbage classification model is trained by the training method described in the first aspect;

[0038] Perform smoothing processing and full connection on the initial classification data to obtain a target classification result.

[0039] In a third aspect, an embodiment of the present application provides a training device for a garbage classification model, including:

[0040] A sampling module for resampling a pre-annotated garbage image sample set to obtain a balanced sample set;

[0041] A first training module for training a preset initial smoothed perception model based on the garbage image sample set and the balanced sample set until the initial smoothed perception model reaches a first preset convergence condition to obtain a target smoothed perception model;

[0042] A second training module for iteratively training a preset first garbage classification model based on the garbage image sample set to obtain a first loss value;

[0043] A first smoothing module for smoothing the first loss value by using the target smoothed perception model to obtain a second loss value;

[0044] An update module for updating the model parameters of the first garbage classification model according to the second loss value until the first garbage classification model reaches a second preset convergence condition to obtain a target garbage classification model.

[0045] In a fourth aspect, an embodiment of the present application provides a waste sorting device, including:

[0046] An acquisition module, configured to acquire waste images;

[0047] An identification module, configured to perform classification and identification on the waste images based on a target waste sorting model to obtain initial classification data, where the target waste sorting model is trained by the training method described in the first aspect;

[0048] A second smoothing module, configured to perform smoothing processing on the initial classification data to obtain a target classification result.

[0049] In a fifth aspect, an embodiment of the present application provides a computer device, including a processor and a memory. The memory is used to store a computer program, and when the computer program is executed by the processor, it implements the training method of the waste sorting model described in the first aspect, or the waste sorting method described in the second aspect.

[0050] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, it implements the training method of the waste sorting model described in the first aspect, or the waste sorting method described in the second aspect.

[0051] It should be noted that for the beneficial effects of the above second aspect to the sixth aspect, please refer to the relevant descriptions of the first aspect above, and details are not described herein again. Description of the Drawings

[0052] Figure 1 It is a schematic structural diagram of a waste sorting system provided by an embodiment of the present application;

[0053] Figure 2 It is a schematic flowchart of a training method of a waste sorting model provided by an embodiment of the present application;

[0054] Figure 3 It is a schematic flowchart of a waste sorting method provided by an embodiment of the present application;

[0055] Figure 4 It is a schematic structural diagram of a training device of a waste sorting model provided by an embodiment of the present application;

[0056] Figure 5 It is a schematic structural diagram of a waste sorting device provided by an embodiment of the present application;

[0057] Figure 6 It is a schematic structural diagram of a computer device provided by an embodiment of the present application. Detailed Embodiments

[0058] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0059] As recorded in the related art, the training set of the garbage classification model usually contains hundreds of thousands or even millions of training samples, and several annotators are required to label the garbage categories in the training samples. Since the categories of some garbage are easy to confuse and there are differences in the cognition of the annotators, a certain proportion of the sample categories are mislabeled, and there is a large amount of label noise, which leads to overfitting of the deep convolutional neural network to the noisy data set, and then greatly reduces the accuracy of the model on the clean test data.

[0060] The current methods for solving model overfitting and performance degradation caused by label noise mainly include:

[0061] 1. Designing a robust loss function: By adapting the loss function, the performance of the model after training on the data set with noisy labels is made equivalent to the performance after training on the data set without noisy labels, such as Generalized Cross Entropy, Symmetric Cross Entropy, etc. However, these adapted loss functions are only applicable to simple situations, that is, application scenarios with relatively simple tasks and small amounts of data.

[0062] 2. Designing a robust network architecture: Including a dedicated architecture for estimating the label noise transition probability in the deep convolutional neural network, such as a generative adversarial network, but such methods are often difficult to train and the effect improvement is not obvious.

[0063] 3. Regularization means such as weight decay, pruning, and batch normalization: These methods are very convenient to use and only require minor modifications to the training. They have good effects when facing a small amount of noisy data, but have poor effects when facing slightly more noise.

[0064] 4. Adjusting the loss value: Adjust the influence of all training samples on the loss value before updating the parameters. The loss value can be adjusted by estimating the label transition matrix, or different weights can be assigned to different samples, or the categories of the samples can be adjusted to affect the final loss value. However, the current adjustment of the loss value often depends on the tuning experience.

[0065] 5. Sample selection: Directly select samples and discard the samples suspected of noise. Although such methods will not introduce mislabeled samples, they will inevitably discard some correctly labeled samples.

[0066] To this end, the embodiments of the present application provide a training method for a garbage classification model, a garbage classification method and a device. By resampling a pre-annotated garbage image sample set, a balanced sample set is obtained to improve the precision and recall rate of positive and negative samples; based on the garbage image sample set and the balanced sample set, a preset initial smooth perception model is trained until the initial smooth perception model reaches a first preset convergence condition, and a target smooth perception model is obtained, so that the target smooth perception model learns the corresponding smooth coefficient; based on the garbage image sample set, an iterative training is performed on a preset first garbage classification model to obtain a first loss value, and the target smooth perception model is used to smooth the first loss value to obtain a second loss value, so as to solve the problem that label noise easily causes model overfitting through smoothing processing and improve the model accuracy; finally, according to the second loss value, the model parameters of the first garbage classification model are updated until the first garbage classification model reaches a second preset convergence condition, and a target garbage classification model is obtained, so that the hyperparameters of the training sample smooth perception network can be automatically learned from the training data, overcoming the disadvantages of manual selection and improving the accuracy of the classification result of the model.

[0067] Refer to Figure 1 , Figure 1 FIG. shows a schematic structural diagram of a garbage classification system provided by an embodiment of the present application. The garbage classification system includes a camera module, an edge computing module, a garbage cleaning module, a central control module, a positioning and navigation module, a motion control module, and a communication module.

[0068] Camera module: used to complete the shooting of road surface garbage images and transmit data to the edge computing module, which can both receive instructions from the central control module and feedback its working status to the central control module.

[0069] Edge computing module: used to perform inference on the received image data using a deep learning model and output the inference result to the central control module. Exemplarily, the edge computing module is selected as: NVIDIA embedded Linux high-performance computer AGX Xavier (8-core NVIDIA Carmel ARMv8.2 64-bit CPU, a 512-core Volta architecture GPU composed of 8 streaming multiprocessors).

[0070] Garbage cleaning module: used to receive instructions from the central control module, operate the corresponding garbage cleaning work, move to the designated position, complete the garbage cleaning, and can feedback its working status to the central control module. This module mainly includes cleaning tools such as robotic arms and vacuum cleaners.

[0071] Central control module: responsible for coordinating the work of the other modules.

[0072] Positioning and navigation module: It has the data of the robot's running route built-in, senses the environment in real time, and provides data for the central control module to make decisions such as obstacle avoidance and movement; it can both receive instructions from the central control module and feedback its working status to the central control module. This module mainly includes sensor devices such as lidar and SLAM.

[0073] Motion control module: According to the instructions of the central control module, it completes the movement of the robot and can feedback its working status to the central control module. This module is mainly composed of a wheel-legged motion chassis.

[0074] Communication module: As the interface for the robot to communicate with the outside world, it can communicate bidirectionally with the central control module, receive external instructions, and also feedback messages to the outside world. This module includes wireless transmission, 5G circuits, etc.

[0075] In addition, this garbage classification system also includes support modules such as a power supply, which will not be elaborated here.

[0076] Refer to Figure 2 , Figure 2 which is a schematic flow diagram of a method for training a garbage classification model provided by an embodiment of this application. The method for training the garbage classification model in the embodiment of this application can be applied to computer devices, including but not limited to smart phones, tablet computers, laptop computers, and intelligent robots. Preferably, it is an intelligent robot, and this robot is integrated with the above-mentioned garbage classification system. As Figure 2 shown, the method for training the garbage classification model includes steps S201 to S205, which are described in detail as follows:

[0077] Step S201: Resample the pre-annotated garbage image sample set to obtain a balanced sample set.

[0078] In this step, the garbage image sample set is a sample set manually annotated, which has label noise and belongs to an unbalanced sample set. Since the garbage image sample set has label noise, but the number of negative samples is relatively small compared to positive samples, this will lead to the sample distribution of the sample set used for training being inconsistent with the expected sample distribution during testing, or the weights of different sample categories in the training stage being inconsistent with those in the testing stage. Therefore, in this embodiment, the garbage image sample set is resampled to make the samples in the sample set balanced.

[0079] Optionally, the resampling method can be random sampling, resampling based on the SMOTE algorithm, resampling based on InformedUndersampling, resampling based on clustering, etc.

[0080] Step S202: Based on the garbage image sample set and the balanced sample set, train a preset initial smooth perception model until the initial smooth perception model reaches a first preset convergence condition, and obtain a target smooth perception model.

[0081] In this step, the initial smooth perception model is a smooth perception model constructed based on a multi-layer perceptron (MLP) as the basic model. It is used to learn the smooth coefficient of the sample label, so that when training the first garbage classification model later, the loss function of the first garbage classification model can be smoothed to play a role in suppressing model overfitting.

[0082] Optionally, train the first garbage classification model with the garbage image sample set and the balanced sample set, and update the model parameters of the initial smooth perception model using the loss function of the garbage classification model until the model converges.

[0083] Step S203: Based on the garbage image sample set, perform iterative training on a preset first garbage classification model to obtain a first loss value.

[0084] In this step, the first garbage classification model is a garbage classification model constructed based on a deep neural network as the basic model, which is used to classify the garbage in the image. It can be understood that iterative training is a process of training a model, updating the model parameters of the model, and using the model with updated model parameters as a new model for continuous training. Each training obtains a first loss value, and each obtained first loss value is smoothed and then used to update the model parameters of the current training model.

[0085] Exemplarily, input the garbage image sample set into the first garbage classification model for processing, output the garbage classification prediction value, calculate the first loss value between the garbage classification prediction value and the actual classification value in the labeled data, smooth the first loss value to obtain a second loss value, and update the model parameters of the first garbage classification model according to the second loss value. Then, continue to train the updated first garbage classification model with the garbage image sample set until the first garbage classification model converges.

[0086] Step S204: Use the target smooth perception model to smooth the first loss value to obtain a second loss value.

[0087] In this step, the smoothing process is to process the loss value using the smooth coefficient of the target smooth perception model. Compared with the current smooth coefficient that needs to be set based on human experience, in this embodiment, the perceptron is used to learn the noise characteristics of the sample label to learn the smooth coefficient of the sample label, thereby reducing the weight of the real sample label when calculating the loss value and effectively suppressing model overfitting.

[0088] Optionally, input the garbage classification prediction value output by the first garbage classification model into a loss function constructed based on a smoothing coefficient for processing to obtain a second loss value.

[0089] Step S205: According to the second loss value, update the model parameters of the first garbage classification model until the first garbage classification model reaches a second preset convergence condition to obtain a target garbage classification model.

[0090] In this step, the preset convergence condition is a condition indicating that the model training is completed. For example, if the loss value (expected error) obtained by the loss function is less than a preset loss threshold, it indicates convergence, or the number of network iterations reaches a preset number. It can be generally understood that the smaller the loss value, the more accurate the feature vector extracted by the model. Exemplarily, when the second loss value is greater than or equal to the preset loss threshold, adjust the model parameters in the first garbage classification model and return to execute Step S103 and Step S104; when the second loss value is less than the preset loss threshold, it indicates that the training of the first garbage classification model is completed, and a trained target garbage classification model is obtained.

[0091] In one embodiment, on the basis of Figure 1 the embodiment shown, the above Step S202 includes:

[0092] Train a preset second garbage classification model based on the garbage image sample set to obtain a third loss value, where the second garbage classification model has the same model structure as the first garbage classification model;

[0093] Use the initial smoothing perception model to smooth the third loss value to obtain a fourth loss value;

[0094] According to the fourth loss value, update the model parameters of the second garbage classification model to obtain a second target garbage classification model;

[0095] Train the second garbage classification model based on the balanced sample set to obtain a fifth loss value;

[0096] According to the fifth loss value, update the model parameters of the initial smoothing perception model until the initial smoothing perception model reaches the first preset convergence condition to obtain a target smoothing perception model.

[0097] In this embodiment, the second garbage classification model has exactly the same model structure as the first garbage classification model. It can be simply understood that by performing a copy operation on the first garbage classification model, the second garbage classification model is obtained. The second garbage classification model learns the sample feature differences between the unbalanced sample set and the balanced sample set, and updates the model parameters of the initial smoothing perception model, enabling the initial smoothing perception model to learn the smoothing coefficient of the sample labels.

[0098] Optionally, the first preset convergence condition may be that the loss values of both the second garbage classification model and the initial smoothed perception model are less than a preset loss threshold, or the sum of the two is less than a preset threshold, or the number of iterations reaches a preset number.

[0099] In one embodiment, based on the embodiment shown in Figure 1 Step S203 described above includes:

[0100] Using the first garbage classification model, perform garbage classification recognition on each garbage image sample in the garbage image sample set to obtain the garbage classification result of each garbage image sample;

[0101] Based on the first loss function, calculate the first loss value according to the garbage classification result, and the first loss function is:

[0102]

[0103] where N represents the total number of the garbage image samples, Loss i represents the loss function of the i-th garbage image sample, represents the sign function when the i-th garbage image sample belongs to the j-th category, represents the probability when the i-th garbage image sample belongs to the j-th category, and K is the total number of categories.

[0104] In this embodiment, the first loss function is the cross-entropy loss value.

[0105] Optionally, the step of using the first garbage classification model to perform garbage classification recognition on each garbage image sample in the garbage image sample set to obtain the garbage classification result of each garbage image sample includes:

[0106] Using the first garbage classification model, determine the confidence scores when the garbage image sample belongs to each category;

[0107] Perform normalization processing on the confidence scores to obtain the probabilities when the garbage image sample belongs to each category.

[0108] In this embodiment, in a multi-classification task, the deep neural network will output the confidence scores corresponding to each category of the current data. These scores are normalized through softmax, and finally the probabilities of the current data belonging to each category will be obtained. For example, the probability calculation of the i-th sample belonging to the j-th category is as follows:

[0109]

[0110] where Represents the confidence score that the i-th sample belongs to the j-th class. Represents the probability that the i-th sample belongs to the j-th class, and K represents the total number of classes.

[0111] In one embodiment, the using the target smoothing perception model to smooth the first loss value to obtain a second loss value includes:

[0112] Using the target smoothing perception model to determine the smoothing coefficient corresponding to the first loss value;

[0113] Based on the second loss function, calculate the second loss value according to the smoothing coefficient, and the second loss function is:

[0114]

[0115] Where N represents the total amount of garbage image samples in the garbage image sample set, and Loss i Represents the loss function of the i-th garbage image sample. Represents the sign function when the i-th garbage image sample belongs to the j-th class. Represents the probability when the i-th garbage image sample belongs to the j-th class, and ε j Represents the smoothing coefficient of the j-th class, and K is the total number of classes.

[0116] In this embodiment, due to the serious label noise in the garbage image sample set, using the cross-entropy loss value of the first loss function to update the model parameters is likely to cause the model to overfit. Therefore, to solve the problem of model overfitting caused by label noise, a label smoothing strategy is adopted. By adding a smoothing coefficient, the weight of the true sample label in calculating the loss function is reduced to suppress overfitting.

[0117] Refer to Figure 3 , Figure 3 is a schematic flowchart of a garbage classification method provided by an embodiment of the present application. The training method of the garbage classification model of the embodiment of the present application can be applied to a computer device, and this computer device is preferably an intelligent robot, and this robot is integrated with the above garbage classification system. As Figure 3 shown, the garbage classification method includes steps S301 to S303, which are described in detail as follows:

[0118] Step S301, obtain a garbage image;

[0119] In this step, exemplarily, for the garbage classification method applied to an intelligent robot, the intelligent robot moves according to a preset route. During the movement, the camera module in the above garbage classification system can collect the garbage images on the ground and send the collected garbage images to the edge computing module for inference.

[0120] Step S302: Based on the target garbage classification model, classify and identify the garbage image to obtain initial classification data. The target garbage classification model is trained based on Figure 2 the training method shown in the embodiment.

[0121] In this step, input the garbage image into the target garbage classification model, and use operations such as convolution, pooling, and sampling by the edge computing module to classify and identify the garbage image, and output the initial classification data.

[0122] Step S303: Smooth and fully connect the initial classification data to obtain the target classification result.

[0123] In this step, use the target smoothing perception model to smooth the initial classification data to reduce the influence of noise, and then fully connect the smoothed initial classification data to obtain the target classification result.

[0124] To execute the training method of the garbage classification model corresponding to the above method embodiment to achieve the corresponding functions and technical effects. Refer to Figure 4 , Figure 4 FIG. shows a structural block diagram of a training device for a garbage classification model provided by an embodiment of the present application. For ease of description, only parts related to this embodiment are shown. The training device for the garbage classification model provided by the embodiment of the present application includes:

[0125] A sampling module 401, configured to resample a pre-annotated garbage image sample set to obtain a balanced sample set;

[0126] A first training module 402, configured to train a preset initial smoothing perception model based on the garbage image sample set and the balanced sample set until the initial smoothing perception model reaches a first preset convergence condition to obtain a target smoothing perception model;

[0127] A second training module 403, configured to iteratively train a preset first garbage classification model based on the garbage image sample set to obtain a first loss value;

[0128] A first smoothing module 404, configured to use the target smoothing perception model to smooth the first loss value to obtain a second loss value;

[0129] An update module 405, configured to update the model parameters of the first garbage classification model according to the second loss value until the first garbage classification model reaches a second preset convergence condition to obtain a target garbage classification model.

[0130] In one embodiment, the first training module 402 includes:

[0131] The first training unit is configured to train a preset second garbage classification model based on the garbage image sample set to obtain a third loss value, where the model structure of the second garbage classification model is the same as that of the first garbage classification model;

[0132] The processing unit is configured to smooth the third loss value by using the initial smooth perception model to obtain a fourth loss value;

[0133] The first updating unit is configured to update the model parameters of the second garbage classification model according to the fourth loss value to obtain a second target garbage classification model;

[0134] The second training unit is configured to train the second garbage classification model based on the balanced sample set to obtain a fifth loss value;

[0135] The second updating unit is configured to update the model parameters of the initial smooth perception model according to the fifth loss value until the initial smooth perception model meets the first preset convergence condition to obtain a target smooth perception model.

[0136] In one embodiment, the second training module 403 includes:

[0137] The recognition unit is configured to use the first garbage classification model to perform garbage classification recognition on each garbage image sample in the garbage image sample set to obtain the garbage classification result of each garbage image sample;

[0138] The first calculation unit is configured to calculate the first loss value based on a first loss function according to the garbage classification result, where the first loss function is:

[0139]

[0140] where N represents the total number of the garbage image samples, Loss i represents the loss function of the i-th garbage image sample, represents the sign function when the i-th garbage image sample belongs to the j-th category, represents the probability when the i-th garbage image sample belongs to the j-th category.

[0141] In one embodiment, the recognition unit includes:

[0142] The determination subunit is configured to use the first garbage classification model to determine the confidence scores when the garbage image sample belongs to each category;

[0143] The processing subunit is configured to perform normalization processing on the confidence scores to obtain the probabilities when the garbage image sample belongs to each category.

[0144] In one embodiment, the first smoothing module 404 includes:

[0145] A determination unit, configured to use the target smoothing perception model to determine a smoothing coefficient corresponding to the first loss value;

[0146] A second calculation unit, configured to calculate the second loss value based on a second loss function according to the smoothing coefficient, where the second loss function is:

[0147]

[0148] where N represents the total number of garbage image samples in the garbage image sample set, Loss i represents the loss function of the i-th garbage image sample, represents the sign function when the i-th garbage image sample belongs to the j-th category, represents the probability when the i-th garbage image sample belongs to the j-th category, and ε j represents the smoothing coefficient of the j-th category.

[0149] The above-mentioned training device for the garbage classification model can implement the training method of the garbage classification model in the above method embodiment. The optional items in the above method embodiment are also applicable to this embodiment, which will not be elaborated here. The remaining content of the embodiments of the present application can refer to the content of the above method embodiment and will not be repeated in this embodiment.

[0150] In order to execute the corresponding garbage classification method in the above method embodiment to achieve the corresponding functions and technical effects. Refer to Figure 5 , Figure 5 shows a structural block diagram of a garbage classification device provided by an embodiment of the present application. For the sake of convenience of description, only the parts related to this embodiment are shown. The garbage classification device provided by the embodiment of the present application includes:

[0151] An acquisition module 501, configured to acquire garbage images;

[0152] An identification module 502, configured to perform classification and identification on the garbage images based on a target garbage classification model to obtain initial classification data, where the target garbage classification model is trained based on the training method shown in Figure 2 the embodiment;

[0153] A second smoothing module 503, configured to perform smoothing processing on the initial classification data to obtain a target classification result.

[0154] The above garbage classification device can implement the garbage classification method of the above method embodiment. The optional items in the above method embodiment are also applicable to this embodiment and will not be elaborated here. The remaining content of the embodiment of the present application can refer to the content of the above method embodiment and will not be repeated in this embodiment.

[0155] Figure 6 It is a schematic structural diagram of a computer device provided by an embodiment of the present application. As Figure 6 shown, the computer device 6 of this embodiment includes: at least one processor 60 ( Figure 6 only one is shown in the figure), a processor, a memory 61, and a computer program 62 stored in the memory 61 and operable on the at least one processor 60. When the processor 60 executes the computer program 62, it implements the steps in any of the above method embodiments.

[0156] The computer device 6 may be a computing device such as a smart phone, a tablet computer, a desktop computer, and a smart robot. The computer device may include but is not limited to the processor 60 and the memory 61. Those skilled in the art can understand that Figure 6 merely examples of the computer device 6, which do not constitute a limitation on the computer device 6, and may include more or fewer components than shown in the figure, or combine some components, or different components. For example, it may also include input / output devices, network access devices, etc.

[0157] The so-called processor 60 may be a central processing unit (CPU), and the processor 60 may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0158] The memory 61 may be an internal storage unit of the computer device 6 in some embodiments, such as a hard disk or memory of the computer device 6. The memory 61 may also be an external storage device of the computer device 6 in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the computer device 6. Further, the memory 61 may also include both the internal storage unit and the external storage device of the computer device 6. The memory 61 is used to store an operating system, application programs, a BootLoader, data, and other programs, such as the program code of the computer program. The memory 61 may also be used to temporarily store data that has been output or will be output.

[0159] In addition, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0160] An embodiment of the present application provides a computer program product, and when the computer program product runs on a computer device, the computer device is caused to execute the steps in each of the above method embodiments.

[0161] In several embodiments provided by the present application, it can be understood that each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, the program segment, or the part of code includes one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the block may occur in a different order from that marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved.

[0162] When the above-mentioned functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0163] The specific embodiments described above further elaborate on the purpose, technical solution, and beneficial effects of this application. It should be understood that the above are only specific embodiments of this application and are not used to limit the protection scope of this application. In particular, it is pointed out that for those skilled in the art, any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of this application should be included in the protection scope of this application.

Claims

1. A training method for a garbage classification model, characterized in that, Including: Resampling a pre-annotated set of garbage image samples to obtain a balanced sample set; Based on the garbage image sample set and the balanced sample set, training a preset initial smooth perception model until the initial smooth perception model reaches a first preset convergence condition to obtain a target smooth perception model, including: training a preset second garbage classification model based on the garbage image sample set to obtain a third loss value, where the model structure of the second garbage classification model is the same as that of the first garbage classification model; using the initial smooth perception model to smooth the third loss value to obtain a fourth loss value; according to the fourth loss value, updating the model parameters of the second garbage classification model to obtain a second target garbage classification model; training the second garbage classification model based on the balanced sample set to obtain a fifth loss value; according to the fifth loss value, updating the model parameters of the initial smooth perception model until the initial smooth perception model reaches the first preset convergence condition to obtain a target smooth perception model; where the initial smooth perception model is a smooth perception model constructed based on a perceptron, which is used to learn the smooth coefficient of the sample label, so as to smooth the loss function of the first garbage classification model during subsequent training of the first garbage classification model, playing a role in suppressing model overfitting; Based on the garbage image sample set, iteratively training a preset first garbage classification model to obtain a first loss value; Using the target smooth perception model to smooth the first loss value to obtain a second loss value; According to the second loss value, updating the model parameters of the first garbage classification model until the first garbage classification model reaches a second preset convergence condition to obtain a target garbage classification model; Wherein, the using the target smooth perception model to smooth the first loss value to obtain a second loss value includes: Using the target smooth perception model to determine the smooth coefficient corresponding to the first loss value; Based on a second loss function, calculating the second loss value according to the smooth coefficient, and the second loss function is: Where N represents the total number of garbage image samples in the garbage image sample set, Loss i represents the loss function of the i-th garbage image sample, represents the sign function when the i-th garbage image sample belongs to the j-th category, represents the probability when the i-th garbage image sample belongs to the j-th category, ε j represents the smoothing coefficient of the j-th category, and K is the total number of categories.

2. The training method of the garbage classification model according to claim 1, wherein, The based on the garbage image sample set, iteratively training a preset first garbage classification model to obtain a first loss value includes: Using the first garbage classification model to perform garbage classification recognition on each garbage image sample in the garbage image sample set to obtain the garbage classification result of each garbage image sample; Based on a first loss function, calculating the first loss value according to the garbage classification result, and the first loss function is: Among them, N represents the total amount of the garbage image samples, Loss i represents the loss function of the i-th garbage image sample, represents the sign function when the i-th garbage image sample belongs to the j-th category, represents the probability when the i-th garbage image sample belongs to the j-th category, and K is the total number of categories.

3. The training method of the garbage classification model according to claim 2, characterized in that, The using the first garbage classification model to perform garbage classification recognition on each garbage image sample in the garbage image sample set to obtain the garbage classification result of each garbage image sample includes: Using the first garbage classification model to determine the confidence scores when the garbage image sample belongs to each category; Normalizing the confidence scores to obtain the probabilities when the garbage image sample belongs to each category.

4. A garbage classification method, characterized in that, Including: Obtaining garbage images; Based on the target garbage classification model, classify and identify the garbage image to obtain initial classification data, where the target garbage classification model is trained based on the training method described in any one of claims 1 to 3; Perform smoothing processing and full connection on the initial classification data to obtain the target classification result.

5. A training device for a garbage classification model, characterized in that, It includes: A sampling module for resampling a pre-annotated garbage image sample set to obtain a balanced sample set; A first training module for training a preset initial smoothing perception model based on the garbage image sample set and the balanced sample set until the initial smoothing perception model reaches a first preset convergence condition to obtain a target smoothing perception model, including: training a preset second garbage classification model based on the garbage image sample set to obtain a third loss value, where the model structure of the second garbage classification model is the same as that of the first garbage classification model; using the initial smoothing perception model to perform smoothing processing on the third loss value to obtain a fourth loss value; according to the fourth loss value, updating the model parameters of the second garbage classification model to obtain a second target garbage classification model; training the second garbage classification model based on the balanced sample set to obtain a fifth loss value; according to the fifth loss value, updating the model parameters of the initial smoothing perception model until the initial smoothing perception model reaches the first preset convergence condition to obtain a target smoothing perception model; where the initial smoothing perception model is a smoothing perception model constructed based on a perceptron, which is used to learn the smoothing coefficient of the sample label, so as to perform smoothing processing on the loss function of the first garbage classification model during the training of the first garbage classification model, playing a role in suppressing model overfitting; A second training module for iteratively training a preset first garbage classification model based on the garbage image sample set to obtain a first loss value; A first smoothing module for using the target smoothing perception model to perform smoothing processing on the first loss value to obtain a second loss value; An update module for updating the model parameters of the first garbage classification model according to the second loss value until the first garbage classification model reaches a second preset convergence condition to obtain a target garbage classification model; Wherein, the using the target smoothing perception model to perform smoothing processing on the first loss value to obtain a second loss value includes: Using the target smoothing perception model to determine the smoothing coefficient corresponding to the first loss value; Based on a second loss function, calculating the second loss value according to the smoothing coefficient, and the second loss function is: Where N represents the total number of garbage image samples in the garbage image sample set, Loss i represents the loss function of the i-th garbage image sample, represents the sign function when the i-th garbage image sample belongs to the j-th category, represents the probability when the i-th garbage image sample belongs to the j-th category, ε j represents the smoothing coefficient of the j-th category, and K is the total number of categories.

6. A garbage classification device, characterized in that, It includes: An acquisition module for acquiring garbage images; An identification module for classifying and identifying the garbage image based on the target garbage classification model to obtain initial classification data, where the target garbage classification model is trained based on the training method described in any one of claims 1 to 3; A second smoothing module for performing smoothing processing on the initial classification data to obtain the target classification result.

7. A computer device, characterized in that, It includes a processor and a memory. The memory is used to store a computer program. When the computer program is executed by the processor, it implements the training method of the garbage classification model according to any one of claims 1 to 3, or the garbage classification method according to claim 4.

8. A computer-readable storage medium, characterized in that, It stores a computer program. When the computer program is executed by the processor, it implements the training method of the garbage classification model according to any one of claims 1 to 3, or the garbage classification method according to claim 4.

Citation Information

Patent Citations

  • Dry and wet garbage recognition and classification method based on improved YOLOv3 network

    CN110796186A

  • Garbage classification method, device and system based on image recognition

    CN112651318A