Garbage identification and classification method
The method addresses the challenge of diverse and complex garbage classification by integrating hypernetwork, Mixup enhancement, and out-of-distribution detection, enhancing model adaptability and accuracy for real-time garbage classification.
Patent Information
- Application Number
- CN202411317374.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-09-20
AI Technical Summary
Existing garbage classification models face challenges in accurately identifying and classifying diverse and complex real-world garbage images, particularly out-of-distribution samples, requiring improved generalization and adaptability.
A method combining hypernetwork, Mixup enhancement, and out-of-distribution detection technologies to enhance the model's ability to classify garbage images, including a comprehensive dataset, HyperTune module for quick adaptation, P-Mix module for sample diversity, E-Mix module for abnormal sample detection, and MixMaster module for meta-training, with a feature extraction network for real-time classification.
The method improves the accuracy and automation of garbage classification by enhancing the model's adaptability to new tasks and robustness against abnormal samples, enabling efficient and accurate real-time garbage management.
Smart Images

Figure CN119229194A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of machine learning, and in particular relates to a garbage identification and classification method. Background Art
[0002] With the rapid development of artificial intelligence technology, especially in the field of machine learning, deep learning technology has made breakthrough progress in image recognition; this technological advancement provides a new solution for the automatic identification and classification of garbage, which is of great significance for promoting the automation of garbage classification and the effective recycling of resources; by constructing an image dataset containing a wide range of samples and training it with a deep learning model, efficient identification and classification of garbage can be achieved.
[0003] However, real-world image data is highly complex and diverse, which places higher demands on the generalization ability of garbage classification models. To meet this challenge, researchers have developed a variety of strategies, such as using hypernetwork technology to quickly adapt to new tasks, using Mixup enhancement technology to improve the model's adaptability to sample diversity, and using meta-learning strategies to enhance the model's ability to quickly learn from small samples. The integrated application of these technologies enables the model to not only accurately identify common types of garbage, but also effectively detect and classify unknown or uncommon garbage samples.
[0004] Out-of-distribution detection is an important research direction in the field of machine learning. It focuses on the performance of the model when faced with samples that have not been encountered during the training process. In the actual application of garbage classification, the model may encounter various atypical or abnormal garbage samples. In order to improve the model's ability to recognize these out-of-distribution samples, researchers have introduced a variety of advanced technologies, including Mixup enhancement of abnormal samples, label assignment using the maximum entropy principle, and generating adaptable classifier weights through hypernetworks. The combined use of these technologies not only enhances the model's classification performance for normal samples, but also significantly improves its detection and generalization capabilities for out-of-distribution samples, providing strong technical support for the effective implementation of garbage identification and classification. Summary of the invention
[0005] The present invention proposes a garbage identification and classification method, which aims to achieve efficient classification and accurate recognition of garbage images by combining hypernetwork, Mixup enhancement and out-of-distribution detection technology, while enhancing the model's detection ability for unknown categories of garbage, so as to improve the accuracy and automation level of garbage classification.
[0006] The present invention proposes a method for identifying and classifying garbage, comprising the following steps: S1. Create a comprehensive garbage image dataset that covers common recyclables, hazardous waste, wet garbage, and dry garbage in garbage; annotate the images with high quality to provide accurate supervision signals for subsequent model training; S2. Build the HyperTune module, which uses the classifier generated by the hypernetwork technology to quickly generate classifier parameters that adapt to new tasks. This module uses meta-learning to quickly learn from a small number of samples and generate efficient classifier weights, laying the foundation for accurate classification. S3, build the P-Mix module, use Mixup to enhance the support set, and use weighted aggregation to calculate the classifier weight. By enhancing samples in the weight space, the model can better adapt to the diversity of samples within the class, thereby improving the classification effect; S4. Construct the E-Mix module to improve the model's ability to detect abnormal samples; OOE-Mix increases the diversity of abnormal samples by mixing up out-of-task OOE samples with in-task INE samples; S5, build the MixMaster module, which uses the Mixup technology with two sub-modules, P-Mix and E-Mix, to train the super network in the meta-training stage; S6. Training of the classifier model: constructing a feature extraction network and applying the classifier weights generated above to classify the query samples; through iterative training, the model parameters are continuously optimized until the model can accurately classify new samples, and regularization technology is used to prevent overfitting; S7. Real-time image acquisition and classification: deploy an automated image acquisition system to obtain garbage image data in real time and input it into the trained model for identification and classification. The model will quickly and accurately classify the garbage in the image based on the learned features to achieve effective garbage management.
[0007] Preferably, in the HyperTune module in step S2, the hypernetwork is trained by meta-learning, that is, learning on multiple small sample classification tasks; each task set includes a support set and a query set, and the model needs to learn on the support set and predict the query set; specifically, it is composed of a multilayer perceptron with two fully connected layers, each layer size is 256, and the weight of the classifier is generated by the formula, and the weight generation process is as follows: Among them, w n represents the classifier weight of the nth class. This weight is obtained by weighting the samples belonging to this class in the support set and is used for the final classifier; K represents the number of samples of each class in the support set. In K-shot tasks, there are usually only K samples in each class; KN represents the total number of samples in the support set, which contains N classes and K samples in each class; 1[y s=n] is the indicator function, when the sample x s The value is 1 when it belongs to category n. s If it does not belong to category n, the value is 0, which is used to filter samples belonging to category n; H(F(x s ))In F(x s ) indicates that the feature extractor is extracted from sample x s The feature vector extracted from ; H(*) is a hypernetwork used to map the feature vector to the weight of the classifier.
[0008] Preferably, in the P-Mix module in step S3, Mixup is used to enhance the support set, and weighted aggregation is used to calculate the classifier weight; the mixed support samples and the corresponding labels are recorded as xs and ys respectively; the mixed parameters PM are sampled from a fixed Beta distribution, and the extracted classifier parameters are calculated using weighted aggregation of sample-specific weight codes, where the aggregation weight is determined according to the probability of the mixed samples, and the specific process is as follows: For samples x1 and x2 in the support set, and their labels y1 and y2, generate mixed samples: The classifier weights are then generated using the weighted sum of the support set embeddings: Among them, w n represents the classifier weight of the nth class; S represents the total number of support set samples after enhancement; It represents the probability that the sth sample belongs to the nth class. Represents the normalization coefficient, ensuring the weight w for each class n The sum of is normalized.
[0009] Preferably, the E-Mix module in step S4 is used to improve the model's ability to detect abnormal samples; 00E-Mix increases the diversity of abnormal samples by mixing up the out-of-task 00E samples with the in-task INE samples. The specific process is as follows: First, each time a task is trained, the author samples from unselected categories as out-of-set samples. And with the samples in the set To mix: in, represents a new sample generated by mixing in-task samples and out-task samples; λ is the weight coefficient of Mixup, which controls the ratio of in-task samples to out-task samples; Then, set the labels of the out-of-set samples to the maximum entropy distribution, that is, uniformly distribute the labels: in, Represents out-of-task samples The label distribution of Represents the probability of each category under uniform distribution; Finally, the final mixed label is calculated: in, Represents the newly generated mixed sample The label distribution of Represents the sample within the task The label distribution of .
[0010] Preferably, the feature extractor F in step S6 adopts a ResNet-12 architecture, including 4 residual blocks, each residual block has 3 convolutional layers, the number of convolution kernels is 64, 160, 320 and 640 respectively, and the convolution kernel size is 3×3; the first 3 residual blocks are followed by a 2×2 average pooling layer, and the final feature vector size is 640; in the pre-training stage, the feature extractor is trained by combining supervised learning and self-supervised learning strategies; and is trained by two linear classifiers: one predicts the category and the other predicts the rotation angle; the loss function combines the classification cross entropy loss and the binary cross entropy loss.
[0011] Compared with the existing technology, a garbage identification and classification method proposed in the present invention ensures the accuracy and comprehensiveness of model training by constructing a comprehensive garbage image data set and adopting high-quality annotations; by utilizing the HyperTune module and P-Mix technology, the method can quickly adapt to new tasks and enhance sample diversity, significantly improving the classification effect; at the same time, the introduction of the E-Mix module effectively improves the model's detection ability for abnormal samples, and the meta-training strategy of the MixMaster module further enhances the generalization of the model; in addition, real-time image recognition and classification are realized through an automated image acquisition system. This method not only improves the real-time and automation level of garbage classification, but also helps to achieve effective garbage management and resource recycling, showing the advantages of rapid adaptability to new tasks and robustness to abnormal samples. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 The present invention is a flow chart of a method for identifying and classifying garbage.
[0013] Figure 2 Flowchart for constructing and training a hypernetwork model.
[0014] Figure 3 This is the network structure diagram of the hypernetwork model.
[0015] Figure 4 This is a schematic diagram of the classification results of the training model inference. DETAILED DESCRIPTION
[0016] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0017] See also Figure 1-Figure 4 , the present invention provides a technical solution.
[0018] The present invention proposes a garbage identification and classification method, which aims to achieve efficient classification and accurate recognition of garbage images by combining hypernetwork, Mixup enhancement and out-of-distribution detection technology, and at the same time enhance the model's detection ability for unknown types of garbage, so as to improve the accuracy and automation level of garbage classification, especially the accuracy of domestic garbage classification.
[0019] The present invention proposes a method for identifying and classifying garbage, the flow chart of which is shown in the attached figure. Figure 1 As shown, the specific steps include: S1. Create a comprehensive garbage image dataset that covers common recyclables, hazardous waste, wet garbage, and dry garbage in garbage; annotate the images with high quality to provide accurate supervision signals for subsequent model training; S2. Build the HyperTune module, which uses the classifier generated by the hypernetwork technology to quickly generate classifier parameters that adapt to new tasks. This module uses meta-learning to quickly learn from a small number of samples and generate efficient classifier weights, laying the foundation for accurate classification. S3, build the P-Mix module, use Mixup to enhance the support set, and use weighted aggregation to calculate the classifier weight. By enhancing samples in the weight space, the model can better adapt to the diversity of samples within the class, thereby improving the classification effect; S4. Construct the E-Mix module to improve the model's ability to detect abnormal samples; OOE-Mix increases the diversity of abnormal samples by mixing up out-of-task OOE samples with in-task INE samples; S5, build the MixMaster module. The MixMaster module uses the Mixup technology with two sub-modules, P-Mix and E-Mix, to train the super network in the meta-training stage; S6. Training of the classifier model: constructing a feature extraction network and applying the classifier weights generated above to classify the query samples; through iterative training, the model parameters are continuously optimized until the model can accurately classify new samples, and regularization technology is used to prevent overfitting; S7. Real-time image acquisition and classification: deploy an automated image acquisition system to obtain garbage image data in real time and input it into the trained model for identification and classification. The model will quickly and accurately classify the garbage in the image based on the learned features to achieve effective garbage management.
[0020] Furthermore, in the attached Figure 2 The HyperTune module mentioned in step S2 is specifically a hypernetwork trained by meta-learning, that is, learning on multiple small sample classification tasks; each task set contains a support set and a query set, and the model needs to learn on the support set and predict the query set; it is specifically composed of a multi-layer perceptron with two fully connected layers, each layer size is 256, and the weight of the classifier is generated by the formula. The weight generation process is as follows: Among them, w n represents the classifier weight of the nth class. This weight is obtained by weighting the samples belonging to this class in the support set and is used for the final classifier; K represents the number of samples of each class in the support set. In K-shot tasks, there are usually only K samples in each class; KN represents the total number of samples in the support set, which contains N classes and K samples in each class; 1[y s =n] is the indicator function, when the sample x s The value is 1 when it belongs to category n. s If it does not belong to category n, the value is 0, which is used to filter samples belonging to category n; H(F(x s ))In F(x s ) indicates that the feature extractor is extracted from sample x s The feature vector extracted from ; H(*) is a hypernetwork used to map the feature vector to the weight of the classifier.
[0021] Furthermore, in the attached Figure 2 The P-Mix module mentioned in step S3 is specifically to use Mixup to enhance the support set and use weighted aggregation to calculate the classifier weight; the mixed support samples and the corresponding labels are recorded as xs and ys respectively; the mixed parameters PM are sampled from a fixed Beta distribution, and the weighted aggregation of the sample-specific weight codes is used to calculate the extracted classifier parameters, where the aggregation weight is determined according to the probability of the mixed samples. The specific process is as follows: For samples x1 and x2 in the support set, and their labels y1 and y2, generate mixed samples: The classifier weights are then generated using the weighted sum of the support set embeddings: Among them, w n represents the classifier weight of the nth class; S represents the total number of support set samples after enhancement; It represents the probability that the sth sample belongs to the nth class. Represents the normalization coefficient, ensuring the weight w for each class n The sum of is normalized.
[0022] Furthermore, in the attached Figure 2 The E-Mix module mentioned in step S4 is specifically used to improve the model's ability to detect abnormal samples; 00E-Mix increases the diversity of abnormal samples by mixing up the out-of-task 00E samples with the in-task INE samples. The specific process is as follows: First, each time a task is trained, the author samples from unselected categories as out-of-set samples. And with the samples in the set To mix: in, represents a new sample generated by mixing in-task samples and out-task samples; λ is the weight coefficient of Mixup, which controls the ratio of in-task samples to out-task samples; Then, set the labels of the out-of-set samples to the maximum entropy distribution, that is, uniformly distribute the labels: in, Represents out-of-task samples The label distribution of Represents the probability of each category under uniform distribution; Finally, the final mixed label is calculated: in, Represents the newly generated mixed sample The label distribution of Represents the sample within the task The label distribution of .
[0023] Furthermore, in the attached Figure 3The feature extractor F mentioned in step S6 specifically adopts the ResNet-12 architecture, which includes 4 residual blocks, each residual block has 3 convolutional layers, the number of convolution kernels are 64, 160, 320 and 640 respectively, and the convolution kernel size is 3×3; the first 3 residual blocks are followed by a 2×2 average pooling layer, and the final feature vector size is 640; in the pre-training stage, the feature extractor is trained by combining supervised learning and self-supervised learning strategies; and is trained by two linear classifiers: one predicts the category and the other predicts the rotation angle; the loss function combines the classification cross entropy loss and the binary cross entropy loss.
Claims
1. A method for identifying and classifying garbage, characterized in that: The following steps are involved: S1. Create a comprehensive garbage image dataset that covers common recyclables, hazardous waste, wet garbage, and dry garbage in garbage; annotate the images with high quality to provide accurate supervision signals for subsequent model training; S2. Build the HyperTune module, which uses the classifier generated by the hypernetwork technology to quickly generate classifier parameters that adapt to new tasks. This module uses meta-learning to quickly learn from a small number of samples and generate efficient classifier weights, laying the foundation for accurate classification. S3, build the P-Mix module, use Mixup to enhance the support set, and use weighted aggregation to calculate the classifier weight. By enhancing samples in the weight space, the model can better adapt to the diversity of samples within the class, thereby improving the classification effect; S4. Construct the E-Mix module to improve the model's ability to detect abnormal samples; 00E-Mix increases the diversity of abnormal samples by mixing up the out-of-task O0E samples with the in-task INE samples; S5, build the MixMaster module. The MixMaster module uses the Mixup technology with two sub-modules, P-Mix and E-Mix, to train the super network in the meta-training stage; S6. Training of the classifier model: constructing a feature extraction network and applying the classifier weights generated above to classify the query samples; through iterative training, the model parameters are continuously optimized until the model can accurately classify new samples, and regularization technology is used to prevent overfitting; S7, real-time image acquisition and classification, deploy an automated image acquisition system to obtain garbage image data in real time and input it into the trained model for identification and classification; The model will quickly and accurately classify the garbage in the image based on the learned features, thereby achieving effective garbage management.
2. A method for identifying and classifying garbage according to claim 1, characterized in that: In the HyperTune module in step S2, the hypernetwork is trained through meta-learning, that is, learning on multiple small sample classification tasks; each task set contains a support set and a query set, and the model needs to learn on the support set and predict the query set; it is specifically composed of a multi-layer perceptron with two fully connected layers, each layer size is 256, and the weight of the classifier is generated by the formula. The weight generation process is as follows: Among them, w n represents the classifier weight of the nth class. This weight is obtained by weighting the samples belonging to this class in the support set and is used for the final classifier; K represents the number of samples of each class in the support set. In K-shot tasks, there are usually only K samples in each class; KN represents the total number of samples in the support set, which contains N classes and K samples in each class; 1[y s =n] is an indicator function, which has a value of 1 when the sample xs belongs to category n and a value of 1 when the sample xs belongs to category n. s If it does not belong to category n, the value is 0, which is used to filter samples belonging to category n; H(F(x s ))In F(x s ) indicates that the feature extractor is extracted from sample x s The feature vector extracted from ; H(*) is a hypernetwork used to map the feature vector to the weight of the classifier.
3. A method for identifying and classifying garbage according to claim 1, characterized in that: The P-Mix module in step S3 uses Mixup to enhance the support set and uses weighted aggregation to calculate the classifier weights; the mixed support samples and the corresponding labels are recorded as xs and ys respectively; the mixed parameters PM are sampled from a fixed Beta distribution, and the extracted classifier parameters are calculated using weighted aggregation of sample-specific weight codes, where the aggregation weights are determined based on the probability of the mixed samples. The specific process is as follows: For samples x1 and x2 in the support set, and their labels y1 and y2, generate mixed samples: The classifier weights are then generated using the weighted sum of the support set embeddings: Among them, w n represents the classifier weight of the nth class; s represents the total number of support set samples after enhancement; It represents the probability that the sth sample belongs to the nth class. Represents the normalization coefficient, ensuring the weight w for each class n The sum of is normalized.
4. A method for identifying and classifying garbage according to claim 1, characterized in that: The E-Mix module in step S4 is used to improve the model's ability to detect abnormal samples; OOE-Mix increases the diversity of abnormal samples by mixing up the out-of-task OOE samples with the in-task INE samples. The specific process is as follows: First, during each task training, the author samples from the unselected categories as out-of-set samples. And with the samples in the set To mix: in, represents a new sample generated by mixing in-task samples and out-task samples; λ is the weight coefficient of Mixup, which controls the ratio of in-task samples to out-task samples; Then, set the labels of the out-of-set samples to the maximum entropy distribution, that is, uniformly distribute the labels: in, Represents out-of-task samples The label distribution of Represents the probability of each category under uniform distribution; Finally, the final mixed label is calculated: in, Represents the newly generated mixed sample The label distribution of Represents the sample within the task The label distribution of .
5. A method for identifying and classifying garbage according to claim 1, characterized in that: The feature extractor F in step S6 adopts the ResNet-12 architecture, which contains 4 residual blocks, each of which has 3 convolutional layers, the number of convolution kernels is 64, 160, 320 and 640 respectively, and the convolution kernel size is 3×3; the first 3 residual blocks are followed by a 2×2 average pooling layer, and the final feature vector size is 640; in the pre-training stage, the feature extractor is trained by combining supervised learning and self-supervised learning strategies; and is trained by two linear classifiers: one predicts the category and the other predicts the rotation angle; the loss function combines the categorical cross entropy loss and the binary cross entropy loss.
Citation Information
Patent Citations
Neural network construction method and device
CN111931904A
Training set preparation method, training set preparation device, training set preparation equipment and medium
CN115134589A
Garbage classification and identification method and system based on deep learning
CN116416476A
Classification model training method and device, defect identification method and device and electronic equipment
CN116956105A
Backbone network search method, target detection network construction method, device and equipment
CN117975072A
Cited By
Small sample identification method based on neighbor Mixup feature calibration
CN121904469A
