Task-independent industrial defect visual inspection model training method and device and task-independent industrial defect visual inspection model detection method and device

By introducing the first vector of classifier head and the inner and outer cycle training mechanism in industrial vision detection, combining the compression excitation module and the residual connection network, the gradient disappearance and label arrangement problems of meta-learning in industrial vision detection are solved, and the generalization ability and training stability of the model are improved.

CN119672428APending Publication Date: 2025-03-21SHENZHEN POLYTECHNIC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411756818.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-03-21

AI Technical Summary

Technical Problem

Meta-learning has problems of gradient disappearance or explosion and label arrangement in industrial vision detection, which affects the generalization performance of the model.

Method used

By introducing the first vector of classifier head, initializing the meta parameters and basic learners, conducting internal and external loop training, updating the meta parameters and the first vector of classifier head, combining the compression excitation module and the residual connection network as feature extractors.

Benefits of technology

It effectively avoids gradient vanishing and explosion problems, improves the generalization ability and training stability of the model, and reduces the impact of label arrangement on model performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119672428A_ABST
    Figure CN119672428A_ABST
Patent Text Reader

Abstract

The invention discloses a task-independent industrial defect visual detection model training and detection method and device, and the method comprises the steps: initializing a first vector and a meta parameter of a classifier head, and obtaining support set data and query set data of a training task; sequentially performing internal loop training on each training task according to the meta-parameters, the classifier head first vector and the support set data, updating the basic parameters of the basic learning device after each training to obtain each task parameter corresponding to each training task, and before each training, obtaining each task parameter corresponding to each training task according to the classifier head first vector and the meta-parameters; updating a classifier head and basic parameters of the basic learner; according to the query set data and the task parameters of each training task, performing outer loop training in a meta learning device, and updating meta parameters and a classifier head first vector; and according to the updated meta parameters and the classifier head first vector, initializing an original detection model to obtain an industrial defect visual detection model. By improving the meta-learning framework, the training effect of the detection model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer vision and relates to a task-independent industrial defect visual detection model training, detection method and device. Background Art

[0002] In the detection of industrial product appearance defects, deep learning technology, especially convolutional neural networks (CNNs), has shown strong advantages. However, industrial defect detection faces several key challenges: small target detection, complex background interference, and insufficient samples, especially in few-sample and zero-sample scenarios. To solve the problem of insufficient samples, transfer learning is used to adapt pre-trained models to new detection tasks by fine-tuning them, but due to the domain shift problem unique to industrial defect detection, traditional transfer learning has limited effects.

[0003] Data augmentation and multi-task learning can alleviate the problem of insufficient samples, but these methods still face the problems of difficulty in obtaining auxiliary information and insufficient diversity of data augmentation in industrial defect detection. To this end, meta-learning methods such as model-agnostic meta-learning (MAML) have been proposed, which enables the model to quickly adapt to new tasks with a small number of samples by learning an initial set of parameters. However, meta-learning still has problems with gradient vanishing or exploding and label permutation when dealing with industrial visual recognition tasks. Summary of the invention

[0004] In response to the shortcomings of the prior art, the present application provides a task-independent industrial defect visual inspection model training, detection method and device, which solves the gradient problem encountered in meta-learning for industrial visual inspection and the problem that label arrangement affects the generalization performance of the model.

[0005] To achieve the above objectives, in a first aspect, the present invention provides a task-independent industrial defect visual inspection model training method, comprising:

[0006] Initialize the first vector of the classifier head and the meta-parameters of the meta-learning model, and obtain support set data and query set data of at least one training task; wherein the training task is a training task of a small number of samples in the field of industrial defect detection;

[0007] According to the meta-parameters, the first vector of the classifier head, the support set data of the training task and the preset basic learner, inner loop training is performed on each training task in turn, and the basic parameters of the basic learner are updated after each inner loop training to obtain the task parameters corresponding to each training task, and before each inner loop training, the classifier head of the basic learner is updated according to the first vector of the classifier head, and the basic parameters of the basic learner are updated according to the meta-parameters; wherein the feature extractor of the basic learner includes a compression excitation module and a residual connection network;

[0008] According to the query set data and task parameters of each training task, outer loop training is performed in a preset meta-learner to obtain the meta-loss of each training task, and according to the meta-loss, the meta-parameters and the first vector of the classifier head are updated; wherein the feature extractor of the meta-learner includes a compression excitation module and a residual connection network;

[0009] The original industrial defect visual detection model is initialized according to the updated meta-parameters and the first vector of the classifier head to obtain the industrial defect visual detection model.

[0010] Compared with the prior art, the embodiments of the present application have the following beneficial effects: by introducing the first vector of the classifier head, it is helpful to find a balance point of the classification head module of the basic learner in the subsequent inner loop training, so as to avoid the disadvantages of poor generalization performance and unstable training caused by label arrangement problems in the same task; through the inner loop training, the basic learner can quickly adapt to specific tasks on a small amount of data and improve the generalization ability; the basic parameters of the basic learner are updated so that the basic learner can quickly adjust itself on each task to adapt to the characteristics of the current task; the classifier head and the basic parameters are updated before each inner loop training so that the basic learner can better capture the commonalities between different tasks; combining the compressed excitation module and the residual connection as a feature extractor can avoid the problem of gradient disappearance and explosion, and can also enhance the ability of the feature extraction model to capture pixel-level defects, and improve the training stability and generalization performance; calculating the meta-loss and updating the meta-parameters and the first vector of the classifier head, summarizing the information of multiple tasks to update the meta-parameters, and providing the basic learner with a better initialization state to adapt to the new task; using the updated meta-parameters and the first vector of the classifier head to initialize the original industrial defect visual detection model, the detection model can have a stronger migration ability and a faster learning speed.

