A method and device applied to long tail problem of aluminum foil sealing quality detection classification
By employing a phased training and weight decay strategy, the problem of class distribution imbalance in aluminum foil sealing quality inspection was solved, improving classification accuracy and achieving more efficient aluminum foil sealing quality inspection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2026-04-07
AI Technical Summary
Existing deep learning models suffer from an imbalance in class distribution when inspecting aluminum foil sealing quality. This leads to the top class dominating and ignoring the tail class, resulting in low overall class selection accuracy.
A phased training approach combined with a weight decay strategy is adopted to learn the backbone network and classifier in stages. By adjusting the weight decay and cross-entropy loss function, class imbalance is alleviated and classification accuracy is improved.
It effectively improved the overall category screening accuracy of deep learning classification algorithms for aluminum foil sealing quality detection, reduced the number of missed and over-detected items, and improved the model's generalization ability.
Smart Images

Figure CN118537609B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of deep learning industrial quality inspection technology, specifically to a method and apparatus for classifying the long-tail problem of aluminum foil sealing quality inspection. Background Technology
[0002] Aluminum foil sealing packaging is widely used in food, pharmaceuticals, and oil products. Aluminum foil offers many advantages as a sealing packaging material. Firstly, it is non-toxic and odorless. Secondly, aluminum foil sealing is not only aesthetically pleasing but also provides excellent sealing performance, prevents oxidation, and is suitable for preserving food and pharmaceuticals under high storage conditions. With the trend of industrial intelligence, pharmaceutical and food packaging equipment is developing towards higher efficiency, higher precision, and multi-functionality. In my country, the total demand for aluminum foil sealing packaging has exceeded 50%, and this demand is expected to continue to grow. However, the airtightness of aluminum foil packaging becomes a crucial factor in ensuring product quality. As the demand for aluminum foil sealing continues to increase, the market demand for quality control testing of aluminum foil seals is becoming increasingly strong.
[0003] The working principle of aluminum foil sealing inspection equipment, such as Figure 1 As shown, the product consists of three parts: the bottle body, aluminum foil, and the bottle cap. The aluminum foil sealing quality inspection equipment transports the product, which has been heat-sealed or electromagnetically induction-sealed, to the infrared thermal imaging inspection station. The infrared thermal imager collects temperature data on the sealed bottle cap and converts the temperature data into an image, which is then fed into a deep learning classification algorithm for identification. The deep learning algorithm analyzes the features of the image after aluminum foil sealing to determine the quality of the aluminum foil sealing inside the bottle cap. Finally, the product is screened according to the set category.
[0004] Deep learning image classification is one of the important research directions in the field of computer vision. As the name suggests, it involves classifying images and using deep learning classification algorithms to identify which category an image belongs to. For example... Figure 2 As shown, the images are categorized into six types: OK, poor seal, damaged, missing edge, no cap, and no aluminum foil. The aluminum foil heat-sealing inspection equipment needs to correctly identify the image category.
[0005] Problems with existing methods: Due to the uneven distribution of quantities among various product categories, such as... Figure 3 As shown, the imbalance ratio is as high as 28, where the imbalance ratio refers to the ratio of the OK category (head category) with the largest number of products to the Uncovered category (tail category) with the smallest number of products. Figure 4As shown, existing deep learning classification models, during training, take images in fixed-size batches as input. After preprocessing, they undergo representation learning (i.e., feature extraction via a backbone network), followed by classifier learning. The prediction result is then calculated using a softmax function, and the loss between the predicted and true results is calculated using cross-entropy loss. Due to a high imbalance in the number of products, the top-ranked categories dominate the training loss in each iteration, contributing most of the gradient and achieving higher accuracy. This results in low accuracy for selecting the overall product category in the deep learning classification algorithm. Summary of the Invention
[0006] The purpose of this invention is to provide a method and apparatus for effectively improving the accuracy of overall product category screening and addressing the long-tail problem in aluminum foil sealing quality inspection and classification.
[0007] This invention is implemented as follows:
[0008] A method and apparatus for classifying the long-tail problem in aluminum foil sealing quality inspection includes the following steps:
[0009] Step 1: Collect temperature data from the sealed bottle cap and convert the temperature data into an image;
[0010] Step 2: Collect the images converted from the input temperature data and preprocess the images to obtain the long-tail recognition training set for aluminum foil sealing quality inspection classification;
[0011] Step 3: By adjusting the weight decay, perform representation learning on the training sample set to extract backbone network features, and then perform classifier learning;
[0012] Step 4: Freeze the weights representing the learning process, and then adjust the weights to learn the classifier.
[0013] Furthermore, in step 3, by adjusting the weight decay, representation learning is performed on the training sample set to extract backbone network features, and then classifier learning is performed as the first stage of training, which accounts for one-third of the entire training cycle.
[0014] In step 4, the weights representing learning are frozen, and the classifier is learned by adjusting the weights as the second stage of training, which accounts for two-thirds of the entire training cycle.
[0015] Furthermore, in step 4, the weights are adjusted specifically using formula 1.
[0016]
[0017] in, The training set for long-tail recognition of aluminum foil sealing quality inspection classification is given, where θ represents the set of weights, θ = {θ l,j}, θ l,j X represents the weight of the j-th filter in the l-th layer of the network. i Represents a data sample, y i The label representing the sample, y i ∈[1, ..., K], where K represents the number of categories, f(X) i ;θ) represents a K-class classification network, l(f(X) i ;θ), y i ) represents the cross-entropy loss function.
[0018] Furthermore, in step 3, the weight decay is specifically adjusted using formula 2.
[0019]
[0020] Where λ represents the hyperparameter controlling the weight decay, and θ k This represents the classifier weight for the k-th category.
[0021] Furthermore, in steps 3 and 4, the softmax function of formula 3 is used to calculate the prediction results, and the cross-entropy loss of formula 4 is used to measure the loss between the prediction results and the actual results.
[0022]
[0023]
[0024] Where x i Represents a data sample, y i The label representing the sample.
[0025] A device for classifying long-tail problems in the quality inspection of aluminum foil sealing includes a data acquisition module that collects temperature data from the sealed bottle cap and converts the temperature data into an image.
[0026] The image preprocessing module is used to collect images converted from input temperature data and preprocess the images to obtain a long-tail recognition training set for aluminum foil sealing quality inspection classification.
[0027] The data processing module is used to adjust the weight decay, perform representation learning on the training sample set to extract backbone network features, and then perform classifier learning; freeze the weights of representation learning, and perform classifier learning by adjusting the weights.
[0028] Furthermore, in the data processing module, by adjusting the weight decay, representation learning is performed on the training sample set to extract backbone network features, and then classifier learning is performed as the first stage of training, which accounts for one-third of the entire training cycle; the weights of representation learning are frozen, and by adjusting the weights, classifier learning is performed as the second stage of training, which accounts for two-thirds of the entire training cycle.
[0029] Furthermore, the data processing module adjusts the weights using Formula 1.
[0030]
[0031] in, The training set for long-tail recognition of aluminum foil sealing quality inspection classification is given, where θ represents the set of weights, θ = {θ l,j θ l,j X represents the weight of the j-th filter in the l-th layer of the network. i Represents a data sample, y i The label of the sample, y i ∈[1, ..., K], where K represents the number of categories, f(X) i ;θ) represents a K-class classification network, l(f(x) i ;θ), y i ) represents the cross-entropy loss function.
[0032] Furthermore, the data processing module specifically adjusts the weight decay using Formula 2.
[0033]
[0034] Where λ represents the hyperparameter controlling the weight decay, and θ k This represents the classifier weight for the k-th category.
[0035] Furthermore, the data processing module uses the softmax function in Formula 3 to calculate the prediction results, and uses the cross-entropy loss in Formula 4 to measure the loss between the prediction results and the actual results.
[0036]
[0037]
[0038] Where xi represents a data sample, y i The label representing the sample.
[0039] Compared with the prior art, the beneficial effects of the present invention are:
[0040] This invention employs a phased training strategy combined with a weight decay strategy, decoupling the backbone and classifier in the model. The initial training phase focuses on representation learning, while the subsequent phase focuses on classifier learning. By adjusting weight decay and using cross-entropy loss for representation learning, and then further adjusting weights to achieve class-balanced loss for classifier learning, this effectively alleviates the long-tail problem in deep learning image classification. It ensures that the losses for different categories reach a relatively balanced state in each training round, effectively covering all categories and avoiding the problem of the network model over-focusing on head categories and neglecting tail categories. This significantly improves the accuracy of deep learning classification algorithms in selecting overall product categories. Attached Figure Description
[0041] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained from these drawings without creative effort.
[0042] Figure 1 This is a schematic diagram of the structure of existing aluminum foil sealing inspection equipment;
[0043] Figure 2 These are sample images of different types of aluminum foil heat seals;
[0044] Figure 3 This is a sample size distribution diagram for different categories of aluminum foil heat sealing.
[0045] Figure 4 This is a flowchart of an existing deep learning image classification algorithm for aluminum foil heat sealing quality inspection;
[0046] Figure 5 This is a flowchart of the first stage of the deep learning image classification algorithm for aluminum foil heat sealing quality inspection of the present invention;
[0047] Figure 6 This is a flowchart of the second stage of the deep learning image classification algorithm for aluminum foil heat sealing quality inspection of the present invention;
[0048] Figure 7 This is a statistical table of the accuracy of existing deep learning classification algorithms for aluminum foil sealing quality inspection;
[0049] Figure 8 This is a statistical table of the accuracy of the deep learning classification algorithm for aluminum foil sealing quality inspection in this invention. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to represent selected embodiments of the invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0051] Please see Figure 5 and Figure 6 A method for classifying the long tail problem in aluminum foil sealing quality inspection includes the following steps:
[0052] Step 1: Collect temperature data from the sealed bottle cap and convert the temperature data into an image;
[0053] Step 2: Collect the images converted from the input temperature data and preprocess the images to obtain the long-tail recognition training set for aluminum foil sealing quality inspection classification;
[0054] Step 3: By adjusting the weight decay, perform representation learning on the training sample set to extract backbone network features, and then perform classifier learning;
[0055] Step 4: Freeze the weights representing the learning process, and then adjust the weights to learn the classifier.
[0056] This invention collects temperature data from sealed bottle caps using an infrared thermal imager, converts the temperature data into images, inputs the images, and preprocesses them using ReSize. The process then proceeds to the first training stage, where weight decay is adjusted, and cross-entropy loss is used for representation learning to extract backbone network features. Classifier learning is then performed, and this first training stage accounts for one-third of the entire training cycle. In the second stage, the weights for representation learning are frozen, and classifier learning is performed by adjusting these weights. That is, the backbone network weights remain unchanged, and representation learning is performed with fixed weights. This second training stage accounts for two-thirds of the entire training cycle.
[0057] This invention employs a phased training strategy combined with a weight decay strategy, decoupling the backbone and classifier in the model. The initial training phase focuses on representation learning, while the subsequent phase focuses on classifier learning. By adjusting weight decay and using cross-entropy loss for representation learning, and then further adjusting weights to achieve class-balanced loss for classifier learning, this effectively alleviates the long-tail problem in deep learning image classification. It ensures that the losses for different categories reach a relatively balanced state in each training round, effectively covering all categories and avoiding the problem of the network model over-focusing on head categories and neglecting tail categories. This significantly improves the accuracy of deep learning classification algorithms in selecting overall product categories.
[0058] Step 4 specifically adjusts the weights using Formula 1.
[0059]
[0060] in, The training set for long-tail recognition of aluminum foil sealing quality inspection classification is given, where θ represents the set of weights, θ = {θ l,j}, θ l,j X represents the weight of the j-th filter in the l-th layer of the network. i Represents a data sample, y i The label representing the sample, y i ∈[1, ..., K], where K represents the number of categories, f(X) i ;θ) represents a K-class classification network, l(f(X) i :θ), y i ) represents the cross-entropy loss function.
[0061] In step 3, the weight decay is adjusted using formula 2.
[0062]
[0063] Where λ represents the hyperparameter controlling the weight decay, and θ k This represents the classifier weight for the k-th category.
[0064] Weight decay penalizes large weights more severely to prevent them from becoming excessively large, while encouraging the learning of smaller weights. By limiting the growth of network weights, the network's complexity is reduced, overfitting is effectively mitigated, and the network's generalization ability is improved, thereby enhancing the accuracy of deep learning classification algorithms in selecting overall product categories.
[0065] In steps 3 and 4, the softmax function of formula 3 is used to calculate the prediction results, and the cross-entropy loss of formula 4 is used to measure the loss between the prediction results and the actual results.
[0066]
[0067]
[0068] Where x i Represents a data sample, y i The label representing the sample.
[0069] A device for classifying long-tail problems in the quality inspection of aluminum foil sealing includes a data acquisition module that collects temperature data from the sealed bottle cap and converts the temperature data into an image.
[0070] The image preprocessing module is used to collect images converted from input temperature data and preprocess the images to obtain a long-tail recognition training set for aluminum foil sealing quality inspection classification.
[0071] The data processing module is used to adjust the weight decay, perform representation learning on the training sample set to extract backbone network features, and then perform classifier learning; freeze the weights of representation learning, and perform classifier learning by adjusting the weights.
[0072] In the data processing module, by adjusting the weight decay, representation learning is performed on the training sample set to extract backbone network features, and then classifier learning is performed as the first stage of training, which accounts for one-third of the entire training cycle. The weights of the representation learning are frozen, and by adjusting the weights, classifier learning is performed as the second stage of training, which accounts for two-thirds of the entire training cycle.
[0073] The data processing module adjusts the weights using Formula 1.
[0074]
[0075] in, The training set for long-tail recognition of aluminum foil sealing quality inspection classification is given, where θ represents the set of weights, θ = {θ l,j}, θ l,j X represents the weight of the j-th filter in the l-th layer of the network. i Represents a data sample, y i The label of the sample, y i ∈[1, ..., K], where K represents the number of categories, f(X) i ;θ) represents a K-class classification network, l(f(X) i ;θ), y i ) represents the cross-entropy loss function.
[0076] The data processing module specifically adjusts the weight decay using Formula 2.
[0077]
[0078] Where λ represents the hyperparameter controlling the weight decay, and θ kThis represents the classifier weight for the k-th category.
[0079] The data processing module uses the softmax function in Formula 3 to calculate the prediction results and uses the cross-entropy loss in Formula 4 to measure the loss between the prediction results and the actual results.
[0080]
[0081]
[0082] Where xi represents a data sample, y i The label representing the sample.
[0083] This invention thoroughly explores the reasons for the low accuracy of existing deep learning image classification algorithms for aluminum foil sealing quality inspection, and deeply analyzes the long-tail problem in classification. Considering the characteristics of the data distribution in aluminum foil sealing quality inspection, a phased training combined with a weight decay strategy is adopted, which significantly alleviates the long-tail problem in aluminum foil sealing quality inspection classification. Figure 7 In China, statistics on the accuracy of existing deep learning classification algorithms for aluminum foil sealing quality inspection are presented. Figure 8 In this invention, the accuracy statistics of the deep learning classification algorithm for aluminum foil sealing quality inspection are obtained through... Figure 7 and Figure 8 The data comparison clearly shows that the number of missed detections decreased from 14 to 5, and the number of passed detections decreased from 14 to 4. This example, through phased training combined with a weight decay strategy, significantly improved the accuracy of deep learning image classification for aluminum foil sealing quality inspection.
[0084] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the invention should be included within the scope of protection of the invention.
Claims
1. A method for classifying the long-tail problem in aluminum foil sealing quality inspection, characterized in that: Includes the following steps: Step 1: Collect temperature data from the sealed bottle cap and convert the temperature data into an image; Step 2: Collect the images converted from the input temperature data and preprocess the images to obtain the long-tail recognition training set for aluminum foil sealing quality inspection classification; Step 3: By adjusting the weight decay, perform representation learning on the training sample set to extract backbone network features, and then perform classifier learning; Step 4: Freeze the weights representing the learning process, and then perform classifier learning by adjusting the weights; In step 3, the weight decay is specifically adjusted using formula 2. Official 2; in, This represents the hyperparameter that controls weight decay. Indicates the first Classifier weights for each category; In step 4, the weights are adjusted using formula 1. Official 1; in, This is a training set for long-tail recognition of aluminum foil sealing quality inspection classification. The set representing the weights, , Indicates the first The first layer of the network The weights of each filter, Indicates a data sample. Labels representing samples, , Indicates the number of categories. express Class classification network, This represents the cross-entropy loss function.
2. The method for classifying the long-tail problem of aluminum foil sealing quality inspection according to claim 1, characterized in that, In step 3, by adjusting the weight decay, representation learning is performed on the training sample set to extract backbone network features, and then classifier learning is performed as the first stage of training, which accounts for one-third of the entire training cycle. In step 4, the weights representing learning are frozen, and the classifier is learned by adjusting the weights as the second stage of training, which accounts for two-thirds of the entire training cycle.
3. The method for classifying the long-tail problem of aluminum foil sealing quality inspection according to claim 1, characterized in that, In steps 3 and 4, the softmax function of formula 3 is used to calculate the prediction results, and the cross-entropy loss of formula 4 is used to measure the loss between the prediction results and the actual results. Official 3; Official 4; Where x i Indicates a data sample. The label representing the sample.
4. A device for classifying the long-tail problem in aluminum foil sealing quality inspection, characterized in that, It includes a data acquisition module that collects temperature data from the sealed bottle cap and converts the temperature data into an image; The image preprocessing module is used to collect images converted from input temperature data and preprocess the images to obtain a long-tail recognition training set for aluminum foil sealing quality inspection classification. The data processing module is used to adjust weight decay, perform representation learning on the training sample set to extract backbone network features, and then perform classifier learning. Freeze the weights representing the learning process, and then adjust the weights to learn the classifier. The data processing module adjusts the weights using Formula 1. Official 1; in, This is a training set for long-tail recognition of aluminum foil sealing quality inspection classification. The set representing the weights, , Indicates the first The first layer of the network The weights of each filter, Indicates a data sample. Labels representing samples, , Indicates the number of categories. express Class classification network, Represents the cross-entropy loss function; The data processing module specifically adjusts the weight decay using Formula 2. Official 2; in, This represents the hyperparameter that controls weight decay. Indicates the first Classifier weights for each category.
5. The device for classifying the long-tail problem of aluminum foil sealing quality inspection according to claim 4, characterized in that, In the data processing module, by adjusting the weight decay, representation learning is performed on the training sample set to extract backbone network features, and then classifier learning is performed as the first stage of training, which accounts for one-third of the entire training cycle. The weights of the representation learning are frozen, and by adjusting the weights, classifier learning is performed as the second stage of training, which accounts for two-thirds of the entire training cycle.
6. The device for classifying the long-tail problem of aluminum foil sealing quality inspection according to claim 4, characterized in that, The data processing module uses the softmax function in Formula 3 to calculate the prediction results and uses the cross-entropy loss in Formula 4 to measure the loss between the prediction results and the actual results. Official 3; Official 4; Where xi represents a data sample. The label representing the sample.
Citation Information
Patent Citations
Long-tail data classification method and system based on class activation thermodynamic diagram and medium
CN115830372A
Medicine bottle aluminum foil sealing machine
CN206328127U