Cross-category universal industrial defect detection method and system, terminal and medium
Through pre-training feature extraction network and residual feature processing technology, the problem of difficulty in generalizing across categories in industrial defect detection is solved, and defect detection without retraining in new categories is realized, which improves the adaptability and efficiency of detection.
Patent Information
- Application Number
- CN202411215353.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-09-02
AI Technical Summary
The existing technology has the problem of difficulty in generalizing across categories in industrial defect detection, especially due to the uncertainty and scarcity of defects, which leads to the existing anomaly detection methods that need to be modeled separately for each product category, resulting in the model being encountered. Retraining is required when entering the new category, adding manpower, time and computational overhead.
A pre-trained feature extraction network is used to extract initial features and reference features. Through residual feature generation, feature perturbation and cross-class domain invariance constraints, a general industrial defect detection model can be trained, which can be used to eliminate retraining in the new category. It can adapt and generate anomaly scores through feature distribution estimation.
It realizes defect detection in multiple product categories and can be directly applicable to new categories without retraining or fine-tuning. It has stronger ability to generalize across categories, improving the adaptability and efficiency of detection.
Smart Images

Figure CN119151888A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a defect detection technology in the field of image processing technology, and in particular to a cross-category universal industrial defect detection method, system, terminal and medium. Background Art
[0002] There are two main research directions in the field of industrial product defect detection, one is based on target detection, and the other is based on anomaly detection. There are many difficulties and challenges in defect detection: uncertainty, defects are usually associated with a lot of uncertainties, such as uncertain visual features, and some defects are uncertain before they appear; scarcity, defect samples are usually quite scarce, and it is quite difficult and almost impossible to collect a defect data set with a large number of annotations; heterogeneity, defects are irregular, so one type of defect may show completely different visual features from another type of defect, and even the same type of defect may have changes in features. The above-mentioned defect characteristics make it difficult for methods based on target detection to work sometimes, but methods based on anomaly detection can solve the above-mentioned difficulties and challenges to a certain extent. However, there are still many challenges in solving the problem of industrial defect detection from the perspective of anomaly detection. The present invention mainly focuses on the problem of processing industrial product defect detection based on anomaly detection.
[0003] Industrial defect detection based on anomaly detection currently has the problem of domain-dependent feature representation, which makes it difficult to generalize anomaly detection across categories. Due to the uncertainty and scarcity of defects, anomaly detection methods are mainly based on normal feature modeling, and then samples outside the normal feature distribution are regarded as defects. However, because the features between different product categories usually have significant differences, existing anomaly detection methods often need to perform anomaly detection modeling for each category separately, that is, for each product category, a large number of normal samples need to be collected, and an anomaly detection model for the product needs to be trained to learn the normal feature distribution representation of this type of product. Due to the domain-dependent characteristics of the normal representation, the existing methods need to be retrained when encountering new product categories, which will inevitably bring additional manpower, time, and computing overhead such as new sample collection, training, and testing.
[0004] In order to solve the problem of cross-category industrial defect detection, You et al. proposed a unified anomaly detection model UniAD that is applicable to multiple categories. They introduced a neighborhood masked self-attention module and a feature perturbation mechanism to achieve the effect of simultaneous detection of multiple categories. However, this method still has difficulty adapting to unknown new categories that have not been seen in training. In response to this challenge, some studies have begun to focus on how to enable anomaly detection models to adapt quickly in new categories. For example, the RegAD method indirectly addresses the problem of adapting to new categories by training a feature registration network to align input samples at the feature level, and then using a small number of new category normal samples for distribution modeling; while Wang et al. proposed FSAD, which achieves adaptation to new categories through meta-learning methods. Although some progress has been made, these methods currently need to use a small number of normal samples to re-model in new categories, and cannot be directly applied to new categories, and the cross-category defect detection effect of these methods is still not ideal. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a cross-category universal industrial defect detection method, system, terminal and medium.
[0006] According to one aspect of the present invention, a cross-category universal industrial defect detection method is provided, comprising:
[0007] Providing a pre-trained feature extraction network, using the pre-trained feature extraction network to extract features of input samples, and obtaining initial features and corresponding reference features;
[0008] An industrial defect detection model is provided. The model obtains residual features and performs feature perturbations based on initial features of training samples and their corresponding reference features. The trained industrial defect detection model is obtained through cross-domain invariance constraints and normal residual feature distribution training.
[0009] The initial features of the sample to be detected and its corresponding reference features are used as inputs of the trained industrial defect detection model to obtain an abnormality score of the sample to be detected for industrial defect detection.
[0010] Preferably, the extracting features of the input sample using the pre-trained feature extraction network to obtain initial features and corresponding reference features includes:
[0011] Based on the normal samples and abnormal samples of known product categories as training samples, the samples are input into the pre-trained feature extraction network to extract the features of the training samples, thereby obtaining the initial features of the training samples;
[0012] Based on normal samples of known product categories, some samples are selected as reference samples of training samples, and are input into the pre-trained feature extraction network to extract features of the reference samples, thereby obtaining normal features as reference features of training samples;
[0013] Based on the samples to be detected of known product categories or unknown product categories, the samples are input into the pre-trained feature extraction network to extract the features of the samples to be detected, so as to obtain the initial features of the samples to be detected;
[0014] Based on the category to which the sample to be detected belongs, some normal samples are selected as reference samples of the sample to be detected, and are input into the pre-trained feature extraction network to extract features of the reference samples to obtain reference features of the sample to be detected.
[0015] Preferably, an industrial defect detection model is provided, which obtains residual features and performs feature perturbations based on the initial features of the training samples and the reference features, and obtains a trained industrial defect detection model through cross-domain invariance constraints and normal residual feature distribution training, including:
[0016] An industrial defect detection model is provided, the industrial defect detection model comprising: a residual feature generation model, a feature constraint model and a feature distribution estimation model;
[0017] The residual feature generation model takes the initial feature of the training sample as input and matches a closest reference feature to generate a residual feature;
[0018] Adding a disturbance feature to the residual feature to obtain a disturbed residual feature;
[0019] The feature constraint model takes the perturbed residual features as input and performs cross-domain invariance constraints to obtain constrained residual features;
[0020] The feature distribution estimation model takes the constrained residual features as input and learns the normal residual feature distribution to obtain a trained industrial defect detection model.
[0021] Preferably, the residual feature generation model takes the initial feature of the training sample as input and matches a closest reference feature to generate the residual feature, including:
[0022] For each initial feature of the input normal sample and abnormal sample, a closest normal reference feature is matched, and the difference between the initial feature and the reference feature is calculated to generate the residual features of the normal sample and the abnormal sample.
[0023] Preferably, the adding a disturbance feature to the residual feature to obtain the disturbed residual feature includes:
[0024] Determine a feature distribution variance according to the modulus value of the residual feature, and use the feature distribution variance to randomly generate a disturbance feature based on a Gaussian distribution;
[0025] The disturbance feature is added to the residual feature to simulate the change of the residual feature of the normal sample in the unknown product category.
[0026] Preferably, the feature constraint model takes the perturbed residual feature as input and performs cross-domain invariance constraint to obtain the constrained residual feature, including:
[0027] The feature constraint model is based on an anomaly-invariant single-classification loss function, which projects the residual features of normal samples into a spatial hypersphere, while keeping the residual features of abnormal samples unchanged, so as to enhance the cross-class domain invariance of the residual features of normal samples and the distinguishability between the residual features of normal samples and the residual features of abnormal samples.
[0028] Preferably, the abnormality-invariant single-classification loss function L occ for:
[0029]
[0030] Among them, i represents the i-th normal sample, N represents the number of normal samples, and y i =1 means that the i-th residual feature is abnormal, y i = 0 means that the i-th residual feature is normal, represents the residual feature after the feature constraint model, Represents the residual features of the input; the first part of the anomaly invariant single-classification loss function represents the single-classification loss function, which is used to constrain the residual features of normal samples to a spatial hypersphere, and the second part represents the anomaly feature invariant constraint term, which is used to allow the residual features of the projected abnormal samples to predict the residual features of the input, thereby keeping the residual features of the abnormal samples from being constrained to the hypersphere.
[0031] Preferably, the feature constraint model is constructed by a single convolutional layer.
[0032] Preferably, the feature distribution estimation model takes the constrained residual feature as input and learns the normal residual feature distribution to obtain a trained industrial defect detection model, including:
[0033] The feature distribution estimation model takes the constrained residual features as input, guides based on explicit boundaries, and utilizes the residual features of abnormal samples to learn the residual feature distribution of normal samples, which is used to generate anomaly scores for input features based on the learned normal residual feature distribution during detection.
[0034] Preferably, the feature distribution estimation model is based on explicit boundary guidance and uses the residual features of abnormal samples to assist in learning the residual feature distribution of normal samples; the trained feature distribution estimation model is used to perform log-likelihood estimation on each input feature, the log-likelihood value is converted into a likelihood value, and then each likelihood value is subtracted from 1 to generate an abnormality score.
[0035] Preferably, the method of using the residual features of abnormal samples to assist in learning the residual feature distribution of normal samples based on explicit boundary guidance includes:
[0036] The input features are transformed into latent space using the feature distribution estimation model, and the latent variables are set to obey Gaussian distribution, and the log-likelihood value of the input features is obtained according to the variational principle;
[0037] Taking the maximization of the log-likelihood value as the optimization goal, optimizing the feature distribution estimation model through the maximum likelihood loss function;
[0038] Construct an explicit boundary-guided semi-push-pull loss function, which includes:
[0039] Define a location hyperparameter β, which is used to control the distance from the normal boundary to the center;
[0040] Sort all log-likelihood values in ascending order, and select the βth percentile of the sorted log-likelihood distribution as the normal boundary bn;
[0041] Introduce a spacing hyperparameter τ and define the anomaly boundary ba as ba = bn-τ;
[0042] The residual features of normal samples outside the normal boundary bn are pulled into the normal boundary bn, and the residual features of abnormal samples within the abnormal boundary ba are pushed out of the abnormal boundary ba;
[0043] The residual feature distribution of normal samples is optimized by the semi-push-pull loss function guided by the explicit boundary, the likelihood value of the residual feature of normal samples is pulled into the distribution, and the likelihood value of the residual feature of abnormal samples is pushed out of the distribution.
[0044] Based on the normal boundary guidance, the residual feature distribution of normal samples and abnormal samples is explicitly divided to complete the residual feature distribution learning of normal samples;
[0045] Preferably, the feature distribution estimation model adopts a normalized flow model, and the normalized flow model is composed of a coupling layer, and the coupling layer is constructed by a fully connected layer.
[0046] Preferably, the initial features of the sample to be detected and the corresponding reference features thereof are used as inputs of the trained industrial defect detection model to obtain the abnormality score of the sample to be detected, including:
[0047] Passing the initial features of the sample to be detected and its corresponding reference features through the trained industrial defect detection model to obtain an abnormality score of the sample to be detected;
[0048] Based on the abnormality score, the image-level abnormality threshold and the pixel-level abnormality threshold are used to determine defective products and defective areas; when the abnormality score value is less than the set threshold, it is determined to be a normal product; if the abnormality score value is greater than or equal to the set threshold, it is determined to be a defective product and the corresponding defective area is obtained.
[0049] Preferably, the step of applying the initial features of the sample to be detected and its corresponding reference features to the trained industrial defect detection model to obtain an abnormality score of the sample to be detected includes:
[0050] The initial features of the sample to be detected and the corresponding reference features thereof are generated by the residual feature generation model to obtain the residual features of the sample to be detected;
[0051] Passing the residual features of the sample to be detected through the feature constraint model to obtain constrained residual features;
[0052] The constrained residual features are passed through a trained feature distribution estimation model to obtain an abnormality score of the sample to be detected.
[0053] According to a second aspect of the present invention, there is provided a cross-category universal industrial defect detection system, comprising:
[0054] A feature extraction module, which is used to provide a pre-trained feature extraction network, and use the pre-trained feature extraction network to extract features of input samples to obtain initial features and corresponding reference features;
[0055] An industrial defect detection training module, which is used to provide an industrial defect detection model. The model obtains residual features and performs feature perturbations based on the initial features of the training samples and their corresponding reference features, and obtains a trained industrial defect detection model through cross-domain invariance constraints and normal residual feature distribution training;
[0056] The industrial defect detection module is used to use the initial features of the sample to be detected and its corresponding reference features as inputs of the trained industrial defect detection model to obtain the abnormality score of the sample to be detected and perform industrial defect detection.
[0057] Preferably, the industrial defect detection model comprises:
[0058] A residual feature generation module, which is used to convert the initial features into residual features;
[0059] A feature constraint module, which is used to constrain normal residual features in the residual features to a spatial hypersphere and keep abnormal residual features in the residual features unchanged, thereby enhancing the cross-domain invariance of the normal residual features and the distinguishability between the normal residual features and the abnormal residual features;
[0060] A feature distribution estimation module is used to learn the normal residual feature distribution and generate anomaly scores for input features based on the learned normal residual feature distribution.
[0061] According to a third aspect of the present invention, there is provided a cross-category universal industrial defect detection terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, can be used to execute any one of the methods described above in the present invention, or to run any one of the systems described above in the present invention.
[0062] According to a fourth aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can be used to execute any of the methods described above in the present invention, or to run any of the systems described above in the present invention.
[0063] Due to the adoption of the above technical solution, the present invention has at least one of the following beneficial effects compared with the prior art:
[0064] The present invention can not only realize that one model can be used for defect detection in multiple product categories at the same time, but more advantageously, it can be directly used in new categories without the need for retraining or fine-tuning. Only a small number of normal samples in the new category are needed as reference. Compared with previous anomaly detection methods, this method has stronger cross-category generalization capabilities.
[0065] Compared with the initial features generated by the pre-trained feature extraction network, the residual features of the present invention have stronger domain invariance, are mainly distributed in a feature area centered on the origin, and will not produce significant changes in the feature domain with the change of categories. They are more suitable for designing cross-class anomaly detection models.
[0066] The present invention can increase the variation of residual features by adding perturbation features during training, so as to better cope with possible variations of normal residual features in unknown classes.
[0067] The present invention uses feature constraints and anomaly-invariant single-classification loss to constrain normal residual features, which can further enhance the domain invariance of normal residual features and the distinguishability between normal / abnormal residual features.
[0068] The present invention learns the normal residual feature distribution in feature distribution estimation and pushes the abnormal residual features out of the distribution. Through the training, an abnormal score is finally obtained, which has better adaptability. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0070] Figure 1 The flowchart is a cross-category universal industrial defect detection method in one embodiment of the present invention.
[0071] Figure 2 Schematic diagram of the training process of the industrial defect detection model in a preferred embodiment of the present invention.
[0072] Figure 3 Schematic diagram of the testing process of the industrial defect detection model in a preferred embodiment of the present invention.
[0073] Figure 4 The present invention is a flowchart of a cross-category universal industrial defect detection method in a preferred embodiment of the present invention.
[0074] Figure 5 Schematic diagram of the training and testing process of the industrial defect detection model in a preferred embodiment of the present invention.
[0075] Figure 6 Schematic diagram of the components of a cross-category universal industrial defect detection system in one embodiment of the present invention. DETAILED DESCRIPTION
[0076] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several variations and improvements may be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0077] Existing industrial defect detection technologies usually have the problem of difficulty in cross-category generalization. To address this problem, an embodiment of the present invention provides a cross-category general industrial defect detection method, which solves the problem of industrial defect detection from the perspective of anomaly detection, and uses residual features to perform domain invariance constraints. The model trained based on residual features is category-independent and not subject to cross-category restrictions. For newly emerging industrial product categories, it can be used in the category without retraining and fine-tuning, and is suitable for application scenarios such as industrial defect detection with diversified product categories and continuous development of new ones.
[0078] Specifically, Figure 1As shown, the cross-category universal industrial defect detection method provided by this embodiment may include the following operations:
[0079] S100, providing a pre-trained feature extraction network, using the pre-trained feature extraction network to extract features of input samples, and obtaining initial features and corresponding reference features; further, the input samples include: training samples and samples to be detected and their reference samples, the obtained reference features are normal features of the reference samples, and the obtained initial features include initial features of the training samples and initial features of the samples to be detected;
[0080] S200, providing an industrial defect detection model, the model is based on the initial features of the training sample and the corresponding reference features, obtains the residual features and performs feature perturbation, and obtains the trained industrial defect detection model through cross-domain invariance constraints and normal residual feature distribution training;
[0081] S300, using the initial features of the sample to be detected and its corresponding reference features as inputs of the trained industrial defect detection model to obtain an abnormality score of the sample to be detected for industrial defect detection.
[0082] In some preferred implementations, the industrial defect detection model provided in this embodiment may further include the following three parts:
[0083] The first part is the residual feature generation model, which is used to convert the initial features into residual features. The residual features have stronger domain invariance and are more suitable for cross-class defect detection. The initial features are generated by the pre-trained feature extraction network.
[0084] The second part is the feature constraint model, which is used to further constrain the residual features of normal samples (hereinafter referred to as normal residual features) into a spatial hypersphere and keep the residual features of abnormal samples (hereinafter referred to as abnormal residual features) as unchanged as possible, so as to enhance the domain invariance of cross-class normal residual features and the distinguishability between normal residual features and abnormal residual features;
[0085] The third part is the feature distribution estimation model, which learns the normal residual feature distribution and pushes the abnormal residual features out of the distribution during training, and generates anomaly scores for the input features based on the learned distribution during testing.
[0086] In some preferred implementations, the industrial defect detection model provided in this embodiment may further include:
[0087] In the training phase, the feature constraint model and the feature distribution estimation model are trained separately. The feature constraint model projects the normal residual features into a spatial hypersphere based on the abnormal invariant single classification loss, while the abnormal residual features remain unchanged, so as to further enhance the domain invariance of the normal residual features and the distinction between the normal residual features and the abnormal residual features; the constrained features (constrained features) generated by the feature constraint model will be further input into the feature distribution estimation model, which learns the normal residual feature distribution based on the probability generation model (preferably the normalized flow model) and the maximum likelihood loss. Figure 2 shown.
[0088] In the test phase (detection phase), the test samples (samples to be tested) are sent to the residual feature generation model, feature constraint model and feature distribution estimation model in turn. The residual feature generation model converts the initial features of the samples to be tested into residual features based on the reference features corresponding to the samples to be tested. The feature constraint model constrains the normal residual features and tries to keep the abnormal residual features unchanged. Finally, the feature distribution estimation model estimates the likelihood values of all input features. Normal residual features that conform to the learned distribution will have a larger likelihood value, while abnormal residual features will generally have a smaller likelihood value because they are far away from the distribution. The likelihood value can be further converted into anomaly scores; based on the final anomaly score map, image-level anomaly thresholds and pixel-level anomaly thresholds are used to determine defective products and defective areas. Figure 3 shown.
[0089] The technical solutions provided by the above embodiments of the present invention are further described in detail below in conjunction with preferred embodiments.
[0090] like Figure 4 and Figure 5 As shown, a preferred embodiment of the present invention provides a cross-category universal industrial defect detection method, comprising the following steps:
[0091] S1, based on the normal sample set, uses the pre-trained feature extraction network to extract the features of the normal samples, obtains the normal features, stores them in the normal feature set, and uses them as reference features;
[0092] S2, obtain normal samples and abnormal samples from the training sample set, use the same pre-trained feature extraction network to extract initial features, input these initial features into the residual feature generation model, each initial feature is matched with a closest normal reference feature in the normal feature set, and the residual is calculated between the initial feature and the normal reference feature to generate normal / abnormal residual features;
[0093] S3, based on the residual features in S2, adds feature perturbations to the residual features to simulate the changes of normal residual features in unknown categories;
[0094] S4, based on the residual features after perturbation in S3, inputs them into the feature constraint model, constrains the normal residual features and keeps the abnormal residual features unchanged through the abnormality-invariant single classification loss;
[0095] S5, based on the residual features constrained in S4, input into the feature distribution estimation model, and learn a more discriminative normal residual feature distribution through maximum likelihood loss and boundary-guided contrast loss;
[0096] S6, obtaining a trained industrial defect detection model through the training process of S2 to S5, using the trained industrial defect detection model, finally estimating the logarithmic likelihood of the feature as the abnormality score, detecting defective products, and obtaining the corresponding defect area.
[0097] In a preferred embodiment of the present invention, S1 is implemented. Multi-scale features are extracted by a pre-trained feature extraction network, and the features are aggregated in a local neighborhood, which can refer to the following operations:
[0098] For an input image I i ∈R H×W×3 , the multi-scale features of layer L are extracted by the pre-trained network φ. For the features of layer l, it is expressed as Among them, H l , W l and C l Represent the height, width and channel dimension of the feature map respectively. For a feature at position (h,w), its size is p. for:
[0099]
[0100] Then, using the aggregation operation f agg Aggregate features within the neighborhood to obtain local aggregated features As shown below:
[0101]
[0102] For all samples in the normal sample set, the above operation is performed, and then all the obtained features are stored in the normal feature set. For each feature layer, a corresponding normal feature set is constructed. The normal feature set of the lth layer is It is expressed as:
[0103]
[0104] Wherein, i represents the i-th normal sample, and N represents the number of normal samples in the normal sample set. In the S1 embodiment of the present invention, a network such as WideResNet, EfficientNet and ViT pre-trained on ImageNet can be selected as the pre-trained network φ, the number of multi-scale feature layers L can be set to 3, and the aggregation operation f agg The adaptive average pooling operation is selected. Of course, in other embodiments, different pre-trained networks can also be selected, and the aggregation operation can be set to maximum pooling, etc.
[0105] In a preferred embodiment of the present invention, S2 is implemented. For each sample in the training sample set, a pre-trained feature extraction network is used to extract multi-scale features, and then the initial features are input into the residual feature generation model to be converted into residual features. Compared with the initial features, there will be significant feature distribution changes between different classes. Because the normal residual features are generated by matching the difference between the nearest normal-reference features, the class-related attributes in the features are offset by each other, and they are mainly distributed in the feature domain centered on the origin. Even between different classes, the normal residual feature distribution will not change significantly, and has stronger domain invariance.
[0106] Specifically, for each initial feature From the normal feature set of layer l Match a nearest feature to it As a normal reference feature:
[0107]
[0108] Then, the residual features are defined as the initial features and its nearest normal reference feature The residual representation between:
[0109]
[0110] Where D(·) represents the Euclidean distance of the input feature vector element by element. In this way, the distribution of residual features can be restricted to the positive half of the feature space, so that the distribution of residual features becomes more compact.
[0111] In a preferred embodiment of the present invention, S3 is implemented to add disturbance to the residual features to simulate the changes of normal residual features in unknown categories.
[0112] Specifically, for the residual feature Randomly sample perturbed features x from a Gaussian distribution σ :
[0113]
[0114] Among them, α is the scale of the disturbance used to control the degree of disturbance, and then x is changed with a certain probability p. σ Join In a preferred embodiment, α and p can be set to 5 and 0.5 respectively.
[0115] In a preferred embodiment of the present invention, S4 is implemented: the residual features are input into the feature constraint model, and the normal residual features are constrained by the abnormality-invariant single classification loss.
[0116] The purpose of the feature constraint model is to constrain the normal residual features to a spatial hypersphere, while increasing the distinguishability between normal residual features and abnormal residual features. To this end, an abnormality-invariant single-classification loss function L is proposed. occ :
[0117]
[0118] Among them, y i =1 means that the i-th residual feature is abnormal, y i = 0 means that the i-th residual feature is normal, represents the residual feature after the feature constraint network, and Represents the initial residual feature. The first part of the loss function is the pseudo-Huber function, which constrains the normal residual feature to a spatial hypersphere. However, only the first part of the loss is likely to cause the feature constraint network to overfit. If all input features are constrained to the hypersphere, if the abnormal residual features are also constrained to the hypersphere, the distinguishability between the normal residual features and the abnormal residual features will be reduced. Therefore, in the second part of the loss function, an abnormal invariant term is added to allow the projected abnormal residual features to predict the initial residual features, so as to keep the abnormal residual features from being constrained to the hypersphere. Based on the abnormal invariant single-classification loss function, not only can the normal residual feature distribution be more compact, but also the abnormal residual features can be kept as unchanged as possible. The constrained residual feature domain can have stronger domain invariance than the initial residual feature domain, and the normal and abnormal residual features can also be better distinguishable, which is more conducive to subsequent feature distribution learning.
[0119] In a preferred embodiment, in order to avoid overfitting of the feature constraint model to the known residual features, a single-layer convolutional network (specifically a 3×3 convolutional layer, a BatchNorm layer, and a ReLU activation function) is used as the feature constraint model. Of course, in other embodiments, other networks can also be tried to construct the feature constraint model, such as the BasicBlock and BottleNeck network modules in ResNet.
[0120] In a preferred embodiment of the present invention, S5 is implemented. Based on the residual features constrained in S4, the residual features are input into the feature distribution estimation model, and preferably a normalized flow model is used as the feature distribution estimation model to learn the normal residual feature distribution.
[0121] use To represent the normalized flow model used, for the input feature x, after the normalized flow model, the log-likelihood logp can be estimated according to the following formula θ (x):
[0122]
[0123] Among them, d is the feature dimension, Represents the latent feature variable formed after the feature x passes through the normalized flow model, is a transformation Jacobian matrix about x. The normalized flow model can transform the input feature x into features in the latent space The features in the latent space are generally assumed to conform to the Gaussian distribution. The normalized flow model generally uses the maximum likelihood method for model optimization, that is, minimizing the negative logarithmic likelihood. Minimizing the negative logarithmic likelihood in the above formula gives the following maximum likelihood loss function L ml :
[0124]
[0125] In a preferred embodiment of the present invention, the use of abnormal residual features should be considered during the training of the normalized flow model, and a boundary-guided contrast loss is used to learn a more compact normal residual feature distribution and enhance the distinction between normal and abnormal. For details, refer to the following operations:
[0126] Define a location hyperparameter β to control the distance from the boundary to the center. Select the βth percentile (e.g. β = 5) of the sorted normal log-likelihood distribution as the normal boundary bn.
[0127] We further introduce a spacing hyperparameter τ and define an anomaly boundary ba = bn-τ
[0128] This preferred embodiment sets the position hyperparameter β to control the distance from the boundary to the center, and the false positive rate of normal samples can be effectively controlled by adjusting β. At the same time, the spacing hyperparameter τ is introduced to control the distance from the abnormal boundary to the normal boundary, and the influence of the contrast loss function guided by the subsequent boundary on the model can be effectively guided by adjusting τ. Since the normal separation boundary only depends on the distribution of normal samples and has nothing to do with abnormal samples, the deviation problem caused by known abnormal samples can be avoided.
[0129] In a preferred embodiment of the present invention, a boundary-guided contrast loss is proposed for learning more discriminative features. The boundary-guided contrast loss can use the normal boundary bn as a reference object, and only pull the normal residual features whose log-likelihood values are less than the normal boundary bn into the boundary, and push the abnormal features whose log-likelihood values are greater than the abnormal boundary ba away from the boundary, at least τ length away from the bn boundary. The boundary-guided contrast loss function formula L bgc The definition is as follows:
[0130]
[0131] The boundary-guided contrast loss function proposed in the above embodiment of the present invention can pull together the normal residual features whose log-likelihood values are smaller than the normal boundary, and push the abnormal residual features whose log-likelihood values are larger than the abnormal boundary away from the abnormal boundary, thereby encouraging the model to learn more discriminative features. At the same time, even in the absence of abnormal samples, the model can be trained through the maximum likelihood loss L ml Make optimizations.
[0132] In a preferred embodiment, a normalized flow model is used as a feature distribution estimation model. Of course, in other embodiments, a Gaussian mixture model, a kernel density estimation method, etc. may also be used to model the distribution of features, and are not limited to the normalized flow model.
[0133] In a preferred embodiment of the present invention, S6 is implemented. Estimating the log-likelihood value as the anomaly score may refer to the following operations:
[0134] First, the trained normalized flow model is used to perform an accurate log-likelihood estimate for each input feature x, as shown below:
[0135]
[0136] Where logp(x) refers to the log likelihood of the input feature x. Based on the estimated log likelihood, it can be converted into likelihood through an exponential function, and the likelihood value ranges from 0 to 1. Since the normalized flow model is optimized by maximizing the log likelihood of the normal residual feature, the likelihood can directly represent the degree of normality. Therefore, the anomaly score can be generated by subtracting each log likelihood value from 1, as shown below:
[0137] s(x)=1-exp(logp(x))
[0138] Where s(x) represents the anomaly score of x. The exponential function is monotonic, so the log-likelihood can be equivalently converted to the anomaly score.
[0139] In a preferred embodiment, each log likelihood value is subtracted from 1 to generate an anomaly score. Of course, likelihood values or other normalization methods may also be used, and are not limited to the anomaly score calculation method.
[0140] In a specific embodiment, during the test process, the trained industrial defect detection model can be used to detect abnormal samples, and the following operations can be referred to:
[0141] First, obtain the test sample. Use the pre-trained feature extraction network to extract the initial features and corresponding reference features of the test sample and its reference sample respectively. The initial features and reference features are converted into residual features through the residual feature generation model. The residual features are constrained by the feature constraint model. Finally, the constrained residual features are input into the trained conditional normalized flow model to estimate the log likelihood. Calculate the anomaly score based on the log likelihood value. If the anomaly score is less than the set threshold, it is judged as a normal sample. If the anomaly score value is greater than the set threshold, it is judged as an abnormal sample.
[0142] In the above embodiment of the present invention, the test sample is sequentially extracted with features through the pre-trained feature extraction network, the residual feature generation model is converted into residual features, the feature constraint model further constrains the features, and finally the log likelihood is estimated through the normalized feature distribution estimation model to obtain the anomaly score. Therefore, only a very low computing cost is required to achieve real-time anomaly detection, which is more suitable for applications such as industrial defect detection.
[0143] Based on the same inventive concept, an embodiment of the present invention also provides an industrial defect detection system that is universal across categories.
[0144] Specifically, Figure 6 As shown, the cross-category universal industrial defect detection system provided by this embodiment may include:
[0145] A feature extraction module, which is used to provide a pre-trained feature extraction network, extract features of input samples using the pre-trained feature extraction network, and obtain initial features and corresponding reference features;
[0146] An industrial defect detection training module is used to provide an industrial defect detection model. The model obtains residual features and performs feature perturbations based on the initial features of the training samples and their corresponding reference features. Through cross-domain invariance constraints and normal residual feature distribution training, a trained industrial defect detection model is obtained.
[0147] The industrial defect detection module is used to use the initial features of the sample to be detected and its corresponding reference features as the input of the trained industrial defect detection model to obtain the abnormality score of the sample to be detected and perform industrial defect detection.
[0148] In some preferred embodiments, the above industrial defect detection training module may further include the following modules:
[0149] Residual feature generation module, which converts the initial features into residual features; residual features have stronger domain invariance and are more suitable for cross-class defect detection. The initial features represent the features generated by the pre-trained feature extraction network;
[0150] The feature constraint module further constrains the normal residual features into a spatial hypersphere based on the single-class loss function and keeps the abnormal residual features unchanged, which is used to enhance the domain invariance of the cross-class normal residual features and the distinguishability between the normal and abnormal residual features;
[0151] The feature distribution estimation module is used to learn the normal residual feature distribution during training (specifically, it can be based on explicit normal boundary guidance and make full use of abnormal residual features to learn a more compact normal residual feature distribution), and generate anomaly scores for input features based on the learned normal residual feature distribution during testing.
[0152] The working process of each functional module of the cross-category universal industrial defect detection system provided by this embodiment is further described in detail below.
[0153] 1. Feature extraction module, used to extract the features of input samples. Its working process includes:
[0154] Based on all normal samples in the known class, a normal sample set is constructed, and the normal sample features are extracted using a pre-trained feature extraction network to obtain normal features;
[0155] Normal features are stored in the normal feature set and used as reference features;
[0156] For each input normal / abnormal sample, features are extracted using a pre-trained feature extraction network, which are called initial features.
[0157] Second, the residual feature generation module is used to convert the initial features into residual features. Its working process is as follows:
[0158] Each normal or abnormal initial feature input into the residual feature generation module will be matched with a closest normal reference feature in the normal feature set, and the difference between the initial feature and the normal reference feature will be calculated to generate a normal / abnormal residual feature.
[0159] Before the residual features are input into the feature constraint module, feature perturbations are added to the residual features to simulate the changes of normal residual features in unknown classes, where:
[0160] For the initial residual features obtained by the residual feature generation module, a perturbation feature is further added. The perturbation feature increases the variation of the residual features during training to better cope with possible variations of normal residual features in unknown classes.
[0161] The perturbation features are randomly generated based on Gaussian distribution, and their feature distribution variance is determined by the modulus value of the residual features.
[0162] 3. Feature constraint module is used to further enhance the cross-class invariance and distinguishability of normal residual features. Its working process is as follows:
[0163] The feature constraint module is optimized by anomaly-invariant single-classification loss;
[0164] In order to avoid overfitting the features of known classes, the feature constraint module is preferably implemented using a simpler neural network, constructed by a single convolutional layer;
[0165] in:
[0166] The feature constraint module is optimized through anomaly-invariant single-class loss, including:
[0167] The loss function consists of a single classification loss function and an abnormal feature invariant constraint term;
[0168] Abnormal invariance means that the learning target of the abnormal features after transformation by the feature constraint module is the abnormal features before transformation, so that the feature constraint module does not transform and constrain the abnormal residual features as much as possible;
[0169] Single classification refers to transforming and constraining the normal residual features into a spatial hypersphere based on the single classification loss function, so as to reduce the cross-class variation of the normal residual features and enhance the cross-class domain invariance.
[0170] Fourth, the feature distribution estimation module is used to learn the normal residual feature distribution and generate anomaly scores for the input features based on the learned normal residual feature distribution. Its working process includes:
[0171] The feature distribution estimation module can adopt any probabilistic generation model with feature distribution modeling. The following preferably adopts a normalized flow model, and further illustrates the normal residual feature distribution learning of the normalized flow model as an example.
[0172] The normalized flow model transforms the input features into the latent space, assumes that the latent variables follow a Gaussian distribution, and estimates the log-likelihood of the input features based on the variational principle;
[0173] The goal of normalized flow model training is to maximize the log-likelihood value, so the normalized flow model is optimized with the maximum likelihood loss function;
[0174] The normalized flow model is also optimized through an explicit boundary-guided semi-push-pull loss function, which pulls the likelihood values of normal features into the distribution and pushes the likelihood values of abnormal features out of the distribution;
[0175] The normalized flow model consists of coupling layers, which are implemented by fully connected layers;
[0176] The normalized flow model can further exploit abnormal residual features to learn a more compact normal residual feature distribution, where:
[0177] The normalized flow model is based on a normal boundary guide, explicitly dividing the normal and abnormal feature distributions;
[0178] Define a location hyperparameter β to control the distance from the boundary to the center;
[0179] Sort all log-likelihood values in ascending order, and select the βth percentile of the sorted log-likelihood distribution as the normal boundary bn;
[0180] A spacing hyperparameter τ is introduced, and the anomaly boundary is defined as ba=bn-τ.
[0181] Normal features outside the normal boundary bn are pulled into the normal boundary, while abnormal features within the abnormal boundary ba are pushed out of the abnormal boundary.
[0182] Estimate the log-likelihood value as anomaly score, including:
[0183] Use the trained normalized flow model to accurately estimate the log-likelihood of each input feature;
[0184] The log-likelihood value is converted into a likelihood value through an exponential function, and the likelihood value is in the range of 0 to 1;
[0185] Each likelihood value is subtracted from 1 to generate an anomaly score.
[0186] 5. Industrial defect detection module: This module is used to estimate the log likelihood as the abnormality score for the sample to be detected and detect abnormal samples. Its working process includes:
[0187] Obtain a test sample (sample to be tested);
[0188] The test sample is extracted with initial features through a pre-trained feature extraction network, and the reference sample of the test sample is extracted with reference features through a pre-trained feature extraction network;
[0189] The initial features and their reference features are transformed into residual features through the residual feature generation module;
[0190] The residual features are further constrained by the feature constraint module, and then the log-likelihood value is estimated by the normalized flow model, and then the log-likelihood value is converted into anomaly score;
[0191] If the anomaly score value is less than the set threshold, it is judged as a normal sample; if the anomaly score value is greater than the set threshold, it is judged as an abnormal sample.
[0192] An embodiment of the present invention also provides an industrial defect detection terminal that is universal across categories, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it can be used to execute the detection method of any one of the above-mentioned embodiments of the present invention, or to run the detection system of any one of the above-mentioned embodiments of the present invention.
[0193] Optionally, the memory is used to store programs; the memory may include volatile memory (English: volatile memory), such as random-access memory (English: random-access memory, abbreviated: RAM), such as static random-access memory (English: static random-access memory, abbreviated: SRAM), double data rate synchronous dynamic random access memory (English: Double Data Rate Synchronous Dynamic Random Access Memory, abbreviated: DDR SDRAM), etc.; the memory may also include non-volatile memory (English: non-volatile memory), such as flash memory (English: flash memory). The memory is used to store computer programs (such as applications, functional modules, etc. that implement the above method), computer instructions, etc., and the above computer programs, computer instructions, etc. can be partitioned and stored in one or more memories. And the above computer programs, computer instructions, data, etc. can be called by the processor.
[0194] The above-mentioned computer programs, computer instructions, etc. may be stored in one or more memories in partitions, and the above-mentioned computer programs, computer instructions, data, etc. may be called by a processor.
[0195] The processor is used to execute the computer program stored in the memory to implement the various steps of the method or various modules of the system involved in the above embodiments. For details, please refer to the relevant descriptions in the above method and system embodiments.
[0196] The processor and the memory may be independent structures or integrated structures. When the processor and the memory are independent structures, the memory and the processor may be coupled and connected via a bus.
[0197] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it can be used to execute the detection method of any one of the above embodiments of the present invention, or to run the detection system of any one of the above embodiments of the present invention.
[0198] Among them, computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of computer programs from one place to another. The storage medium can be any available medium that can be accessed by a general or special-purpose computer. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in a user device. Of course, the processor and the storage medium can also be present in a communication device as discrete components.
[0199] The cross-category universal industrial defect detection method, system, terminal and medium provided by the above-mentioned embodiment of the present invention, in the training stage, the product category participating in the training is a known (currently collected) class, and normal and abnormal samples are collected at the same time. A part of the normal samples can be used as a normal reference sample set, and features are extracted using a pre-trained feature extraction network to construct a normal feature reference set. For each feature of the input sample, the most similar feature is matched from the normal feature reference set as a reference feature, and the difference between the two is used as a residual feature. The residual feature is then sequentially input into the feature constraint part and the feature distribution estimation part to learn the normal residual feature distribution; in the test stage, the model can be used for known categories or directly applied to new product categories that have not been seen in the training. The samples to be tested are sequentially passed through the residual feature generation part, the feature constraint part and the feature distribution estimation part, and an abnormal score is generated for each area of the samples to be tested based on the learned normal residual distribution. The present invention utilizes the domain invariance of the residual feature, and the model obtained by training based on the residual feature has category independence. For newly emerging industrial product categories, the model does not need to be retrained and fine-tuned to be used in the category, and is suitable for product category diversification and continuous promotion of new industrial defect detection and other application scenarios.
[0200] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0201] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0202] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0203] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0204] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0205] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A cross-category universal industrial defect detection method, characterized in that: include: Providing a pre-trained feature extraction network, using the pre-trained feature extraction network to extract features of input samples, and obtaining initial features and corresponding reference features; An industrial defect detection model is provided. The model obtains residual features and performs feature perturbations based on the initial features of the training samples and their corresponding reference features, and obtains a trained industrial defect detection model through cross-domain invariance constraints and normal residual feature distribution training; The initial features of the sample to be detected and its corresponding reference features are used as inputs of the trained industrial defect detection model to obtain an abnormality score of the sample to be detected for industrial defect detection.
2. The cross-category universal industrial defect detection method according to claim 1, characterized in that: The step of extracting features of input samples using the pre-trained feature extraction network to obtain initial features and corresponding reference features includes: Based on the normal samples and abnormal samples of known product categories as training samples, the samples are input into the pre-trained feature extraction network to extract the features of the training samples, thereby obtaining the initial features of the training samples; Based on normal samples of known product categories, some samples are selected as reference samples of training samples, and are input into the pre-trained feature extraction network to extract features of the reference samples, thereby obtaining normal features as reference features of training samples; Based on the samples to be detected of known product categories or unknown product categories, the samples are input into the pre-trained feature extraction network to extract the features of the samples to be detected, so as to obtain the initial features of the samples to be detected; Based on the category to which the sample to be detected belongs, some normal samples are selected as reference samples of the sample to be detected, and are input into the pre-trained feature extraction network to extract features of the reference samples to obtain reference features of the sample to be detected.
3. The cross-category universal industrial defect detection method according to claim 1, characterized in that: The industrial defect detection model is provided. The model obtains residual features and performs feature perturbation based on the initial features of the training samples and the reference features. The trained industrial defect detection model is obtained through cross-domain invariance constraints and normal residual feature distribution training, including: An industrial defect detection model is provided, the industrial defect detection model comprising: a residual feature generation model, a feature constraint model and a feature distribution estimation model; The residual feature generation model takes the initial feature of the training sample as input and matches a closest reference feature to generate a residual feature; Adding a disturbance feature to the residual feature to obtain a disturbed residual feature; The feature constraint model takes the perturbed residual features as input and performs cross-domain invariance constraints to obtain constrained residual features; The feature distribution estimation model takes the constrained residual features as input and learns the normal residual feature distribution to obtain a trained industrial defect detection model.
4. The cross-category universal industrial defect detection method according to claim 3, characterized in that: Also includes any one or more of the following: -The residual feature generation model takes the initial features of the training sample as input and matches a closest reference feature to generate residual features, including: For each initial feature of the input normal sample and abnormal sample, a closest normal reference feature is matched, and the difference between the initial feature and the reference feature is calculated to generate the residual features of the normal sample and the abnormal sample; -The adding of disturbance features to the residual features to obtain the disturbed residual features includes: Determine a feature distribution variance according to the modulus value of the residual feature, and use the feature distribution variance to randomly generate a disturbance feature based on a Gaussian distribution; Adding the disturbance feature to the residual feature to simulate the change of the residual feature of the normal sample in the unknown product category; The feature constraint model takes the perturbed residual features as input and performs cross-domain invariance constraints to obtain constrained residual features, including: The feature constraint model is based on an abnormality-invariant single-classification loss function, which projects the residual features of normal samples into a spatial hypersphere, while keeping the residual features of abnormal samples unchanged, so as to enhance the cross-class domain invariance of the residual features of normal samples and the distinguishability between the residual features of normal samples and the residual features of abnormal samples; wherein: The anomaly-invariant single-class loss function L occ for: Among them, i represents the i-th normal sample, N represents the number of normal samples, and y i =1 means that the i-th residual feature is abnormal, y i = 0 means that the i-th residual feature is normal, represents the residual feature after the feature constraint model, Represents the residual features of the input; the first part of the abnormality-invariant single-classification loss function represents the single-classification loss function, which is used to constrain the residual features of normal samples to a spatial hypersphere, and the second part represents the abnormality feature invariant constraint term, which is used to allow the residual features of the projected abnormal samples to predict the residual features of the input, thereby keeping the residual features of the abnormal samples from being constrained to the hypersphere; The feature distribution estimation model takes the constrained residual features as input and learns the normal residual feature distribution to obtain a trained industrial defect detection model, including: The feature distribution estimation model takes the constrained residual features as input, guides based on explicit boundaries, and utilizes the residual features of abnormal samples to learn the residual feature distribution of normal samples, which is used to generate anomaly scores for input features based on the learned normal residual feature distribution during detection.
5. The cross-category universal industrial defect detection method according to claim 4, characterized in that: Also includes any one or more of the following: -The feature constraint model is constructed by a single convolutional layer; - The feature distribution estimation model adopts a probabilistic generation model, based on explicit boundary guidance, and uses the residual features of abnormal samples to assist in learning the residual feature distribution of normal samples; the trained feature distribution estimation model is used to perform log-likelihood estimation on each input feature, the log-likelihood value is converted into a likelihood value, and then each likelihood value is subtracted from 1 to generate an abnormality score; wherein: The method based on explicit boundary guidance and using the residual features of abnormal samples to assist in learning the residual feature distribution of normal samples includes: The input features are transformed into latent space using the feature distribution estimation model, and the latent variables are set to obey Gaussian distribution, and the log-likelihood value of the input features is obtained according to the variational principle; Taking the maximization of the log-likelihood value as the optimization goal, optimizing the feature distribution estimation model through the maximum likelihood loss function; Construct an explicit boundary-guided semi-push-pull loss function, which includes: Define a location hyperparameter β, which is used to control the distance from the normal boundary to the center; Sort all log-likelihood values in ascending order, and select the βth percentile of the sorted log-likelihood distribution as the normal boundary bn; Introduce a spacing hyperparameter τ and define the anomaly boundary ba as ba = bn-τ; The residual features of normal samples outside the normal boundary bn are pulled into the normal boundary bn, and the residual features of abnormal samples within the abnormal boundary ba are pushed out of the abnormal boundary ba; The residual feature distribution of normal samples is optimized by the semi-push-pull loss function guided by the explicit boundary, the likelihood value of the residual feature of normal samples is pulled into the distribution, and the likelihood value of the residual feature of abnormal samples is pushed out of the distribution; Based on the normal boundary guidance, the residual feature distribution of normal samples and abnormal samples is explicitly divided to complete the residual feature distribution learning of normal samples; -The feature distribution estimation model adopts a normalized flow model, which is composed of a coupling layer, and the coupling layer is constructed by a fully connected layer.
6. The cross-category universal industrial defect detection method according to claim 1, characterized in that: The initial features of the sample to be detected and the corresponding reference features thereof are used as inputs of the trained industrial defect detection model to obtain an abnormality score of the sample to be detected, including: Passing the initial features of the sample to be detected and its corresponding reference features through the trained industrial defect detection model to obtain an abnormality score of the sample to be detected; Based on the abnormality score, the image-level abnormality threshold and the pixel-level abnormality threshold are used to determine defective products and defective areas; when the abnormality score value is less than the set threshold, it is determined to be a normal product; if the abnormality score value is greater than or equal to the set threshold, it is determined to be a defective product and the corresponding defective area is obtained.
7. A cross-category universal industrial defect detection system, characterized in that: include: A feature extraction module, which is used to provide a pre-trained feature extraction network, and use the pre-trained feature extraction network to extract features of input samples to obtain initial features and corresponding reference features; An industrial defect detection training module, which is used to provide an industrial defect detection model. The model obtains residual features and performs feature perturbations based on the initial features of the training samples and their corresponding reference features, and obtains a trained industrial defect detection model through cross-domain invariance constraints and normal residual feature distribution training; The industrial defect detection module is used to use the initial features of the sample to be detected and its corresponding reference features as inputs of the trained industrial defect detection model to obtain the abnormality score of the sample to be detected and perform industrial defect detection.
8. The cross-category universal industrial defect detection system according to claim 7, characterized in that: The industrial defect detection model comprises: A residual feature generation module, which is used to convert the initial features into residual features; A feature constraint module, which is used to constrain normal residual features in the residual features to a spatial hypersphere and keep abnormal residual features in the residual features unchanged, thereby enhancing the cross-domain invariance of the normal residual features and the distinguishability between the normal residual features and the abnormal residual features; A feature distribution estimation module is used to learn the normal residual feature distribution and generate anomaly scores for input features based on the learned normal residual feature distribution.
9. A cross-category universal industrial defect detection terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, it can be used to perform the method described in any one of claims 1 to 6, or to run the system described in any one of claims 7 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it can be used to perform the method described in any one of claims 1 to 6, or to run the system described in any one of claims 7 to 8.
Citation Information
Patent Citations
Defect detection method and device based on multi-scale characteristic distillation and medium
CN113962928A
Cross-category industrial defect detection method and device and medium
CN116152174A
Abnormal image generation method, training sample generation method and defective product detection method
CN118015399A
Data anomaly detection method and apparatus
WO2023123941A1