[0011] In some embodiments of the first aspect of the present application, updating the basic parameters of the basic learner after each inner loop training to obtain each task parameter corresponding to each training task includes:

[0012] Update the basic parameters of the basic learner to obtain the task parameters corresponding to the training tasks, wherein the updating method is as follows:

[0013]

[0014] in represents the learning rate of the inner loop, i is the number of steps for the inner loop update, is the basic parameter of the basic learner after the i-th cycle when the inner loop calculates the training task b, f θ represents the base learner, is the base learner in the support set data The loss function on , uses the basic parameters after the i-1th step Calculate the loss, is the loss function About basic parameters The gradient of

[0015] The basic parameters of the basic learner obtained in the last cycle of each training task are used as the task parameters corresponding to each training task.

[0016] Compared with the prior art, the above embodiment has the following beneficial effects: updating the basic parameters of the basic learner after each inner loop training helps the basic learner adapt to the unique characteristics of each task; using the basic parameters obtained in the last loop as the task parameters of the corresponding task ensures that the model has been optimized for the current task at the end of each inner loop training, and these task parameters provide a basis for further adjusting the meta-parameters to adapt to future tasks in the subsequent meta-learning process.

[0017] In some embodiments of the first aspect of the present application, before each inner loop training, updating the classifier head of the base learner according to the classifier head first vector includes:

[0018] Decouple the basic parameters of the basic learner: in represents the feature extractor, ω represents the classifier head module, and M represents the number of classification categories;

[0019] The classifier head module is updated according to the first classifier head vector, and the updating method is as follows:

[0020] Where W represents the first vector of the classifier head.

[0021] Compared with the prior art, the above embodiment has the following beneficial effects: before each inner loop training, the first vector of the classifier head is used to update the classifier head, so that the base learner can better capture the commonalities between different tasks, reduce the risk of overfitting of the base learner on specific tasks, improve robustness, and at the same time avoid the shortcomings of poor generalization performance and unstable training caused by label arrangement problems in the same task.

[0022] In some embodiments of the first aspect of the present application, updating the meta-parameters and the first classifier head vector according to the meta-loss includes:

[0023] According to the meta-loss, the meta-parameters are updated in the following manner:

[0024]

[0025] Where Lθ′ represents the sum of the losses of the training tasks of group B on the query set data, θ′ represents the meta-parameter, β represents the learning rate of the outer loop, N represents the number of inner loop trainings of training task b, Indicates the basic parameters updated by the basic learner after the last cycle of training task b in the inner loop training. represents the query set data of training task b, is the meta-learner on the query set The loss function on , using the parameters Calculate the loss, Represents gradient calculation.

[0026] Compared with the prior art, the above embodiment has the following beneficial effects: by summarizing the losses of multiple tasks to update the meta-parameters, a better initialization state is provided for subsequent basic learners to adapt to new tasks, thereby reducing overfitting on a single task.

[0027] In some embodiments of the first aspect of the present application, updating the meta-parameters and the first classifier head vector according to the meta-loss further includes:

[0028] According to the meta-loss, the first vector of the classifier head is updated as follows:

[0029]

[0030] in Represents the weight vector of each classifier head in the b tasks in the inner loop.

[0031] Compared with the prior art, the above embodiment has the following beneficial effects: by aggregating the losses of multiple tasks and updating the first vector of the classifier head, optimization can be performed based on the information of multiple tasks, avoiding the lack of feedback from multiple tasks, helping to solve the label arrangement problem of the base learner and improving the generalization performance.

[0032] In a second aspect, the present invention also provides a task-independent industrial defect visual detection model training device, comprising: an initialization module, an inner loop module, an outer loop module and a result output module.

[0033] The initialization module is used to initialize the first vector of the classifier head and the meta-parameters of the meta-learning model, and obtain support set data and query set data of at least one training task; wherein the training task is a training task of a small number of samples in the field of industrial defect detection;

[0034] The inner loop module is used to perform inner loop training on each training task in turn according to the meta-parameters, the first vector of the classifier head, the support set data of the training task and the preset basic learner, and update the basic parameters of the basic learner after each inner loop training to obtain each task parameter corresponding to each training task, and before each inner loop training, update the classifier head of the basic learner according to the first vector of the classifier head, and update the basic parameters of the basic learner according to the meta-parameters; wherein the feature extractor of the basic learner includes a compression excitation module and a residual connection network;

[0035] The outer loop module is used to perform outer loop training in a preset meta-learner according to the query set data and task parameters of each training task, obtain the meta-loss of each training task, and update the meta-parameters and the first vector of the classifier head according to the meta-loss; wherein the feature extractor of the meta-learner includes a compression excitation module and a residual connection network;

[0036] The result output module is used to initialize the original industrial defect visual detection model according to the updated meta-parameters and the first vector of the classifier head to obtain the industrial defect visual detection model.

