Defect detection method and system based on self-supervised learning
By combining the self-supervised learning methods of SimSiam and CBAM, and using the ResNet-101 encoder and attention module, the problems of data scarcity and high annotation cost in defect detection are solved, and efficient defect detection is achieved.
Patent Information
- Application Number
- CN202411557341.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-11-04
AI Technical Summary
In defect detection tasks, the scarcity of data and labels limits the effectiveness of traditional supervised learning methods, and self-supervised networks struggle to accurately distinguish between useful and redundant information, affecting detection accuracy and robustness.
A self-supervised learning method combining SimSiam and CBAM is adopted, using ResNet-101 as the encoder and inserting spatial attention module SAM and channel attention module CAM to enhance feature representation ability, suppress redundant information interference, and improve the model's generalization ability.
It reduces reliance on data annotation, improves the accuracy and robustness of defect detection, reduces data acquisition and annotation costs, and enhances the model's generalization ability.
Smart Images

Figure CN120894664A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision, and in particular to a defect detection method and system based on self-supervised learning. BACKGROUND
[0002] With the development of deep learning, most visual tasks (such as image classification, object detection and semantic segmentation) have taken good results under sufficient data, but for specific tasks with insufficient data and labels, the effect of supervised learning model will be greatly limited.
[0003] Taking defect detection as an example, in a supervised detection model based on deep learning, we usually need to label the collected data as a training set and input it into the backbone network for feature extraction to learn the class and position information of the target object in the data, and then send the extracted feature map to the downstream to complete the detection task. The amount of information contained in the feature map often directly affects the detection rate and accuracy of the detection, and the network structure and data determine the amount of information in the feature map.
[0004] In the defect detection task, more and more methods have been proposed, and in these methods, the feature extraction capability is usually improved by optimizing the backbone network, such as increasing the network depth, adding attention mechanism, etc. Through comparative experiments on public data sets, good results have been achieved.
[0005] But in practical application, data is often the key factor that determines the detection effect, especially in specific fields or customized tasks, high-quality and accurately labeled data is often scarce and difficult to obtain and has high cost. In this case, even if the backbone network is designed to be advanced, if there is not enough rich and representative training data, the generalization ability and detection performance of the model will be greatly reduced. Therefore, some self-supervised methods have been proposed.
[0006] Contrastive self-supervised learning, as a branch of self-supervised learning, has shown significant advantages in the field of computer vision in recent years. Its core idea is to construct positive sample pairs (usually different versions of the same image after different transformations) and negative sample pairs (samples from different images or different categories), and design algorithms to enable the model to learn the feature representation that distinguishes these positive and negative sample pairs. In this process, even if there is no explicit label, the model can identify the invariant or important features in the data.
[0007] SimSiam (Simple Siamese) is a representative method in contrastive self-supervised learning. Unlike contrastive learning methods that rely on negative sample pairs, SimSiam directly maximizes the similarity of two enhanced views of the same image without using negative sample pairs. Its network structure is as follows Figure 1As shown. First, data augmentation operations are performed on the input image, such as random cropping of the image, random graying, random noise, and random flipping, etc., and then the enhanced image is input into the twin network, and the encoder is used for feature extraction operation, the encoders of the two branches share parameters, and the feature vector is obtained; The projection layer cascaded with the encoder is composed of a fully connected layer, which maps the output of the encoder to a low-dimensional space to further extract useful feature information. A prediction layer is added in one branch of the twin network, which is also composed of a fully connected layer, and the prediction vector will be used to match the feature vector of the other view. During the back propagation process of the network, the gradient stopping strategy is used for one branch to prevent model collapse, and only the branch with the prediction layer is updated. Finally, the cosine similarity of the output of the two branches is calculated, and the negative value is taken as the loss, and the larger the value is, the closer the two vectors are.
[0008] Although SimSiam has shown strong feature learning ability and data efficiency in multiple visual tasks, for the specific defect detection task, high-dimensional features often contain rich detail information and spatial structure, which are crucial for accurate defect recognition. SimSiam may inevitably cause the loss of part of the feature information in the process of encoding and mapping the features.
[0009] In summary, there are two problems in the current defect detection task: (1) In the specific defect detection task with insufficient data and labels, traditional supervised learning methods often have difficulty in learning effective feature representation from limited data, resulting in limited model detection effect. (2) Unsupervised networks often have difficulty in accurately distinguishing useful information and redundant information when extracting features, which not only leads to the loss of part of the useful defect information, but also may cause some noise information to be incorrectly introduced, thereby interfering with the subsequent defect detection task and affecting the accuracy and robustness of the model. SUMMARY
[0010] The technical task of the present application is to provide a defect detection method and system based on self-supervised learning, which not only reduces the dependence on data labeling, but also improves the accuracy and robustness of defect detection, providing a new idea and method for solving the problem of data scarcity and high labeling cost in specific defect detection tasks.
[0011] The technical solution adopted by the present application to solve its technical problems is:
[0012] A defect detection method based on self-supervised learning, which is realized based on SimSiam and CBAM, adopts ResNet-101 as an encoder to extract features of an image, inserts a spatial attention module SAM after the encoder layer, inputs the extracted feature map into the SAM to generate a spatial attention weight map to enhance the expression ability of position information, and inserts a channel attention module CAM in the projection layer to enhance the weight of useful channel information while performing feature mapping and suppress the interference of redundant channel information.
[0013] The method applies the contrast-based self-supervised learning method SimSiam to a specific task scene with insufficient data and labels, reduces the dependence of the defect detection model on data, and reduces the cost and difficulty of data acquisition and labeling; the SAM and CAM in CBAM are introduced into the encoder and projection layer of SimSiam respectively, the spatial structure and local information of high-dimensional features are preserved, and the accuracy of defect detection is further improved; and the expression ability of features is enhanced through the introduction of the attention mechanism, and the generalization ability of the self-supervised defect detection model is improved.
[0014] Further, the implementation of the method includes:
[0015] 1) Data preparation:
[0016] Collect image data from multiple sources, including real-time monitoring on the production line, historical archived image data, and images generated through simulation experiments;
[0017] After collecting the data, random cropping, random graying, random noise, and random flipping operations are performed on the data, respectively, to further increase data diversity; then, data cleaning operations are performed on the enhanced data set to remove background information irrelevant to defects, so as to reduce the computational burden of the model; finally, the data is normalized to make the pixel value distributed within a certain range, which helps the model to better learn the features;
[0018] 2) Network design based on SimSiam and CBAM:
[0019] In the encoder layer, ResNet-101 is selected as the encoder, which not only can extract rich and multi-level defect information in the image, but also solves the gradient vanishing problem in deep network training through its special residual connection method; the spatial attention module SAM is added after the encoder layer, which can make the network focus more on the key information area in the image through spatial dimension weighting processing of the feature map, and ignore the unimportant background or noise information;
[0020] In the high-dimensional feature map, the location information and the feature information of the defect are contained simultaneously. The SAM can enhance the expression ability of the location information, and the CAM can model the importance of each feature channel, so that the channel attention module CAM is added to the projection layer to adjust the weight of each channel, thereby enhancing the key feature information of the defect and suppressing the redundant or noise information. This mechanism helps the network to filter out the most discriminative information from numerous features, further improving the detection rate and accuracy of defect detection.
[0021] 3) Train and deploy the detection model.
[0022] Further, the collected image data should cover all possible defect types as much as possible to ensure that the model can learn comprehensive defect features.
[0023] Further, while dividing part of the labeled data into training set and validation set, a part of unlabeled data is also needed for pre-training of the model.
[0024] Further, the network is designed based on SimSiam and CBAM:
[0025] SAM extracts the spatial information of the feature map by performing average pooling and maximum pooling operations along the channel dimension, then concatenates the two feature maps and processes them through a convolutional layer to generate an attention weight map with the same size as the feature map. The weight map dynamically adjusts the weight of each position by calculating the importance score of each position in the feature map, thereby enhancing the location information of the defect, which is crucial for the positioning of the defect in the defect detection task.
[0026] Further, the network is designed based on SimSiam and CBAM:
[0027] During the improvement of the two branches, the parameters are shared, the gradient is stopped, and the structure is not changed; the stability and efficiency of the original self-supervised learning framework of SimSiam are maintained.
[0028] Parameter sharing ensures that the network can fully utilize the complementary information between the two branches during learning, promoting consistent learning of features; the gradient stopping mechanism effectively avoids the degradation problem that may occur during model training, ensuring the stability and convergence of feature learning.
[0029] Further, the detection model is trained and deployed,
[0030] When training the model, the RMSprop optimizer is selected as the optimization strategy because it has good adaptability to non-stationary targets and can effectively update the model parameters during training, thereby improving the convergence speed and stability of the model.
[0031] The cosine annealing strategy is adopted to dynamically adjust the learning rate, which can provide a larger learning rate in the early stage of training to accelerate the convergence of the model, and gradually reduce the learning rate in the later stage of training to avoid the model from falling into the dilemma of overfitting.
[0032] In terms of hyperparameter adjustment, through a large number of experiments and verifications, key hyperparameters including: encoder version, data enhancement strategy, structure of projection layer and prediction layer, parameters of CBAM module, initial value of learning rate and batch size are adjusted and optimized.
[0033] The application also claims to protect a defect detection system based on self-supervised learning, comprising:
[0034] A data collection and processing module is used to collect image data from multiple sources, and after collecting the data, the data is processed to increase data diversity, remove background information irrelevant to defects, and normalize the data;
[0035] A network design module based on SimSiam and CBAM is used to select ResNet-101 as the encoder in the encoder layer, add a spatial attention module SAM after the encoder layer, and add a channel attention module CAM in the projection layer;
[0036] A model deployment module is used to train and deploy the detection model;
[0037] The system realizes defect detection based on self-supervised learning through the above method.
[0038] The application also claims to protect a defect detection device based on self-supervised learning, comprising: at least one memory, at least one CPU and at least one GPU;
[0039] The at least one memory is used to store machine-readable programs;
[0040] The at least one CPU and the at least one GPU are used to call the machine-readable programs to realize the above method.
[0041] The application also claims to protect a computer readable medium, which stores computer instructions, and the computer instructions make the processor execute the above method when executed by the processor.
[0042] Compared with the prior art, the defect detection method and system based on self-supervised learning have the following beneficial effects:
[0043] The present application is directed to a specific task of data and label deficiency, based on SimSiam and CBAM, a defect detection method based on self-supervised learning is proposed, by introducing CBAM attention mechanism, the ability of SimSiam in processing high-dimensional features is effectively enhanced, the spatial structure and local information of the features are retained, so that the model can better learn useful features and suppress the interference of redundant features. At the same time, the present method reduces the dependence on data labeling, greatly reduces the cost and difficulty of data labeling, so that the model can still maintain good detection performance when facing data and label deficiency or unknown scenes, and enhances the generalization ability of the model. In addition, through reasonable network design and parameter optimization, the present method not only ensures high performance, but also optimizes the utilization of computing resources, improves the efficiency and energy saving in practical application.
[0044] In summary, the present method not only provides a new solution for defect detection, but also promotes the application and development of self-supervised learning in the field of computer vision, and has broad application prospect and important practical value. BRIEF DESCRIPTION OF DRAWINGS
[0045] Figure 1 is the SimSiam network structure diagram provided by the embodiment of the present application;
[0046] Figure 2 is the CBAM network structure diagram provided by the embodiment of the present application;
[0047] Figure 3 is the encoder and projection layer diagram after adding CBAM provided by the embodiment of the present application. DETAILED DESCRIPTION
[0048] The present application will be further described below in combination with specific embodiments.
[0049] The embodiment of the present application provides a defect detection method based on self-supervised learning, which is realized based on SimSiam and CBAM, adopts ResNet-101 as an encoder to extract features of an image, inserts a spatial attention module SAM after the encoder layer, inputs the extracted feature map into the SAM to generate a spatial attention weight map and enhance the expression ability of position information, and inserts a channel attention module CAM in the projection layer to enhance the weight of useful channel information while performing feature mapping and suppress the interference of redundant channel information.
[0050] The method based on contrastive self-supervised learning SimSiam is applied to the specific task scene with insufficient data and labels, which reduces the dependence of the defect detection model on data and reduces the cost and difficulty of data acquisition and labeling; the SAM and CAM in CBAM are introduced into the encoder and projection layer of SimSiam respectively, and the spatial structure and local information of high-dimensional features are retained to further improve the accuracy of defect detection; the expression ability of features is enhanced through the introduction of attention mechanism, and the generalization ability of the self-supervised defect detection model is improved.
[0051] The implementation process of the method is as follows:
[0052] 1. Data preparation.
[0053] In the defect detection method based on self-supervised learning, data preparation is a crucial step. Since it is aimed at specific defect detection tasks with insufficient data and labels, special attention needs to be paid to data collection and preprocessing.
[0054] In order to ensure the diversity of data, image data is collected from multiple sources, including but not limited to real-time monitoring on the production line, historical archived image materials, and images generated through simulation experiments, and all possible defect types are covered as much as possible to ensure that the model can learn comprehensive defect features. At the same time, ensure the image quality is clear and the resolution is moderate, so that the model can accurately capture the defect details.
[0055] After collecting the data, random cropping, random graying, random noise and random flipping operations are performed on the data respectively to further increase the data diversity, and then the data cleaning operation is performed on the enhanced data set to remove background information irrelevant to defects, in order to reduce the computational burden of the model. Finally, the data is normalized to make the pixel value within a certain range, which helps the model to better learn the features.
[0056] Since the method uses self-supervised learning, while dividing part of the labeled data into training set and validation set, it also needs to prepare a part of unlabeled data for model pre-training.
[0057] 2. Network design based on SimSiam and CBAM.
[0058] As shown in Figure 3 , the network structure of the method is improved based on SimSiam. In the encoder layer, ResNet-101 is selected as the encoder, which not only extracts rich and multi-level defect information from the image, but also solves the gradient vanishing problem in deep network training through its special residual connection method.
[0059] Unlike the SimSiam network, which directly inputs the extracted feature map into the projection layer, the method adds a spatial attention module SAM after the encoder layer. By weighting the feature map in the spatial dimension, the network can focus more on the key information area in the image and ignore unimportant background or noise information. Specifically, SAM extracts the spatial information of the feature map by average pooling and max pooling operations along the channel dimension, then concatenates the two feature maps and processes them through a convolution layer to generate an attention weight map with the same size as the feature map. The weight map dynamically adjusts the weight of each position by calculating the importance score of each position in the feature map, thereby enhancing the defect position information, which is crucial for defect location in the defect detection task.
[0060] In high-dimensional feature maps, both defect position information and feature information are included. SAM can enhance the expression ability of position information, while CAM can model the importance of each feature channel. Therefore, the method adds CAM to the projection layer to adjust the weight of each channel, thereby enhancing the key feature information of defects and suppressing redundant or noise information. This mechanism helps the network to filter out the most discriminative information from numerous features, further improving the detection rate and accuracy of defect detection.
[0061] During the improvement of the two branches, the parameters are shared, the gradient is stopped, and the structure is not changed, maintaining the stability and efficiency of the original SimSiam self-supervised learning framework. Parameter sharing ensures that the network can fully utilize the complementary information between the two branches during learning, promoting consistent learning of features, while the gradient stopping mechanism effectively avoids the degradation problem that may occur during model training, ensuring the stability and convergence of feature learning.
[0062] 3. Train and deploy the detection model.
[0063] During model training, the RMSprop optimizer is chosen as the optimization strategy because it has good adaptability to non-stationary objectives and can effectively update model parameters during training, thereby improving the convergence speed and stability of the model.
[0064] In addition, the cosine annealing strategy is used to dynamically adjust the learning rate, which can provide a larger learning rate in the early stages of training to speed up model convergence, and gradually reduce the learning rate in the later stages of training to avoid the model falling into the overfitting dilemma.
[0065] In terms of hyperparameter adjustment, through extensive experiments and verification, key hyperparameters such as the encoder version, data augmentation strategy, structure of the projection and prediction layers, CBAM module parameters, initial learning rate, and batch size are adjusted and optimized.
[0066] For the two problems existing in the current defect detection task proposed in the background art, for problem (1), the method introduces a contrastive self-supervised learning network SimSiam, which is a kind of twin network specially designed for unsupervised visual representation learning. SimSiam does not need to rely on negative sample pairs, and directly maximizes the similarity between the two enhanced views of the same image, thereby effectively reducing the dependence on a large amount of labeled data. At the same time, it discards the momentum encoder and instead uses the stop gradient operation as a key means to prevent the network output from collapsing, which challenges the necessity of the momentum encoder in traditional contrastive learning. In the defect detection task, this self-supervised learning method without complex components and additional labeling enables SimSiam to learn more robust and effective feature representations under limited data conditions, providing a solid foundation for subsequent defect recognition and positioning. In addition, in order to further improve the performance of SimSiam in the defect detection task, the method makes targeted modifications to the encoder in SimSiam. Specifically: replace the original encoder with ResNet-101, by introducing residual connections and bottleneck structure, ensure that it has strong feature extraction ability, effectively solve the problem of gradient disappearance and gradient explosion that may occur in the training process of deep neural networks, help the model to more accurately identify defect categories and locate defect positions in the subsequent defect detection task, thereby improving the accuracy and robustness of detection.
[0067] For problem (2), the method introduces CBAM, adds SAM after the encoder layer, and adds CAM to the projection layer. SAM processes the feature map in the spatial dimension to make the network focus more on the key information area in the image and ignore unimportant background or noise information. Specifically, SAM extracts the spatial information of the feature map by average pooling and max pooling operations along the channel dimension, then concatenates the two feature maps and processes them through a convolution layer to generate an attention weight map with the same size as the feature map. The weight map dynamically adjusts the weight of each position by calculating the importance score of each position in the feature map, thereby enhancing the defect position information, which is crucial for defect location in the defect detection task. CAM focuses on the channel dimension of the image and dynamically adjusts the feature representation of each channel by calculating the weight of each channel, thereby enhancing the expression ability of defect features. This weighting processing in the channel helps the model focus on the feature channels that are crucial for the defect detection task, while suppressing the channels that contribute less to the detection task. Therefore, CAM not only helps to improve the detection accuracy of the model, but also enhances the robustness of the model, so that it can maintain stable detection performance when facing complex and variable defect shapes and background environments.
[0068] Attention mechanism enables the model to dynamically focus on the most important part when processing input data, thereby effectively preserving and utilizing key information. CBAM (Convolutional Block Attention Module) is a convolutional attention module that combines spatial attention module (SAM) and channel attention module (CAM), which can adaptively learn the importance of different channels and different positions in the feature map, thereby enhancing the expression of key information. The network structure of CBAM is as follows: Figure 2As shown, in CAM, each channel of the feature map is used to be regarded as a feature detector, so the channel feature focuses on whether the image information is useful, in order to more efficiently calculate the channel attention feature, then the average pooling and the maximum pooling are respectively adopted to compress the spatial dimension of the feature map to obtain two different spatial context information, then the obtained two feature maps are input into a multi-layer perception (MLP) network to obtain a final channel attention feature map, in SAM, the spatial attention feature map is generated by the relationship in the space of the feature map. Unlike CAM, spatial attention focuses on the location of effective information on the feature map. In order to calculate the spatial attention, first, the average pooling and the maximum pooling operation are performed in the channel dimension. Then the generated feature maps are spliced. Finally, on the spliced feature map, a convolution operation is used to generate the final spatial attention feature map, based on the existing pain points of SimSiam and the characteristics of CBAM, the SAM and CAM in CBAM are introduced into the encoder and the projection layer of SimSiam respectively, by preserving the spatial structure and local information of high-dimensional features, the accuracy of defect detection is further improved.
[0069] In summary, in view of the two problems existing in the field of defect detection at present, the defect detection method based on self-supervised learning is proposed, by introducing the attention mechanism and combining the ResNet-101 encoder and the SimSiam framework, an efficient and accurate defect detection system is successfully constructed. The system not only reduces the dependence on data labeling, but also improves the accuracy and robustness of defect detection, providing a new idea and method for solving the problem of data scarcity and high labeling cost in specific defect detection tasks.
[0070] The embodiment of the application also provides a defect detection system based on self-supervised learning, which realizes defect detection based on self-supervised learning through the defect detection method based on self-supervised learning described in the above embodiment.
[0071] The system comprises:
[0072] 1. A data collection and processing module for collecting image data from multiple sources, and processing the data after collecting the data, increasing data diversity, removing background information irrelevant to defects, and normalizing the data.
[0073] The image data is collected from multiple sources, including real-time monitoring on the production line, historical archived image data, and images generated through simulation experiments;
[0074] After collecting the data, random cropping, random graying, random noise and random flipping operations are performed on the data respectively to further increase data diversity; then data cleaning operations are performed on the enhanced data set to remove background information unrelated to defects, in order to reduce the computational burden of the model; finally, the data is normalized to make the pixel value within a certain range, which helps the model to better learn the features;
[0075] While dividing part of the labeled data into training set and validation set, a part of unlabeled data is also needed to prepare for the pre-training of the model.
[0076] 2. Network design module based on SimSiam and CBAM, in the encoder layer, ResNet-101 is selected as the encoder, spatial attention module SAM is added after the encoder layer, and channel attention module CAM is added in the projection layer.
[0077] In the encoder layer, ResNet-101 is selected as the encoder, which can not only extract rich and multi-level defect information from the image, but also solve the gradient vanishing problem in deep network training through its special residual connection method; spatial attention module SAM is added after the encoder layer, which can make the network focus more on the key information area in the image and ignore the unimportant background or noise information through spatial dimension weighting processing of the feature map;
[0078] In the high-dimensional feature map, both the position information and the feature information of the defect are contained, SAM can enhance the expression ability of the position information, and CAM can model the importance of each feature channel, therefore, channel attention module CAM is added in the projection layer to adjust the weight of each channel, so as to enhance the key feature information of the defect and suppress the redundant or noise information; this mechanism helps the network to filter out the most discriminative information from the numerous features, further improving the detection rate and accuracy of defect detection.
[0079] In the process of improving the two branches at the same time, the structure of parameter sharing and gradient stopping is not changed, which maintains the stability and efficiency of the original self-supervised learning framework of SimSiam. Parameter sharing ensures that the network can fully utilize the complementary information between the two branches in the learning process, promoting the consistency learning of features, while the gradient stopping mechanism effectively avoids the degradation problem that may occur in the training process of the model, ensuring the stability and convergence of feature learning.
[0080] 3. Model deployment module, used for training and deploying the detection model.
[0081] When training the model, the RMSprop optimizer is selected as the optimization strategy because it has good adaptability to non-stationary objectives and can effectively update the model parameters during training, thereby improving the convergence speed and stability of the model.
[0082] In addition, the cosine annealing strategy is adopted to dynamically adjust the learning rate, which can provide a larger learning rate in the early stage of training to accelerate the convergence of the model, and gradually reduce the learning rate in the later stage of training to avoid the model from falling into the dilemma of overfitting.
[0083] In terms of hyperparameter adjustment, through a large number of experiments and verifications, the key hyperparameters such as the version of the encoder, the data augmentation strategy, the structure of the projection layer and the prediction layer, the parameters of the CBAM module, the initial value of the learning rate, and the batch size are adjusted and optimized.
[0084] The traditional supervised learning method is limited in the absence of high-quality labeled data, and the self-supervised learning model is difficult to learn useful information and is susceptible to noise interference because it learns features from unlabeled data. To solve the above problems, the system combines the contrastive self-supervised learning model SimSiam (Simple Siamese) and CBAM (Convolutional Block Attention Module), uses ResNet-101 as the encoder, and inserts the spatial attention module (SAM) after it and the channel attention module (CAM) in the projection layer, which enhances the ability of SimSiam in processing high-dimensional features, so that the network can pay more attention to the location information and feature information of the defects, and improves the precision of defect detection; At the same time, the self-supervised network structure also solves the problem of difficult data acquisition and high labeling cost in specific scenarios, and improves the generalization ability of the defect detection model.
[0085] The embodiment of the application also provides a defect detection device based on self-supervised learning, comprising: at least one memory, at least one CPU and at least one GPU;
[0086] The at least one memory is used to store a machine-readable program;
[0087] The at least one CPU and the at least one GPU are used to call the machine-readable program to realize the defect detection method based on self-supervised learning described in the above embodiment.
[0088] The embodiments of the present application also provide a computer readable medium, which stores computer instructions. The computer instructions, when executed by a processor, cause the processor to perform the defect detection method based on self-supervised learning described in the above embodiments. Specifically, a system or device equipped with a storage medium can be provided. The storage medium stores software program codes for implementing the functions of any of the above embodiments. The computer (or CPU or MPU) of the system or device reads and executes the program codes stored in the storage medium.
[0089] In this case, the program codes read from the storage medium can themselves implement the functions of any of the above embodiments. Therefore, the program codes and the storage medium storing the program codes constitute a part of the present application.
[0090] The embodiments of the storage medium for storing the program codes include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, nonvolatile memory cards, and ROMs. Alternatively, the program codes can be downloaded from a server computer via a communication network.
[0091] In addition, it should be clear that not only the program codes read by the computer, but also the operating system or the like operating on the computer can perform part or all of the actual operations based on the instructions of the program codes, thereby implementing the functions of any of the above embodiments.
[0092] In addition, it should be understood that the program codes read from the storage medium can be written into the memory provided in the expansion board inserted into the computer or the memory provided in the expansion unit connected to the computer. Subsequently, the CPU or the like installed on the expansion board or the expansion unit can perform part or all of the actual operations based on the instructions of the program codes, thereby implementing the functions of any of the above embodiments.
[0093] The present application has been described in detail by the above drawings and preferred embodiments, however, the present application is not limited to these disclosed embodiments. As can be known by those skilled in the art from the above embodiments, more embodiments of the present application can be obtained by combining the code auditing means in the above different embodiments, and these embodiments are also within the scope of protection of the present application.
Claims
1. A defect detection method based on self-supervised learning, characterized in that, This method is based on SimSiam and CBAM. It uses ResNet-101 as the encoder to extract features from the image. After the encoder layer, a spatial attention module (SAM) is inserted to input the extracted feature map into the SAM to generate a spatial attention weight map, which enhances the expressive power of positional information. A channel attention module (CAM) is inserted into the projection layer to enhance the weight of useful channel information and suppress the interference of redundant channel information while performing feature mapping.
2. The defect detection method based on self-supervised learning according to claim 1, characterized in that, The implementation of this method includes: 1) Data preparation: Image data was collected from multiple sources, including real-time monitoring of the production line, historical archived image data, and images generated through simulation experiments; After collecting the data, random cropping, random grayscale conversion, random noise reduction, and random flipping operations were performed on the data to increase data diversity. Then, data cleaning was performed on the enhanced dataset to remove background information unrelated to defects. Finally, the data was normalized to distribute pixel values within a specific range. 2) Network design based on SimSiam and CBAM: In the encoder layer, ResNet-101 is selected as the encoder; after the encoder layer, a spatial attention module (SAM) is added. By weighting the feature map in terms of spatial dimensions, the network can focus more on the key information regions in the image and ignore unimportant background or noise information. By adding a Channel Attention Module (CAM) to the projection layer and adjusting the weights of each channel, the key feature information of defects can be enhanced and redundant or noise information can be suppressed. 3) Train and deploy the detection model.
3. The defect detection method based on self-supervised learning according to claim 2, characterized in that, The collected image data should cover as many possible defect types as possible to ensure that the model can learn comprehensive defect features.
4. A defect detection method based on self-supervised learning according to claim 2 or 3, characterized in that, While dividing the labeled data into training and validation sets, it is also necessary to prepare a portion of unlabeled data for model pre-training.
5. The defect detection method based on self-supervised learning according to claim 2, characterized in that, The network design based on SimSiam and CBAM is described below: SAM extracts spatial information from feature maps by performing average pooling and max pooling operations along the channel dimension. Then, it concatenates these two feature maps and processes them through a convolutional layer to generate an attention weight map of the same size as the feature map. This weight map dynamically adjusts the weight of each position by calculating the importance score of each position in the feature map, thereby enhancing the information on the location of defects.
6. A defect detection method based on self-supervised learning according to claim 2 or 5, characterized in that, The network design based on SimSiam and CBAM is described below: While improving both branches simultaneously, the parameter sharing and gradient stopping structure remained unchanged, maintaining the stability and efficiency of SimSiam's original self-supervised learning framework.
7. The defect detection method based on self-supervised learning according to claim 2, characterized in that, The training and deployment detection model, When training the model, the RMSprop optimizer was selected as the optimization strategy. A cosine annealing strategy is used to dynamically adjust the learning rate; Regarding hyperparameter tuning, key hyperparameters, including encoder version, data augmentation strategy, structure of projection and prediction layers, parameters of CBAM module, initial learning rate, and batch size, were adjusted and optimized through experiments and verification.
8. A defect detection system based on self-supervised learning, characterized in that, include: The data collection and processing module is used to collect image data from multiple sources, and after collecting the data, it processes the data to increase data diversity, remove background information unrelated to defects, and normalize the data. The network design module is based on SimSiam and CBAM. In the encoder layer, ResNet-101 is selected as the encoder. A spatial attention module (SAM) is added after the encoder layer, and a channel attention module (CAM) is added in the projection layer. The model deployment module is used to train and deploy the detection model; The system achieves defect detection based on self-supervised learning through the method described in any one of claims 1 to 7.
9. A defect detection device based on self-supervised learning, characterized in that, include: At least one memory, at least one CPU, and at least one GPU; The at least one memory is used to store a machine-readable program; The at least one CPU and at least one GPU are used to invoke the machine-readable program to implement the method of any one of claims 1 to 7.
10. A computer-readable medium, characterized in that, The computer-readable medium stores computer instructions that, when executed by a processor, cause the processor to perform the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Steel picture defect detection method in industrial production based on self-supervised contrast characterization learning technology
CN114240886A
Small sample target detection method for mutual distillation self-supervision potential knowledge mining
CN117292219A
Small intestine tumor CT image automatic segmentation method based on self-supervised learning
CN118521786A
Combined self-supervision target identification method suitable for underwater
CN118865082A