Method and device for classifying long tail problems in aluminum foil sealing quality detection
Through staged training and weight attenuation strategies, the problem of unbalanced category distribution of the deep learning model in aluminum foil sealing quality detection is solved, the recognition accuracy of rare categories is improved, and the overall detection accuracy is improved.
Patent Information
- Application Number
- CN202410349007.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-03-26
AI Technical Summary
Existing deep learning classification models have an imbalanced category distribution problem in aluminum foil sealing quality inspection, which results in the model's low recognition accuracy for rare categories, excessive focus on common categories, and neglect of rare categories.
Use staged training combined with a weight attenuation strategy to decouple the backbone of the model from the classifier. In the early stage, cross-entropy loss is used for representation learning, and in the later stage, the weight is adjusted for classifier learning to ensure that the losses of different categories are balanced and avoid the model from overly focusing on common phenomena. category.
The overall category screening accuracy of the deep learning classification algorithm for aluminum foil sealing quality inspection has been significantly improved, the number of missed and over-inspections has been reduced, and the ability to identify rare categories has been improved.
Smart Images

Figure CN118537609A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning industrial quality inspection technology, and specifically to a method and device for classifying long-tail problems in aluminum foil sealing quality inspection. Background Art
[0002] Aluminum foil sealing packaging has been widely used in many fields such as food, medicine, and oil. Aluminum foil has many advantages as a sealing packaging material. First of all, aluminum foil itself is non-toxic and tasteless. Secondly, aluminum foil sealing is not only beautiful, but also has good sealing and anti-oxidation. It can also better preserve food and medicine with high storage conditions. With the trend of industrial intelligence, pharmaceutical and food packaging equipment is developing in the direction of high efficiency, high precision, and multi-function. The total demand for sealed packaging using aluminum foil in my country has exceeded 50%, and the demand for sealed packaging using aluminum foil will increase in the future. However, after sealing with aluminum foil, the sealing of aluminum foil packaging has become an important factor in ensuring product quality. As the demand for aluminum foil sealing continues to increase, the market demand for quality inspection to ensure aluminum foil sealing is becoming more and more intense.
[0003] The working principle of aluminum foil seal detection equipment, such as Figure 1 As shown in the figure, the product consists of three parts: bottle body, aluminum foil and bottle cap. The aluminum foil sealing quality inspection equipment transports the products sealed by heat sealing or electromagnetic induction sealing to the infrared thermal imaging inspection station. The infrared thermal imager collects temperature data of the sealed bottle cap and converts the temperature data into an image, which is then passed to the deep learning classification algorithm for recognition. The deep learning algorithm analyzes the image features after the aluminum foil is sealed to determine the quality of the aluminum foil seal in the bottle cap, and finally screens the products according to the set categories.
[0004] Among them, deep learning image classification task is one of the important research directions in the field of computer vision. As the name suggests, it is to classify images and identify which classification category the image belongs to through deep learning classification algorithm. Figure 2 As shown, there are six categories: OK, bad seal, broken, missing edge, no cover, and no aluminum foil. The aluminum foil heat seal inspection equipment needs to correctly identify the category of the image.
[0005] Problems with existing methods: Due to the imbalanced distribution of product quantities in multiple categories, such as Figure 3 As shown in the figure, 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 in the figure, during the training process, the existing deep learning classification model inputs a fixed-size batch of images, which are preprocessed and then represent and learn, that is, the backbone network extracts features, and then the classifier learns and the softmax function calculates the prediction results. The cross entropy loss is used to calculate the loss between the prediction results and the actual results. Due to the high imbalance in the number of products, the head category dominates the training loss in each iteration of the model, contributes most of the gradient, and obtains higher accuracy, resulting in low overall product category screening accuracy of the deep learning classification algorithm. Summary of the invention
[0006] The purpose of the present invention is to provide a method and device for solving the long-tail problem of aluminum foil sealing quality inspection classification, which effectively improves the accuracy of overall product category screening.
[0007] The present invention is achieved in that:
[0008] A method and device for solving the long-tail problem of aluminum foil sealing quality detection and classification, comprising the following steps:
[0009] Step 1: Collect temperature data of the sealed bottle cap and convert the temperature data into an image;
[0010] Step 2: 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;
[0011] Step 3: By adjusting weight decay, representation learning is performed on the training sample set to extract backbone network features, and then classifier learning is performed;
[0012] Step 4: Freeze the weights that represent learning, and learn the classifier by adjusting the weights.
[0013] Furthermore, in step 3, by adjusting 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 occupies 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 occupies two-thirds of the entire training cycle.
[0015] Furthermore, in step 4, the weight is adjusted specifically by formula 1:
[0016]
[0017] in, is the long-tail identification training set for aluminum foil sealing quality detection classification, θ represents the set of weights, θ={θ l,j}, θ l,j represents the weight of the jth filter in the lth layer network, X i represents the data sample, y i Represents the label of the sample, y i ∈[1, ..., K], K represents the number of categories, f(Xi; θ) represents the K-class classification network, l(f(X i ;θ),y i ) represents the cross entropy loss function.
[0018] Furthermore, in step 3, weight attenuation is adjusted specifically through formula 2:
[0019]
[0020] Among them, λ represents the hyperparameter that controls weight decay, θ k represents the classifier weight of the k-th category.
[0021] Furthermore, in step 3 and step 4, the prediction result is calculated using the softmax function of formula 3, and the loss between the prediction result and the true result is measured by the cross entropy loss of formula 4;
[0022]
[0023]
[0024] where x i represents the data sample, y i Represents the label of the sample.
[0025] A device for solving the long-tail problem of aluminum foil sealing quality inspection and classification, comprising a data acquisition module, collecting temperature data of the sealed bottle cap and converting the temperature data into an image;
[0026] An 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 the 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 the backbone network features, and then classifier learning is performed as the first stage of training, which occupies one-third of the entire training cycle; the weights of representation learning are frozen, and classifier learning is performed by adjusting the weights, which is the second stage of training, which occupies two-thirds of the entire training cycle.
[0029] Furthermore, the data processing module adjusts the weights through Formula 1:
[0030]
[0031] in, is the long-tail identification training set for aluminum foil sealing quality detection classification, θ represents the set of weights, θ={θ l,j}, θ l,j represents the weight of the jth filter in the lth layer network, X i represents the data sample, y i Represents the label of the sample, y i ∈[1, ..., K], K represents the number of categories, f(X i ; θ) represents the 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 attenuation through formula 2:
[0033]
[0034] Among them, λ represents the hyperparameter that controls weight decay, θ k represents the classifier weight of the k-th category.
[0035] Furthermore, the data processing module uses the softmax function of Formula 3 to calculate the prediction result, and uses the cross entropy loss of Formula 4 to measure the loss between the prediction result and the true result;
[0036]
[0037]
[0038] Where xi represents the data sample, y i Represents the label of the sample.
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] The present invention adopts a phased training combined with a weight decay strategy to decouple the backbone and classifier in the model, and performs representation learning in the early stage of training and classifier learning in the later stage. By adjusting the weight decay, using cross entropy loss for representation learning, and then adjusting the weights to achieve class balance loss, classifier learning is performed, which well alleviates the long-tail problem of deep learning image classification, so that the losses of different categories in each round of training reach a relatively balanced state, taking all categories into account well, avoiding the problem that the network model pays too much attention to the head category and ignores the tail category, and greatly improves the overall category screening accuracy of the deep learning classification algorithm for products. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 It is a structural schematic diagram of the existing aluminum foil sealing detection equipment;
[0043] Figure 2 These are sample images of different categories of aluminum foil heat seals;
[0044] Figure 3 It is the distribution diagram of sample quantity of different categories of aluminum foil heat seal;
[0045] Figure 4 It is a flowchart of the existing deep learning image classification algorithm for aluminum foil heat seal quality inspection;
[0046] Figure 5 It is a flow chart of the first stage of the deep learning image classification algorithm for quality inspection of aluminum foil heat seal quality inspection of the present invention;
[0047] Figure 6 It is a flow chart of the second stage of the deep learning image classification algorithm for quality inspection of aluminum foil heat seal quality inspection of the present invention;
[0048] Figure 7 It is a statistical table of the accuracy of existing deep learning classification algorithms for aluminum foil sealing quality detection;
[0049] Figure 8 This is a statistical table of the accuracy of the deep learning classification algorithm for aluminum foil sealing quality detection of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, 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 part of the embodiments of the present invention, rather than all of 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. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention claimed for protection, but merely represents the selected embodiments of the present invention. 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.
[0051] See also Figure 5 and Figure 6 , a method for the long-tail problem of aluminum foil sealing quality detection classification, comprising the following steps:
[0052] Step 1: Collect temperature data of the sealed bottle cap and convert the temperature data into an image;
[0053] Step 2: 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;
[0054] Step 3: By adjusting weight decay, representation learning is performed on the training sample set to extract backbone network features, and then classifier learning is performed;
[0055] Step 4: Freeze the weights that represent learning, and learn the classifier by adjusting the weights.
[0056] The present invention collects temperature data of the sealed bottle cap by an infrared thermal imager, converts the temperature data into an image, inputs the image, and performs ReSize preprocessing on the image, enters the first stage of training, adjusts weight attenuation, uses cross entropy loss to perform representation learning to extract backbone network features, and then performs classifier learning. The first stage of training occupies 1 / 3 of the entire training cycle, enters the second stage, freezes the weight of representation learning, and performs classifier learning by adjusting the weight, that is, the weight of the backbone network is not adjusted, and representation learning is performed with fixed weights. The second stage of training occupies 2 / 3 of the entire training cycle.
[0057] The present invention adopts a phased training combined with a weight decay strategy to decouple the backbone and classifier in the model, and performs representation learning in the early stage of training and classifier learning in the later stage. By adjusting the weight decay, using cross entropy loss for representation learning, and then adjusting the weights to achieve class balance loss, classifier learning is performed, which well alleviates the long-tail problem of deep learning image classification, so that the losses of different categories in each round of training reach a relatively balanced state, taking all categories into account well, avoiding the problem that the network model pays too much attention to the head category and ignores the tail category, and greatly improves the overall category screening accuracy of the deep learning classification algorithm for products.
[0058] In step 4, the weight adjustment is implemented through formula 1.
[0059]
[0060] in, is the long-tail identification training set for aluminum foil sealing quality detection classification, θ represents the set of weights, θ={θ l,j}, θ l,j represents the weight of the jth filter in the lth layer network, X i represents the data sample, y i Represents the label of the sample, y i ∈[1, ..., K], K represents the number of categories, f(X i ; θ) represents the K-class classification network, l(f(X i ;θ),y i ) represents the cross entropy loss function.
[0061] In step 3, weight attenuation is adjusted specifically through formula 2:
[0062]
[0063] Among them, λ represents the hyperparameter that controls weight decay, θ k represents the classifier weight of the k-th category.
[0064] Weight decay imposes a greater penalty on large weights to prevent them from being too large and encourages learning small weights. By limiting the growth of network weights to constrain the network, the complexity of the network is reduced, overfitting is effectively reduced, and the generalization ability of the network is improved, thereby improving the overall product category screening accuracy of the deep learning classification algorithm.
[0065] In step 3 and step 4, the softmax function of formula 3 is used to calculate the prediction result, and the cross entropy loss of formula 4 is used to measure the loss between the prediction result and the true result;
[0066]
[0067]
[0068] where x i represents the data sample, y i Represents the label of the sample.
[0069] A device for solving the long-tail problem of aluminum foil sealing quality inspection and classification, comprising a data acquisition module, collecting temperature data of the sealed bottle cap and converting the temperature data into an image;
[0070] An 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 the 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 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 occupies one-third of the entire training cycle; the weights of representation learning are frozen, and classifier learning is performed by adjusting the weights. This is the second stage of training, which occupies two-thirds of the entire training cycle.
[0073] The data processing module adjusts the weights through formula 1,
[0074]
[0075] in, is the long-tail identification training set for aluminum foil sealing quality detection classification, θ represents the set of weights, θ={θ l,j}, θ l,j represents the weight of the jth filter in the lth layer network, X i represents the data sample, y i Represents the label of the sample, y i ∈[1, ..., K], K represents the number of categories, f(X i ; θ) represents the 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 attenuation through formula 2:
[0077]
[0078] Among them, λ represents the hyperparameter that controls weight decay, θ krepresents the classifier weight of the k-th category.
[0079] The data processing module uses the softmax function of formula 3 to calculate the prediction result, and uses the cross entropy loss of formula 4 to measure the loss between the prediction result and the actual result;
[0080]
[0081]
[0082] Where xi represents the data sample, y i Represents the label of the sample.
[0083] In the present invention, the reasons for the low accuracy of the existing deep learning image classification algorithm for aluminum foil seal quality detection are fully explored, and the classification long-tail problem is deeply analyzed. According to the characteristics of the distribution of aluminum foil seal quality detection data, a phased training combined with a weight decay strategy is adopted to alleviate the classification long-tail problem of aluminum foil seal quality detection to a large extent. Figure 7 In the current deep learning classification algorithm accuracy statistics for aluminum foil sealing quality detection, Figure 8 In the present invention, the accuracy statistics of the deep learning classification algorithm for aluminum foil sealing quality detection are obtained through Figure 7 and Figure 8 By comparing the data of the previous two examples, it can be clearly found that the number of missed inspections has been reduced from 14 to 5, and the number of passed inspections has been reduced from 14 to 4. This example has greatly improved the accuracy of deep learning image classification for aluminum foil sealing quality inspection by combining phased training with weight decay strategy.
[0084] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for solving the long-tail problem of aluminum foil sealing quality inspection classification, characterized by: The following steps are involved: Step 1: Collect temperature data of the sealed bottle cap and convert the temperature data into an image; Step 2: 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; Step 3: By adjusting weight decay, representation learning is performed on the training sample set to extract backbone network features, and then classifier learning is performed; Step 4: Freeze the weights that represent learning, and learn the classifier by adjusting the weights.
2. The method for solving the long-tail problem of aluminum foil sealing quality inspection classification according to claim 1 is characterized in that: In step 3, by adjusting 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 occupies 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 occupies two-thirds of the entire training cycle.
3. The method for solving the long-tail problem of aluminum foil sealing quality inspection classification according to claim 1 is characterized in that: In step 4, the weight is adjusted by formula 1: in, is the long-tail identification training set for aluminum foil sealing quality detection classification, θ represents the set of weights, θ={θ l,j }, θ l,j represents the weight of the jth filter in the lth layer network, X i represents the data sample, y i Represents the label of the sample, y i ∈[1, ..., K], K represents the number of categories, f(X i ; θ) represents the K-class classification network, l(f(X i ;θ),y i ) represents the cross entropy loss function.
4. The method for solving the long-tail problem of aluminum foil sealing quality inspection classification according to claim 3 is characterized in that: In step 3, weight attenuation is adjusted specifically through formula 2: Among them, λ represents the hyperparameter that controls weight decay, θ k represents the classifier weight of the k-th category.
5. The method for solving the long-tail problem of aluminum foil sealing quality inspection classification according to claim 1 is characterized in that: In step 3 and step 4, the softmax function of formula 3 is used to calculate the prediction result, and the cross entropy loss of formula 4 is used to measure the loss between the prediction result and the true result; where x i represents the data sample, y i Represents the label of the sample.
6. A device for solving the long-tail problem of aluminum foil sealing quality inspection and classification, characterized in that: It includes a data acquisition module, which collects temperature data of the bottle cap after sealing and converts the temperature data into an image; An 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; Freezing represents the learned weights, and classifier learning is performed by adjusting the weights.
7. The device for solving the long-tail problem of aluminum foil sealing quality inspection and classification according to claim 6 is characterized in that: In the data processing module, by adjusting 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 occupies one-third of the entire training cycle; the weights of representation learning are frozen, and classifier learning is performed by adjusting the weights. This is the second stage of training, which occupies two-thirds of the entire training cycle.
8. The device for solving the long-tail problem of aluminum foil sealing quality inspection and classification according to claim 6 is characterized in that: The data processing module adjusts the weights through formula 1, in, is the long-tail identification training set for aluminum foil sealing quality detection classification, θ represents the set of weights, θ={θ l,j }, θ l,j represents the weight of the jth filter in the lth layer network, X i represents the data sample, y i Represents the label of the sample, y i ∈[1, ..., K], K represents the number of categories, f(X i ; θ) represents the K-class classification network, l(f(X i ;θ),y i ) represents the cross entropy loss function.
9. The device for solving the long-tail problem of aluminum foil sealing quality inspection classification according to claim 8 is characterized in that: The data processing module specifically adjusts the weight attenuation through formula 2: Among them, λ represents the hyperparameter that controls weight decay, θ k represents the classifier weight of the k-th category.
10. The device for solving the long-tail problem of aluminum foil sealing quality inspection and classification according to claim 6 is characterized in that: The data processing module uses the softmax function of formula 3 to calculate the prediction result, and uses the cross entropy loss of formula 4 to measure the loss between the prediction result and the actual result; Where xi represents the data sample, y i Represents the label of the sample.
Citation Information
Patent Citations
Aluminum foil sealing detection device and method
CN105921421A
Single monkey video action classification method with long-tail distribution characteristic
CN114596590A
Integrated transfer learning method and system based on depth feature mapping
CN114925802A
Long-tail data classification method and system based on class activation thermodynamic diagram and medium
CN115830372A
Fraud detection and credit evaluation method based on comparative learning and decoupling graph nerves
CN116862667A
Cited By
Method and system of assessing quality of heat seals
GB2703767A
Method and system for detecting heat sealing abnormalities in industrial heat sealing equipment
JP7883333B1