[0037] In some embodiments of the second aspect of the present application, the inner loop module includes: a task parameter acquisition unit;

[0038] The task parameter acquisition unit is used to update the basic parameters of the basic learner after each inner loop training to obtain each task parameter corresponding to each training task, including:

[0039] Update the basic parameters of the basic learner to obtain the task parameters corresponding to the training tasks, wherein the updating method is as follows:

[0040]

[0041] in represents the learning rate of the inner loop, i is the number of steps for the inner loop update, is the basic parameter of the basic learner after the i-th cycle when the inner loop calculates the training task b, f θ represents the base learner, is the base learner in the support set data The loss function on , uses the basic parameters after the i-1th step Calculate the loss, is the loss function About basic parameters The gradient of

[0042] The basic parameters of the basic learner obtained in the last cycle of each training task are used as the task parameters corresponding to each training task.

[0043] In some embodiments of the second aspect of the present application, the inner loop module further includes: a classifier head updating unit;

[0044] The classifier head updating unit is used to update the classifier head of the basic learner according to the classifier head first vector before each inner loop training, including:

[0045] Decouple the basic parameters of the basic learner: in represents the feature extractor, ω represents the classifier head module, and M represents the number of classification categories;

[0046] The classifier head module is updated according to the first classifier head vector, and the updating method is as follows:

[0047] Where W represents the first vector of the classifier head.

[0048] In some embodiments of the second aspect of the present application, the outer loop module includes: a meta-parameter updating unit;

[0049] The meta-parameter updating unit is used to update the meta-parameter according to the meta-loss, and the updating method is as follows:

[0050]

[0051] Where L θ′ represents the sum of the losses of the training tasks of group B on the query set data, θ ′ represents the meta-parameter, β represents the learning rate of the outer loop, N represents the number of inner loop trainings for training task b, Indicates the basic parameters updated by the basic learner after the last cycle of training task b in the inner loop training. represents the query set data of training task b, is the meta-learner on the query set The loss function on , using the parameters Calculate the loss, Represents gradient calculation.

[0052] In some embodiments of the second aspect of the present application, the outer loop module further includes: a first vector updating unit;

[0053] The first vector updating unit is used to update the first vector of the classifier head according to the meta-loss, and the updating method is as follows:

[0054]

[0055] in Represents the weight vector of each classifier head in the b tasks in the inner loop.

[0056] Compared with the prior art, the above embodiments of the present application have the following beneficial effects: by introducing the first vector of the classifier head, it is helpful to find a balance point of the classification head module of the basic learner in the subsequent inner loop training, so as to avoid the disadvantages of poor generalization performance and unstable training caused by label arrangement problems in the same task; through the inner loop training, the basic learner can quickly adapt to specific tasks on a small amount of data and improve the generalization ability; the basic parameters of the basic learner are updated so that the basic learner can quickly adjust itself on each task to adapt to the characteristics of the current task; the classifier head and the basic parameters are updated before each inner loop training so that the basic learner can better capture the commonalities between different tasks; combining the compressed excitation module and the residual connection as a feature extractor can avoid the problem of gradient disappearance and explosion, and can also enhance the ability of the feature extraction model to capture pixel-level defects, and improve the training stability and generalization performance; calculating the meta-loss and updating the meta-parameters and the first vector of the classifier head, summarizing the information of multiple tasks to update the meta-parameters, and providing the basic learner with a better initialization state to adapt to the new task; using the updated meta-parameters and the first vector of the classifier head to initialize the original industrial defect visual detection model, the detection model can have a stronger migration ability and a faster learning speed.

[0057] In a third aspect, the present invention further provides a task-independent industrial defect visual detection method, comprising: acquiring an industrial defect image to be detected;

[0058] The industrial defect image is input into an industrial defect visual detection model so that the industrial defect visual detection model outputs a defect visual detection result; wherein the industrial defect visual detection model is trained according to the above-mentioned task-independent industrial defect visual detection model training method.

[0059] In a fourth aspect, the present invention further provides a task-independent industrial defect visual inspection device, comprising: an acquisition module and a processing module;

[0060] Wherein, the acquisition module is used to acquire the industrial defect image to be detected;

[0061] The processing module is used to input the industrial defect image into the industrial defect visual detection model so that the industrial defect visual detection model outputs a defect visual detection result; wherein, the industrial defect visual detection model is trained according to the above-mentioned task-independent industrial defect visual detection model training method. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 : A flow chart of a task-independent industrial defect visual inspection model training and inspection method provided in some embodiments of the present invention.

[0063] Figure 2 : A structural schematic diagram of a task-independent industrial defect visual detection model training and detection device provided in some embodiments of the present invention.

[0064] Figure 3 : A comparison chart of the 2-way normalized accuracy indicators of 6 subsets of the MVTec dataset between a task-independent industrial defect visual detection model training method provided in some embodiments of the present invention and a mainstream industrial product defect recognition algorithm.

[0065] Figure 4 : A comparison chart of the 3-way normalized accuracy indicators of 6 subsets of the MVTec dataset between a task-independent industrial defect visual detection model training method provided in some embodiments of the present invention and a mainstream industrial product defect recognition algorithm.

