A self-supervised defect representation learning method in industrial scenarios
By employing a self-supervised learning method and utilizing a multi-level feature alignment network and an adaptive anomaly measurement mechanism, the problem of scarce defect samples is solved, improving the generalization ability and accuracy of industrial defect detection, and making it suitable for defect identification in complex industrial environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG UNIV OF TECH
- Filing Date
- 2025-10-27
- Publication Date
- 2026-07-17
Smart Images

Figure CN121350837B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of industrial defect detection technology, and in particular relates to a self-supervised defect representation learning method in industrial scenarios. Background Technology
[0002] In industrial production, automated defect detection is crucial for ensuring product quality. Currently, mainstream methods rely on supervised learning-based deep learning techniques, such as using convolutional neural networks for image classification, object detection, or semantic segmentation. These methods have achieved significant results in defect detection tasks, effectively identifying various types of defects. However, supervised learning methods heavily depend on large amounts of labeled data, especially defect samples encompassing diverse defect types. In real-world industrial scenarios, defect samples are typically scarce and difficult to collect, and labeling is costly. This scarcity of defect samples leads to supervised learning models easily overfitting to normal samples, resulting in insufficient generalization ability and difficulty in effectively detecting unknown or rare defect types. Furthermore, class imbalance causes model training to favor normal classes, further reducing defect detection accuracy. To overcome the bottleneck of scarce defect samples, a self-supervised defect representation learning method for industrial scenarios is urgently needed. Summary of the Invention
[0003] To address the aforementioned technical issues, this invention proposes a self-supervised defect representation learning method for industrial scenarios. By constructing a multi-level feature alignment network and an adaptive anomaly measurement mechanism, it achieves efficient defect detection based solely on normal samples, significantly improving the generalization ability and detection accuracy of industrial quality inspection systems.
[0004] To achieve the above objectives, this invention provides a self-supervised defect representation learning method for industrial scenarios, comprising:
[0005] Construct a normal sample dataset of industrial products and preprocess it to obtain preprocessed normal samples;
[0006] The preprocessed normal samples are input into a multi-scale feature pyramid dual-branch encoder network to extract and fuse global semantic features and local detail features to obtain fused features.
[0007] Using the fused features, self-supervised training is performed through a progressive temperature-regulated contrastive learning mechanism to learn the feature distribution of normal samples;
[0008] The fused features are decoded and reconstructed using a semantic consistency reconstruction network, and the reconstruction loss is calculated to optimize the feature representation.
[0009] The comprehensive anomaly score of the test sample is calculated based on the trained model. A dynamic threshold is established according to the statistical distribution of the comprehensive anomaly score. The defect is determined by comparing the comprehensive anomaly score of the test sample with the dynamic threshold.
[0010] Optionally, constructing and preprocessing a normal sample dataset of industrial products includes:
[0011] The normal sample dataset is standardized using a preset mean and standard deviation; the standardized image is then subjected to Gaussian kernel convolution to suppress noise.
[0012] Optionally, the multi-scale feature pyramid dual-branch encoder network includes a main branch encoder and an auxiliary branch encoder; extracting and fusing global semantic features and local detail features includes: extracting global semantic features through the main branch encoder and extracting local detail features through the auxiliary branch encoder; and weighting and fusing the global semantic features and local detail features through an attention mechanism to generate fused features.
[0013] Optional, training of the progressive temperature regulation contrastive learning mechanism includes:
[0014] Normal samples are augmented to generate positive sample pairs; contrast loss is calculated based on cosine similarity; during training, the temperature parameter in the contrast loss function is adaptively reduced according to the number of iterations.
[0015] Optionally, the decoding and reconstruction of the semantic consistency reconstruction network includes:
[0016] The fused features are decoded by a decoder network to reconstruct the image; the reconstruction loss is obtained by weighted summation of pixel-level reconstruction loss, perceptual loss based on a pre-trained network, and structural similarity loss.
[0017] Optionally, the calculation of the comprehensive anomaly score for the sample to be tested includes:
[0018] Calculate the Mahalanobis distance score between the feature distribution of the test sample and the feature distribution of the normal sample;
[0019] Calculate the reconstruction error score between the test sample and its reconstructed image;
[0020] Calculate the semantic consistency score between the test sample and its reconstructed image at the semantic feature level;
[0021] The Mahalanobis distance score, reconstruction error score, and semantic consistency score are fused using adaptive weights to obtain a comprehensive anomaly score.
[0022] Optionally, establishing a dynamic threshold based on the statistical distribution of the comprehensive anomaly score includes:
[0023] The dynamic threshold is calculated and determined based on the mean and standard deviation of the comprehensive abnormality score of normal samples; the dynamic threshold is updated online according to the test sample data using an exponential moving average method.
[0024] Optionally, the defect is determined by comparing the comprehensive anomaly score of the sample under test with the dynamic threshold, including:
[0025] If the comprehensive anomaly score is greater than the dynamic threshold, the sample to be tested is determined to be a defective product.
[0026] If the comprehensive anomaly score is less than or equal to the dynamic threshold, the sample to be tested is determined to be a normal product.
[0027] Technical Effects of this Invention: This invention discloses a self-supervised defect representation learning method for industrial scenarios. By introducing a multi-scale feature pyramid dual-branch encoder structure, it effectively achieves deep fusion of global semantics and local details, thereby significantly improving the defect representation learning ability based solely on normal samples. The adoption of a progressive temperature-regulated contrastive learning mechanism enhances the model's accurate modeling of normal sample feature distribution and its generalization adaptability to unknown defect types, improving detection robustness and accuracy. Furthermore, the combination of a three-dimensional anomaly scoring fusion architecture and a dynamic threshold adaptive update strategy effectively improves the recognition accuracy of minute anomalies in complex industrial environments. This invention is highly beneficial for the self-supervised detection and intelligent identification of defects in industrial products, providing strong technical support for solving the problem of scarce defect samples in industrial scenarios and improving the level of automated quality inspection. Attached Figure Description
[0028] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0029] Figure 1 This is a flowchart illustrating a self-supervised defect representation learning method in an industrial scenario according to an embodiment of the present invention, wherein 101 is a data preprocessing module, 102 is a multi-scale feature extraction network, 103 is a progressive contrastive learning module, 104 is a semantic reconstruction network, and 105 is an anomaly measurement and evaluation system.
[0030] Figure 2 This is a schematic diagram of the structure of the multi-scale feature pyramid dual-branch encoder network according to an embodiment of the present invention;
[0031] Figure 3 This is a schematic diagram of the training process of the progressive contrastive learning module in an embodiment of the present invention;
[0032] Figure 4This is a schematic diagram of the semantic consistency reconstruction network according to an embodiment of the present invention;
[0033] Figure 5 This is a schematic diagram of the composition of the anomaly detection system according to an embodiment of the present invention. Detailed Implementation
[0034] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0035] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0036] This embodiment provides a self-supervised defect representation learning method in an industrial scenario, including:
[0037] Construct a normal sample dataset of industrial products and preprocess it to obtain preprocessed normal samples;
[0038] The preprocessed normal samples are input into a multi-scale feature pyramid dual-branch encoder network to extract and fuse global semantic features and local detail features to obtain fused features.
[0039] Using the fused features, self-supervised training is performed through a progressive temperature-regulated contrastive learning mechanism to learn the feature distribution of normal samples;
[0040] The fused features are decoded and reconstructed using a semantic consistency reconstruction network, and the reconstruction loss is calculated to optimize the feature representation.
[0041] The comprehensive anomaly score of the test sample is calculated based on the trained model. A dynamic threshold is established according to the statistical distribution of the comprehensive anomaly score. The defect is determined by comparing the comprehensive anomaly score of the test sample with the dynamic threshold.
[0042] Furthermore, constructing and preprocessing a normal sample dataset of industrial products includes:
[0043] The normal sample dataset is standardized using a preset mean and standard deviation; the standardized image is then subjected to Gaussian kernel convolution to suppress noise.
[0044] Furthermore, the multi-scale feature pyramid dual-branch encoder network includes a main branch encoder and an auxiliary branch encoder; the extraction and fusion of global semantic features and local detail features includes: extracting global semantic features through the main branch encoder and extracting local detail features through the auxiliary branch encoder; and weighting and fusing the global semantic features and local detail features through an attention mechanism to generate fused features.
[0045] Furthermore, the training of the progressive temperature regulation contrastive learning mechanism includes:
[0046] Normal samples are augmented to generate positive sample pairs; contrast loss is calculated based on cosine similarity; during training, the temperature parameter in the contrast loss function is adaptively reduced according to the number of iterations.
[0047] Furthermore, the decoding and reconstruction of the semantic consistency reconstruction network includes:
[0048] The fused features are decoded by a decoder network to reconstruct the image; the reconstruction loss is obtained by weighted summation of pixel-level reconstruction loss, perceptual loss based on a pre-trained network, and structural similarity loss.
[0049] Furthermore, the calculation of the comprehensive anomaly score for the sample to be tested includes:
[0050] Calculate the Mahalanobis distance score between the feature distribution of the test sample and the feature distribution of the normal sample;
[0051] Calculate the reconstruction error score between the test sample and its reconstructed image;
[0052] Calculate the semantic consistency score between the test sample and its reconstructed image at the semantic feature level;
[0053] The Mahalanobis distance score, reconstruction error score, and semantic consistency score are fused using adaptive weights to obtain a comprehensive anomaly score.
[0054] Furthermore, establishing a dynamic threshold based on the statistical distribution of the comprehensive anomaly score includes:
[0055] The dynamic threshold is calculated and determined based on the mean and standard deviation of the comprehensive abnormality score of normal samples; the dynamic threshold is updated online according to the test sample data using an exponential moving average method.
[0056] Furthermore, the defect is determined by comparing the comprehensive anomaly score of the sample under test with the dynamic threshold.
[0057] If the comprehensive anomaly score is greater than the dynamic threshold, the sample to be tested is determined to be a defective product.
[0058] If the comprehensive anomaly score is less than or equal to the dynamic threshold, the sample to be tested is determined to be a normal product.
[0059] Specifically, the implementation process of this embodiment includes:
[0060] like Figure 1 As shown, this invention provides a self-supervised defect representation learning method for industrial scenarios, including: a data preprocessing module 101, a multi-scale feature extraction network 102, a progressive contrastive learning module 103, a semantic reconstruction network 104, and an anomaly measurement and evaluation system 105; the data preprocessing module is connected to the multi-scale feature extraction network and also to the progressive contrastive learning module. The system acquires normal product images through a self-supervised deep learning algorithm and performs defect representation learning.
[0061] A network is constructed using a multi-scale feature pyramid bi-branch encoder and a progressive temperature-regulated contrastive learning mechanism. The multi-scale feature extraction network processes the feature representations of normal samples to detect defects in target samples. The implementation steps are as follows:
[0062] Step 1: Construct a normal sample dataset of industrial products ,in Indicates the first A set of normal product images. The dataset undergoes standardization preprocessing:
[0063] (1);
[0064] in and These represent the mean and standard deviation of the dataset, respectively, for the RGB three channels. , Further noise suppression processing is performed:
[0065] (2);
[0066] in The standard deviation is expressed as Gaussian kernel, This represents a convolution operation, resulting in a preprocessed dataset. .
[0067] Step 2: Multi-scale feature pyramid dual-branch encoder network architecture as follows Figure 2 As shown. Includes global feature extraction in the main branch. and auxiliary branch local feature extraction :
[0068] (3);
[0069] (4);
[0070] in This represents four different feature level indices, with feature dimensions of respectively. , and These represent the network parameters of the main branch and the auxiliary branch, respectively. Feature fusion is achieved through an attention mechanism.
[0071] (5);
[0072] (6);
[0073] in This represents the sigmoid activation function. and For the learning parameters of the attention mechanism, Indicates feature splicing, This indicates element-wise multiplication.
[0074] Step 3: Gradual temperature control strategy, such as Figure 3 As shown, this solves the feature learning imbalance problem caused by a fixed temperature parameter in traditional contrastive learning. The batch size for comparison is set to... For any normal sample Generate positive sample pairs through data augmentation ,in and Different enhanced views of the same sample For different samples, the loss function for contrastive learning is defined as:
[0075] (7);
[0076] in Indicates through mapping network The resulting 512-dimensional feature representation, Cosine similarity:
[0077] (8);
[0078] in For the temperature parameter, an adaptive adjustment strategy is adopted:
[0079] (9);
[0080] in These are the initial temperature parameters. The attenuation coefficient is... This refers to the number of training iterations. This strategy allows the model to focus on significant differences in the early stages of training and on subtle differences in the later stages.
[0081] Step 4: Reconstruct the network based on semantic consistency. Figure 4 As shown. The decoding process of the reconstructed network is defined as follows:
[0082] (10);
[0083] in Indicates the decoder network, These are the decoder parameters. The reconstruction loss function combines multiple loss terms:
[0084] (11);
[0085] in , , This is the loss weighting coefficient. Reconstruction loss is defined as:
[0086] (12);
[0087] Perceptual loss utilizes intermediate layer features from a pre-trained VGG-16 network:
[0088] (13);
[0089] in This indicates the VGG-16 network's... Feature extraction function of layer The selected number of layers. The structural similarity loss is defined as:
[0090] (14);
[0091] (15);
[0092] in , The mean of the image. , For image variance, For covariance, , It is a constant.
[0093] Step 5: Three-dimensional anomaly scoring fusion mechanism as follows Figure 5 As shown, this significantly improves the accuracy and robustness of anomaly detection compared to a single scoring method, while establishing a dynamic threshold-adaptive anomaly scoring system. For the test sample... Calculate the three-dimensional anomaly score:
[0094] (1) Mahalanobis distance score: Let the distribution of features of normal samples be... Then the Mahalanobis distance is:
[0095] (16);
[0096] (2) Reconstruction error score:
[0097] (17);
[0098] in This represents the encoder network.
[0099] (3) Semantic consistency score:
[0100] (18);
[0101] The comprehensive anomaly score is fused using adaptive weighting:
[0102] (19);
[0103] The weights are learned by maximizing the difference in scores between normal and abnormal samples:
[0104] (20).
[0105] Step 6: Implement a dynamic threshold adaptive mechanism, such as... Figure 5 As shown. The threshold is determined by the statistical distribution of abnormal scores from normal samples:
[0106] (twenty one);
[0107] in and These are the mean and standard deviation of the abnormality scores for normal samples, respectively. To control the parameters, the optimal value is determined through cross-validation. Simultaneously, an adaptive threshold update mechanism is established.
[0108] (twenty two);
[0109] in To update the coefficients, The threshold is calculated based on the new data.
[0110] Online incremental learning updates feature distribution parameters using an exponential moving average:
[0111] (twenty three);
[0112] (twenty four);
[0113] in It acts as a memory factor, controlling the degree to which historical information is retained.
[0114] Step 7: Compare the anomaly score with the dynamic threshold. If... If it is determined to be a defective product; If the defect is not found, it is considered a normal product. This method effectively learns the intrinsic normal characteristics and fine-grained abnormal features of industrial products through a multi-scale feature pyramid dual-branch encoder and a progressive temperature-regulated contrastive learning mechanism, improving the generalization ability and self-supervised learning robustness of defect detection. Furthermore, by adjusting the feature fusion weights and abnormal scoring parameters of the network, it can support the detection of unknown defects (surface scratches, internal voids, deformation, etc.) in different types of industrial products (such as electronic components, metal parts, textiles, etc.).
[0115] This invention proposes a self-supervised defect representation learning method for industrial scenarios. Utilizing a large number of readily available normal samples, it learns the normal representation features of products through a self-supervised learning task, without the involvement of any defect samples. Specifically, this invention employs multi-view contrastive learning and reconstruction tasks, forcing the model to understand the features of normal products from different angles and dimensions, thereby learning robust and comprehensive normal representations. After completing self-supervised training, the degree of deviation between the features of the test sample and the normal representation can be used to determine whether it is a defect. This method effectively solves the problem of scarce defect samples, improves the model's generalization ability in industrial scenarios, and can detect unknown types of defects, providing an efficient and practical solution for quality inspection of industrial products.
[0116] The above are merely preferred embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A self-supervised defect representation learning method in an industrial setting, characterized in that, include: Construct a normal sample dataset of industrial products and preprocess it to obtain preprocessed normal samples; The preprocessed normal samples are input into a multi-scale feature pyramid dual-branch encoder network to extract and fuse global semantic features and local detail features to obtain fused features. Using the fused features, self-supervised training is performed through a progressive temperature-regulated contrastive learning mechanism to learn the feature distribution of normal samples; The fused features are decoded and reconstructed using a semantic consistency reconstruction network, and the reconstruction loss is calculated to optimize the feature representation. The comprehensive anomaly score of the test sample is calculated based on the trained model. A dynamic threshold is established according to the statistical distribution of the comprehensive anomaly score. The defect is determined by comparing the comprehensive anomaly score of the test sample with the dynamic threshold.
2. The self-supervised defect representation learning method in industrial scenarios as described in claim 1, characterized in that, Constructing and preprocessing a normal sample dataset of industrial products includes: The normal sample dataset is standardized using a preset mean and standard deviation; the standardized image is then subjected to Gaussian kernel convolution to suppress noise.
3. The self-supervised defect representation learning method in industrial scenarios as described in claim 1, characterized in that, The multi-scale feature pyramid dual-branch encoder network includes a main branch encoder and an auxiliary branch encoder; the extraction and fusion of global semantic features and local detail features includes: extracting global semantic features through the main branch encoder and extracting local detail features through the auxiliary branch encoder; and weighting and fusing the global semantic features and local detail features through an attention mechanism to generate fused features.
4. The self-supervised defect representation learning method in industrial scenarios as described in claim 1, characterized in that, The training of the progressive temperature regulation contrastive learning mechanism includes: Normal samples are augmented to generate positive sample pairs; contrast loss is calculated based on cosine similarity; during training, the temperature parameter in the contrast loss function is adaptively reduced according to the number of iterations.
5. The self-supervised defect representation learning method in industrial scenarios as described in claim 1, characterized in that, The decoding and reconstruction of the semantic consistency reconstruction network includes: The fused features are decoded by a decoder network to reconstruct the image; the reconstruction loss is obtained by weighted summation of pixel-level reconstruction loss, perceptual loss based on a pre-trained network, and structural similarity loss.
6. The self-supervised defect representation learning method in industrial scenarios as described in claim 1, characterized in that, The calculation of the comprehensive anomaly score for the sample to be tested includes: Calculate the Mahalanobis distance score between the feature distribution of the test sample and the feature distribution of the normal sample; Calculate the reconstruction error score between the test sample and its reconstructed image; Calculate the semantic consistency score between the test sample and its reconstructed image at the semantic feature level; The Mahalanobis distance score, reconstruction error score, and semantic consistency score are fused using adaptive weights to obtain a comprehensive anomaly score.
7. The self-supervised defect representation learning method in industrial scenarios as described in claim 1, characterized in that, The dynamic threshold is established based on the statistical distribution of the comprehensive anomaly score, including: The dynamic threshold is calculated and determined based on the mean and standard deviation of the comprehensive abnormality score of normal samples; the dynamic threshold is updated online according to the test sample data using an exponential moving average method.
8. The self-supervised defect representation learning method in industrial scenarios as described in claim 1, characterized in that, The defects identified by comparing the comprehensive anomaly score of the sample under test with the dynamic threshold include: If the comprehensive anomaly score is greater than the dynamic threshold, the sample to be tested is determined to be a defective product. If the comprehensive anomaly score is less than or equal to the dynamic threshold, the sample to be tested is determined to be a normal product.