[0066] Figure 5 : A comparison diagram of the training stability of a task-independent industrial defect visual detection model training method provided in some embodiments of the present invention and other baseline methods in training a 2-way classifier in subset 1 of MvTec.

[0067] Figure 6 : A comparison diagram of the training stability of a task-independent industrial defect visual detection model training method provided in some embodiments of the present invention and other baseline methods in training a 3-way classifier in subset 1 of MvTec.

[0068] Figure 7 : An ablation experiment result diagram of a task-independent industrial defect visual detection model training framework provided in some embodiments of the present invention.

[0069] Figure 8 : A pseudo code implementation diagram of a task-independent industrial defect visual detection model training method provided in some embodiments of the present invention. DETAILED DESCRIPTION

[0070] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0071] Embodiment 1:

[0072] Please refer to Figure 1 , a task-independent industrial defect visual detection model training method provided by an embodiment of the present invention, comprising steps S1 to S4:

[0073] Step S1: Initialize the first vector of the classifier head and the meta-parameters of the meta-learning model, and obtain support set data and query set data of at least one training task.

[0074] Preferably, the training task may be a training task with a small number of samples in the field of industrial defect detection, or may be any other type of training task.

[0075] In this preferred embodiment, step S1 introduces the first vector of the classifier head, which helps to find a balance point of the classification head module of the basic learner in the subsequent inner loop training, thereby avoiding the shortcomings of poor generalization performance and unstable training caused by label arrangement problems in the same task.

[0076] Step S2: According to the meta-parameters, the first vector of the classifier head, the support set data of the training task and the preset basic learner, inner loop training is performed on each training task in turn, and the basic parameters of the basic learner are updated after each inner loop training to obtain the task parameters corresponding to each training task, and before each inner loop training, the classifier head of the basic learner is updated according to the first vector of the classifier head, and the basic parameters of the basic learner are updated according to the meta-parameters.

[0077] Preferably, in some embodiments of the present application, the updating of the basic parameters of the basic learner after each inner loop training to obtain the task parameters corresponding to each training task can be achieved by the following preferred implementations:

[0078] Update the basic parameters of the basic learner to obtain the task parameters corresponding to the training tasks, wherein the updating method is as follows:

[0079]

[0080] in represents the learning rate of the inner loop, i is the number of steps for the inner loop update, is the basic parameter of the basic learner after the i-th cycle when the inner loop calculates the training task b, f θ represents the base learner, is the base learner in the support set data The loss function on , uses the basic parameters after the i-1th step Calculate the loss, is the loss function About basic parameters The gradient of

[0081] The basic parameters of the basic learner obtained in the last cycle of each training task are used as the task parameters corresponding to each training task.

[0082] Furthermore, before each inner loop training, updating the classifier head of the basic learner according to the first vector of the classifier head can be implemented by the following preferred implementation:

[0083] Decouple the basic parameters of the basic learner: in represents the feature extractor, ω represents the classifier head module, and M represents the number of classification categories;

[0084] The classifier head module is updated according to the first classifier head vector, and the updating method is as follows:

[0085] Where W represents the first vector of the classifier head.

[0086] Furthermore, the basic learner can use a compression-excitation residual network model obtained by combining a compression-excitation module with a residual connection network as a feature extractor.

[0087] For example, the process of data propagation forward in the feature extractor is as follows:

[0088] Assume that the input data shape is (3, 224, 224), which represents a 224×224 image with 3 channels. In the initial convolution layer, the shape of the convolution kernel is 7×7, and the stride is 2. The shape of the data after passing through this convolution layer is (64, 112, 112), where 64 is the number of channels; then it passes through a 3×3 maximum pooling layer with a stride of 2, and the output shape after pooling is (64, 56, 56). Its main purpose is to halve the spatial size. The data is then input into the first convolution module of the compression-excitation residual network model module, which includes two 3×3 convolutions. The convolution kernel size remains unchanged, but the output channel becomes 128, and the spatial size is The output data is reduced by half, and the output shape is (128, 28, 28); then the output data is input into the second convolution module, the output channel is further increased to 256, and the spatial size is further halved, and the input data shape is (256, 14, 14); the output data is input into the third convolution module, the output channel continues to double, and the spatial size is reduced by half, and the output size is: (512, 7, 7); finally, after the most comprehensive average pooling layer, the entire spatial dimension is reduced to 1×1, and the output shape is (512, 1, 1).

[0089] In this preferred embodiment, the compressed-excitation residual network model obtained by combining the compressed excitation module with the residual connection network is used as a feature extractor, which can avoid the gradient vanishing and explosion problems and enhance the model's ability to capture pixel-level defects, thereby improving training stability and generalization performance.

[0090] In this preferred embodiment, step S2 updates the basic parameters of the basic learner after each inner loop training, which helps the basic learner adapt to the unique characteristics of each task; the basic parameters obtained in the last loop are used as the task parameters of the corresponding task, ensuring that the model has been optimized for the current task at the end of each inner loop training, and these task parameters provide a basis for further adjusting the meta-parameters to adapt to future tasks in the subsequent meta-learning process; before each inner loop training, the classifier head is updated using the first vector of the classifier head, so that the basic learner can better capture the commonalities between different tasks, reduce the risk of overfitting of the basic learner on specific tasks, improve robustness, and at the same time avoid the shortcomings of poor generalization performance and unstable training caused by label arrangement problems in the same task.

[0091] Step S3: performing outer loop training in a preset meta-learner according to the query set data and task parameters of each training task, obtaining the meta-loss of each training task, and updating the meta-parameters and the first vector of the classifier head according to the meta-loss.

[0092] Preferably, in some embodiments of the present application, updating the meta-parameter according to the meta-loss includes:

[0093] According to the meta-loss, the meta-parameters are updated in the following manner:

[0094]

[0095] Where L θ′ represents the sum of the losses of the training tasks of group B on the query set data, θ ′ represents the meta-parameter, β represents the learning rate of the outer loop, N represents the number of inner loop trainings for training task b, Indicates the basic parameters updated by the basic learner after the last cycle of training task b in the inner loop training. represents the query set data of training task b, is the meta-learner on the query set The loss function on , using the parameters Calculate the loss, Represents gradient calculation.

[0096] Further, the updating the first vector of the classifier head according to the meta-loss further includes:

[0097] According to the meta-loss, the first vector of the classifier head is updated as follows:

[0098]

[0099] in Represents the weight vector of each classifier head in the b tasks in the inner loop.

[0100] Furthermore, the feature extractor of the meta-learner can be the same as the basic learner, using a compression-excitation residual network model obtained by combining a compression-excitation module with a residual connection network as a feature extractor.

[0101] In this preferred embodiment, step S3 updates the meta-parameters by summarizing the losses of multiple tasks, providing a better initialization state for subsequent base learners to adapt to new tasks and reduce overfitting on a single task; updating the first vector of the classifier head can be optimized based on the information of multiple tasks to avoid the lack of feedback from multiple tasks, which helps to solve the label arrangement problem of the base learner and improve the generalization performance.

[0102] Step S4: Initialize the original industrial defect visual detection model according to the updated meta-parameters and the first vector of the classifier head to obtain the industrial defect visual detection model.

[0103] In this embodiment, step S4 initializes the original industrial defect visual inspection model by using the updated meta-parameters and the first vector of the classifier head, so that the inspection model has stronger migration ability and faster learning speed.

[0104] In addition, as an implementation method, the above-mentioned task-independent industrial defect visual detection model training method can also be implemented as follows: Figure 8 A pseudocode implementation diagram of a task-independent industrial defect visual detection model training method is shown for implementation.

[0105] Furthermore, if Figure 3 The comparison chart of the 2-way normalized accuracy index of the training method of the present application and the mainstream industrial product defect recognition algorithm on 6 subsets of the MVTec dataset is shown. Figure 4 The 3-way normalized accuracy index comparison chart of the training method of the present application and the mainstream industrial product defect recognition algorithm on 6 subsets of the MVTec data set is shown. Figure 5 The comparison diagram of the training stability of the training method of the present application and other baseline methods in training 2-way classifiers in subset 1 of MvTec is shown, and Figure 6The comparison diagram of the training stability of the training method of the present application in subset 1 of MvTec and other baseline methods in training 3-way classifiers is shown. The task-independent industrial defect visual detection model training method of the present application is based on the ResNet-12 model as the basic framework, and introduces a one-dimensional vector, compression and excitation module and residual network. In terms of normalized accuracy, the average level is significantly higher than some other mainstream methods, and the overall stability curve during training is also significantly higher than other algorithms.

[0106] As a supplement, Figure 7 The ablation experiment result diagram of a task-independent industrial defect visual detection model training framework is shown. After the introduction of one-dimensional vector W, compression and excitation module (SE module) and residual block, the normalized accuracy (ACCnor) of the model framework is significantly higher than that of the other three cases, proving the beneficial effects of the introduction of one-dimensional vector, compression and excitation module and residual connection on the training framework, that is, proving the improvement effect of the technical solution of the present application compared with the prior art.

[0107] In summary, compared with the prior art, the above embodiments of the present application have the following beneficial effects: by introducing the first vector of the classifier head, it is helpful to find a balance point of the classification head module of the basic learner in the subsequent inner loop training, avoiding the shortcomings of low generalization performance and unstable training caused by label arrangement problems in the same task; through inner loop training, the basic learner can quickly adapt to specific tasks on a small amount of data and improve the generalization ability; the basic parameters of the basic learner are updated, so that the basic learner can quickly adjust itself on each task to adapt to the characteristics of the current task; the classifier head and basic parameters are updated before each inner loop training, The basic learner can better capture the commonalities between different tasks; combining the compressed excitation module and the residual connection as a feature extractor can avoid the gradient vanishing and explosion problems, and can also enhance the ability of the feature extraction model to capture pixel-level defects, improve training stability and generalization performance; calculate the meta-loss and update the meta-parameters and the first vector of the classifier head, summarize the information of multiple tasks to update the meta-parameters, and provide a better initialization state for the basic learner to adapt to new tasks; use the updated meta-parameters and the first vector of the classifier head to initialize the original industrial defect visual detection model, which can make the detection model have stronger migration ability and faster learning speed.

[0108] Embodiment 2:

[0109] Please refer to Figure 2 Based on the same inventive concept, an embodiment of the present invention discloses a task-independent industrial defect visual detection model training device, including: an initialization module M1, an inner loop module M2, an outer loop module M3 and a result output module M4.

[0110] The initialization module M1 is used to initialize the first vector of the classifier head and the meta-parameters of the meta-learning model, and obtain the support set data and query set data of at least one training task.

[0111] Preferably, the training task may be a training task with a small number of samples in the field of industrial defect detection, or may be other types of training tasks;

[0112] Compared with the prior art, the initialization module M1 of this embodiment introduces the first vector of the classifier head, which helps to find a balance point of the basic learner classification head module in the subsequent inner loop training, thereby avoiding the shortcomings of poor generalization performance and unstable training caused by label arrangement problems in the same task.

[0113] The inner loop module M2 is used to perform inner loop training on each training task in turn according to the meta-parameters, the first vector of the classifier head, the support set data of the training task and the preset basic learner, and to update the basic parameters of the basic learner after each inner loop training to obtain the task parameters corresponding to each training task, and before each inner loop training, update the classifier head of the basic learner according to the first vector of the classifier head, and update the basic parameters of the basic learner according to the meta-parameters.

[0114] Preferably, the basic learner can use a compression-excitation residual network model obtained by combining a compression-excitation module with a residual connection network as a feature extractor.

[0115] The inner loop module M2 includes: a task parameter acquisition unit; the task parameter acquisition unit is used to update the basic parameters of the basic learner after each inner loop training, and obtain each task parameter corresponding to each training task, including:

[0116] Update the basic parameters of the basic learner to obtain the task parameters corresponding to the training tasks, wherein the updating method is as follows:

[0117]

[0118] in represents the learning rate of the inner loop, i is the number of steps for the inner loop update, is the basic parameter of the basic learner after the i-th cycle when the inner loop calculates the training task b, f θ represents the base learner, is the base learner in the support set data The loss function on , uses the basic parameters after the i-1th step Calculate the loss, is the loss function About basic parameters The gradient of

[0119] The basic parameters of the basic learner obtained in the last cycle of each training task are used as the task parameters corresponding to each training task.

[0120] Furthermore, the inner loop module M2 further includes: a classifier head updating unit; the classifier head updating unit is used to update the classifier head of the basic learner according to the classifier head first vector before each inner loop training, including:

[0121] Decouple the basic parameters of the basic learner: in represents the feature extractor, ω represents the classifier head module, and M represents the number of classification categories;

[0122] The classifier head module is updated according to the first classifier head vector, and the updating method is as follows:

[0123] Where W represents the first vector of the classifier head.

[0124] Compared with the prior art, the inner loop module M2 of this embodiment updates the basic parameters of the basic learner after each inner loop training, which helps the basic learner adapt to the unique characteristics of each task; the basic parameters obtained in the last loop are used as the task parameters of the corresponding task to ensure that the model has been optimized for the current task at the end of each inner loop training. These task parameters provide a basis for further adjusting the meta-parameters to adapt to future tasks in the subsequent meta-learning process; before each inner loop training, the classifier head is updated using the first vector of the classifier head, so that the basic learner can better capture the commonalities between different tasks, reduce the risk of overfitting of the basic learner on specific tasks, improve robustness, and avoid the shortcomings of poor generalization performance and unstable training caused by label arrangement problems in the same task; the compressed-excitation residual network model obtained by combining the compressed excitation module with the residual connection network is used as a feature extractor to avoid gradient vanishing and explosion problems, and can also enhance the model's ability to capture pixel-level defects, thereby improving training stability and generalization performance.

[0125] The outer loop module M3 is used to perform outer loop training in a preset meta-learner according to the query set data and task parameters of each training task, obtain the meta-loss of each training task, and update the meta-parameters and the first vector of the classifier head according to the meta-loss.

[0126] Preferably, the meta-learner may use a compression-excitation residual network model obtained by combining a compression-excitation module with a residual connection network as a feature extractor.

[0127] The outer loop module M3 includes: a meta parameter updating unit; the meta parameter updating unit is used to update the meta parameter according to the meta loss, and the updating method is as follows:

[0128]

[0129] Where L θ′ represents the sum of the losses of the training tasks of group B on the query set data, θ ′ represents the meta-parameter, β represents the learning rate of the outer loop, N represents the number of inner loop trainings for training task b, Indicates the basic parameters updated by the basic learner after the last cycle of training task b in the inner loop training. represents the query set data of training task b, is the meta-learner on the query set D b q The loss function on , using the parameters Calculate the loss, Represents gradient calculation.

[0130] Furthermore, the outer loop module M3 further includes: a first vector updating unit; the first vector updating unit is used to update the first vector of the classifier head according to the element loss, and the updating method is as follows:

[0131]

[0132] in Represents the weight vector of each classifier head in the b tasks in the inner loop.

[0133] Compared with the prior art, the outer loop module M3 of this embodiment updates the meta-parameters by aggregating the losses of multiple tasks, providing a better initialization state for subsequent basic learners to adapt to new tasks and reduce overfitting on a single task; updating the first vector of the classifier head can be optimized according to the information of multiple tasks to avoid the lack of feedback from multiple tasks, which is helpful to solve the label arrangement problem of the basic learner and improve the generalization performance. The compressed-excitation residual network model obtained by combining the compressed excitation module with the residual connection network is used as a feature extractor to avoid the gradient vanishing and explosion problems, and can also enhance the model's ability to capture pixel-level defects, thereby improving training stability and generalization performance.

[0134] The result output module M4 is used to initialize the original industrial defect visual detection model according to the updated meta-parameters and the first vector of the classifier head to obtain the industrial defect visual detection model.

[0135] Compared with the prior art, the result output module M4 of this embodiment uses the updated meta-parameters and the first vector of the classifier head to initialize the original industrial defect visual detection model, so that the detection model has stronger migration ability and faster learning speed.

[0136] In summary, compared with the prior art, the embodiments of the present application have the following beneficial effects: by introducing the first vector of the classifier head, it is helpful to find a balance point of the classification head module of the basic learner in the subsequent inner loop training, avoiding the shortcomings of low generalization performance and unstable training caused by label arrangement problems in the same task; through inner loop training, the basic learner can quickly adapt to specific tasks on a small amount of data and improve the generalization ability; the basic parameters of the basic learner are updated, so that the basic learner can quickly adjust itself on each task to adapt to the characteristics of the current task; the classifier head and basic parameters are updated before each inner loop training, so that The obtained basic learner can better capture the commonalities between different tasks; combining the compressed excitation module and the residual connection as a feature extractor can avoid the gradient vanishing and explosion problems, and can also enhance the ability of the feature extraction model to capture pixel-level defects, improve training stability and generalization performance; calculate the meta-loss and update the meta-parameters and the first vector of the classifier head, summarize the information of multiple tasks to update the meta-parameters, and provide a better initialization state for the basic learner to adapt to new tasks; use the updated meta-parameters and the first vector of the classifier head to initialize the original industrial defect visual detection model, which can make the detection model have stronger migration ability and faster learning speed.

[0137] Embodiment three:

[0138] Please refer to Figure 1 , a task-independent industrial defect visual inspection method provided by an embodiment of the present invention, comprising steps S5 to S6:

[0139] Step S5: Acquire an industrial defect image to be detected;

[0140] Step S6: inputting the industrial defect image into the industrial defect visual detection model so that the industrial defect visual detection model outputs a defect visual detection result; wherein the industrial defect visual detection model is trained according to the above-mentioned task-independent industrial defect visual detection model training method.

[0141] Embodiment 4:

[0142] Please refer to Figure 2 , a task-independent industrial defect visual inspection device provided by an embodiment of the present invention, comprising an acquisition module M5 and a processing module M6;

[0143] Wherein, the acquisition module M5 is used to acquire the industrial defect image to be detected;

[0144] The processing module M6 is used to input the industrial defect image into the industrial defect visual detection model so that the industrial defect visual detection model outputs a defect visual detection result; wherein, the industrial defect visual detection model is trained according to the above-mentioned task-independent industrial defect visual detection model training method.

[0145] The specific working process of each module described above can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here. The module division is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system.

[0146] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.

Claims

1. A task-independent industrial defect visual inspection model training method, characterized in that: include: Initialize the first vector of the classifier head and the meta-parameters of the meta-learning model, and obtain support set data and query set data of at least one training task; wherein the training task is a training task of a small number of samples in the field of industrial defect detection; According to the meta-parameters, the first vector of the classifier head, the support set data of the training task and the preset basic learner, inner loop training is performed on each training task in turn, and the basic parameters of the basic learner are updated after each inner loop training to obtain the task parameters corresponding to each training task, and before each inner loop training, the classifier head of the basic learner is updated according to the first vector of the classifier head, and the basic parameters of the basic learner are updated according to the meta-parameters; wherein the feature extractor of the basic learner includes a compression excitation module and a residual connection network; According to the query set data and task parameters of each training task, outer loop training is performed in a preset meta-learner to obtain the meta-loss of each training task, and according to the meta-loss, the meta-parameters and the first vector of the classifier head are updated; wherein the feature extractor of the meta-learner includes a compression excitation module and a residual connection network; According to the updated meta-parameters and the first vector of the classifier head, the original industrial defect visual detection model is initialized to obtain the industrial defect visual detection model.

2. A task-independent industrial defect visual inspection model training method as claimed in claim 1, characterized in that: The updating of the basic parameters of the basic learner after each inner loop training to obtain the task parameters corresponding to each training task includes: Update the basic parameters of the basic learner to obtain the task parameters corresponding to the training tasks, wherein the updating method is as follows: in represents the learning rate of the inner loop, i is the number of steps for the inner loop update, is the basic parameter of the basic learner after the i-th cycle when the inner loop calculates the training task b, f θ represents the base learner, is the base learner in the support set data The loss function on , uses the basic parameters after the i-1th step Calculate the loss, is the loss function About basic parameters The gradient of The basic parameters of the basic learner obtained in the last cycle of each training task are used as the task parameters corresponding to each training task.

3. A task-independent industrial defect visual inspection model training method as claimed in claim 2, characterized in that: Before each inner loop training, updating the classifier head of the basic learner according to the first classifier head vector includes: Decouple the basic parameters of the basic learner: in represents the feature extractor, ω represents the classifier head module, and M represents the number of classification categories; The classifier head module is updated according to the first classifier head vector, and the updating method is as follows: Where W represents the first vector of the classifier head.

4. A task-independent industrial defect visual inspection model training method as claimed in claim 3, characterized in that: The updating of the meta-parameters and the first vector of the classifier head according to the meta-loss comprises: According to the meta-loss, the meta-parameters are updated in the following manner: Where L θ′ represents the sum of the losses of the training tasks of group B on the query set data, θ′ represents the meta-parameter, β represents the learning rate of the outer loop, N represents the number of inner loop trainings of training task b, Indicates the basic parameters updated by the basic learner after the last cycle of training task b in the inner loop training. represents the query set data of training task b, is the meta-learner on the query set The loss function on , using parameters Calculate the loss, Represents gradient calculation.

5. A task-independent industrial defect visual inspection model training method as claimed in claim 4, characterized in that: The updating of the meta-parameters and the first vector of the classifier head according to the meta-loss further includes: According to the meta-loss, the first vector of the classifier head is updated as follows: in Represents the weight vector of each classifier head in the b tasks in the inner loop.

6. A task-independent industrial defect visual inspection model training device, characterized in that: include: Initialization module, inner loop module, outer loop module and result output module; The initialization module is used to initialize the first vector of the classifier head and the meta-parameters of the meta-learning model, and obtain support set data and query set data of at least one training task; wherein the training task is a training task of a small number of samples in the field of industrial defect detection; The inner loop module is used to perform inner loop training on each training task in turn according to the meta-parameters, the first vector of the classifier head, the support set data of the training task and the preset basic learner, and update the basic parameters of the basic learner after each inner loop training to obtain each task parameter corresponding to each training task, and before each inner loop training, update the classifier head of the basic learner according to the first vector of the classifier head, and update the basic parameters of the basic learner according to the meta-parameters; wherein the feature extractor of the basic learner includes a compression excitation module and a residual connection network; The outer loop module is used to perform outer loop training in a preset meta-learner according to the query set data and task parameters of each training task, obtain the meta-loss of each training task, and update the meta-parameters and the first vector of the classifier head according to the meta-loss; wherein the feature extractor of the meta-learner includes a compression excitation module and a residual connection network; The result output module is used to initialize the original industrial defect visual detection model according to the updated meta-parameters and the first vector of the classifier head to obtain the industrial defect visual detection model.

7. A task-independent industrial defect visual inspection model training device as claimed in claim 6, characterized in that: The inner loop module includes: a task parameter acquisition unit; The task parameter acquisition unit is used to update the basic parameters of the basic learner after each inner loop training to obtain each task parameter corresponding to each training task, including: Update the basic parameters of the basic learner to obtain the task parameters corresponding to the training tasks, wherein the updating method is as follows: in represents the learning rate of the inner loop, i is the number of steps for the inner loop update, is the basic parameter of the basic learner after the i-th cycle when the inner loop calculates the training task b, f θ represents the base learner, is the base learner in the support set data The loss function on , uses the basic parameters after the i-1th step Calculate the loss, is the loss function About basic parameters The gradient of The basic parameters of the basic learner obtained in the last cycle of each training task are used as the task parameters corresponding to each training task.

8. The task-independent industrial defect visual inspection model training device according to claim 7, characterized in that: The inner loop module also includes: a classifier head updating unit; The classifier head updating unit is used to update the classifier head of the basic learner according to the classifier head first vector before each inner loop training, including: Decouple the basic parameters of the basic learner: in represents the feature extractor, ω represents the classifier head module, and M represents the number of classification categories; The classifier head module is updated according to the first classifier head vector, and the updating method is as follows: Where W represents the first vector of the classifier head.

9. The task-independent industrial defect visual inspection model training device according to claim 8, characterized in that: The outer loop module includes: a meta-parameter updating unit; The meta-parameter updating unit is used to update the meta-parameter according to the meta-loss, and the updating method is as follows: Where L θ′ represents the sum of the losses of the training tasks of group B on the query set data, θ′ represents the meta-parameter, β represents the learning rate of the outer loop, N represents the number of inner loop trainings of training task b, Indicates the basic parameters updated by the basic learner after the last cycle of training task b in the inner loop training. represents the query set data of training task b, is the meta-learner on the query set The loss function on , using the parameter θ N b Calculate the loss, Represents gradient calculation.

10. The task-independent industrial defect visual inspection model training device according to claim 9, characterized in that: The outer loop module further includes: a first vector updating unit; The first vector updating unit is used to update the first vector of the classifier head according to the meta-loss, and the updating method is as follows: in Represents the weight vector of each classifier head in the b tasks in the inner loop.

11. A task-independent industrial defect visual inspection method, characterized in that: include: Acquire an image of an industrial defect to be detected; The industrial defect image is input into an industrial defect visual detection model so that the industrial defect visual detection model outputs a defect visual detection result; wherein the industrial defect visual detection model is trained according to a task-independent industrial defect visual detection model training method according to any one of claims 1 to 5.

12. A task-independent industrial defect visual inspection device, characterized in that: include: Acquisition module and processing module; Wherein, the acquisition module is used to acquire the industrial defect image to be detected; The processing module is used to input the industrial defect image into the industrial defect visual detection model so that the industrial defect visual detection model outputs a defect visual detection result; wherein, the industrial defect visual detection model is trained according to a task-independent industrial defect visual detection model training method according to any one of claims 1 to 5.