An industrial defect detection method and system

By employing a normal feature reconstruction model and a masked reverse knowledge distillation method in industrial defect detection, combined with image-level and feature-level masking strategies, and utilizing the cosine similarity function, the overgeneralization problem in unsupervised detection is solved, thereby improving detection accuracy and anomaly localization precision.

CN116580014BActive Publication Date: 2025-11-21HUAZHONG UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310570502.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-19
Publication Date
2025-11-21
Estimated Expiration
2043-05-19

AI Technical Summary

Technical Problem

Existing unsupervised anomaly detection methods suffer from overgeneralization in industrial defect detection, resulting in low detection accuracy.

Method used

A normal feature reconstruction model is adopted. By comparing the differences between the feature extraction of the image to be detected and the normal feature map, and combining image-level and feature-level masking strategies, the teacher network and the student network are trained. The cosine similarity function is used to measure the feature differences and improve the detection accuracy.

Benefits of technology

It effectively solves the overgeneralization problem, improves the accuracy of industrial defect detection, enhances the comprehensive understanding of global and local information, and improves the positioning accuracy of abnormal areas.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116580014B_ABST
    Figure CN116580014B_ABST
Patent Text Reader

Abstract

The application discloses an industrial defect detection method and system, belongs to the technical field of industrial image processing, and provides a normal feature reconstruction model based on image level and feature level mask strategies, which can reconstruct normal features according to abnormal features; in the image level mask strategy, normal and abnormal features are extracted from normal industrial images and abnormal industrial images constructed based on the normal images, and are respectively taken as input signals and supervision signals; the difference between the input signals and the supervision signals promotes the learning of global information of the model, so as to guide the reconstruction of the abnormal area. In the feature level mask strategy, after feature extraction is performed on the fused and compressed abnormal feature map, part of the obtained feature map is randomly masked, and then the missing part is reconstructed, so as to emphasize the local correlation between pixels, and the fine-grained reconstruction of the image is beneficial. The application of the two kinds of mask strategies can successfully solve the overgeneralization problem, and the accuracy of industrial defect detection is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of industrial image processing technology, and more specifically, relates to an industrial defect detection method and system. Background Technology

[0002] With the advent of Industry 4.0, digitalization, informatization, and intelligentization have become important development directions in industrial manufacturing. Industries such as construction, machinery, and electronics are all beginning their intelligent transformation. In the industrial production process, product quality is easily affected by existing working conditions and limitations in personnel skills. Surface defects are the most direct manifestation of this impact on product quality. Therefore, to ensure pass rates and product quality reliability, surface defect detection is essential; it is a crucial link in industrial quality inspection. Traditionally, product defects are mostly detected by skilled quality inspectors based on human experience. However, quality inspectors may experience visual fatigue, are easily influenced by environmental factors, and each person's judgment of defects differs, making it difficult to guarantee inspection efficiency and quality. Therefore, many companies now choose to use machine vision equipment to replace manual labor in repetitive tasks, improving production efficiency and product quality.

[0003] Image anomaly detection aims to identify and locate heterogeneous regions within homogeneous images and has been widely applied in manufacturing defect detection, medical diagnosis, and video surveillance. In many industrial scenarios, such as quality control and surface defect detection, collecting anomalous samples is expensive and time-consuming, and the insufficient number of anomalous samples limits the application of supervised methods in actual production. To address this issue, numerous unsupervised methods have emerged. These methods, trained only on normal samples, can successfully locate anomalous regions in test images. Existing unsupervised anomaly detection methods can be categorized into distribution-based methods, reconstruction-based methods, and knowledge distillation-based methods.

[0004] Anomaly detection methods based on knowledge distillation typically involve a teacher network and a student network. The teacher network provides supervisory signals to help the student network reconstruct normal data. A simple and fundamental assumption in this knowledge distillation approach is that if the student network only perceives normal samples, then when faced with anomaly inputs, the reconstructed features output by the student network will differ significantly from its input features. This difference can serve as a criterion for judging the degree of anomaly. However, for some anomalous input features that are similar to normal features, the student network can still reconstruct them perfectly. This indicates that the method suffers from overgeneralization, resulting in a small difference between the features input to the student network and the features reconstructed by the student network, leading to missed defects and low accuracy in industrial defect detection. Summary of the Invention

[0005] In view of the above-mentioned defects or improvement needs of the existing technology, the present invention provides an industrial defect detection method and system to solve the technical problem that the accuracy of industrial defect detection is low due to the overgeneralization problem of the model in the existing technology.

[0006] To achieve the above objectives, in a first aspect, the present invention provides an industrial defect detection method, comprising:

[0007] Industrial image x to be inspected t Perform N layers of feature extraction to obtain x t After obtaining the N layers of original feature maps, they are input into the normal feature reconstruction model to obtain x. t N-layer normal feature map; compare x t The difference between the N-layer original feature map and the N-layer normal feature map is used to determine whether the industrial image to be detected has industrial defects if the difference value is greater than a preset threshold; otherwise, the industrial image to be detected is determined not to have industrial defects.

[0008] Where N≥1; the normal feature reconstruction model is trained in the following way:

[0009] For each pair of normal industrial images x in the training sample set n and based on x n The constructed anomalous industrial image x of the same size a Perform N layers of feature extraction to obtain x n The N-layer normal feature map, and x a The N-layer anomaly feature map;

[0010] x a The N-layer abnormal feature map is input into the normal feature reconstruction model, and the normal feature reconstruction model will then convert x... a The N-layer feature maps are fused by channel and then compressed to obtain the abnormal feature map f. B ; for f B After performing N layers of feature extraction, for f B Each feature map layer is randomly masked to obtain N incomplete feature maps; the missing pixels in each incomplete feature map are reconstructed to obtain x. a N-layer normal feature map; x a Each normal feature map of a layer has the same size as the abnormal feature map of its corresponding layer.

[0011] By minimizing x n With x a The sum of differences between the corresponding layer normal feature maps is used to train the parameters in the normal feature reconstruction model.

[0012] More preferably, in the process of industrial defect detection, a teacher network is used to extract N layers of features from the industrial image to be detected;

[0013] During the training process of the normal feature reconstruction model, a teacher network is used to train each pair of normal industrial images x in the training sample set. n and based on x n The constructed anomalous industrial image x a Perform feature extraction at N layers respectively;

[0014] Among them, the teacher network is the feature extraction model.

[0015] More preferably, the normal feature reconstruction model includes: a cascaded bottleneck module, a student network, a random mask module, and a reconstruction module; the student network is an inverted structure of the teacher network;

[0016] The bottleneck module is used to convert x a After fusing the N-layer feature maps by channel, the resulting anomaly feature map f is compressed along the channel dimension. B ;

[0017] Student networks are used for f B Perform N-layer feature extraction;

[0018] The random mask module is used for f B Each layer of feature map is randomly masked to obtain N incomplete feature maps;

[0019] The reconstruction module is used to reconstruct the missing pixels in each incomplete feature map, thereby obtaining x. a The N-layer normal feature map.

[0020] More preferably, the reconstruction module includes: a cascaded first convolutional layer, an activation layer, and a second convolutional layer.

[0021] More preferably, a cosine similarity function is used to measure x. n With x a The difference between the normal feature maps of the l-th layer; l = 1, 2, ..., N.

[0022] More preferably, the loss function of the normal feature reconstruction model is used to measure x. n With x a The sum of differences between the corresponding layer normal feature maps is as follows:

[0023]

[0024] in, For x n The normal feature map of the l-th layer; For x aThe normal feature map of the l-th layer; vec(·) represents the vectorization operation.

[0025] More preferably, based on normal industrial images x n Constructing abnormal industrial images x a The method is as follows:

[0026] From normal industrial images x n Cut out one or more image blocks from the x-shaped area and paste them into the x-shaped area. n At other locations, abnormal industrial images x were obtained a .

[0027] More preferably, x t The difference S between the N-layer original feature map and the N-layer normal feature map AD for:

[0028] S AD =max(S) AL (h,w))

[0029] Among them, S AL (h,w) is x t The difference measurement map S between the N-layer original feature map and the N-layer normal feature map AL The pixel value in row h and column w; h = 1, 2, ..., H; w = 1, 2, ..., W; H is S AL The length of S; W is the length of S. AL The width;

[0030]

[0031]

[0032] Φ(·) represents the upsampling operation, which is used to transform the size of the difference measurement plots of each layer to the same size H×W; For the difference measure plot of layer l, h l Line w l The pixel values ​​of the column; For x t The h-th channel of each channel in the original feature map of layer l l Line w l A vector composed of the pixel values ​​of the columns; For x t The h-th channel of the normal feature image of layer l l Line w l A vector composed of the pixel values ​​of the column; h l =1,2,…,H l ;w l =1,2,…,W l H lW is the length of the original feature map of layer l; l is the width of the original feature map of layer l.

[0033] In a second aspect, the present invention provides an industrial defect detection system, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the industrial defect detection method provided in the first aspect of the present invention.

[0034] Thirdly, the present invention also provides a computer-readable storage medium comprising a stored computer program, wherein the computer program, when executed by a processor, controls the device containing the storage medium to perform the industrial defect detection method provided in the first aspect of the present invention.

[0035] In summary, the above-described technical solutions conceived in this invention can achieve the following beneficial effects:

[0036] 1. This invention provides an industrial defect detection method, which offers a normal feature reconstruction model that can reconstruct normal features based on abnormal features. After extracting normal features from the industrial image to be detected based on the normal feature reconstruction model, the original features of the industrial image to be detected are compared with the extracted normal features to determine whether an industrial defect exists. The training strategy of the normal feature reconstruction model includes an image-level masking strategy and a feature-level masking strategy. In the image-level masking strategy, normal features and abnormal features are extracted from normal industrial images and abnormal industrial images constructed based on normal images, serving as input signals and supervision signals, respectively. The difference between the input signals and supervision signals promotes the normal feature reconstruction model's learning of global information to guide the reconstruction of abnormal regions. In the feature-level masking strategy, the fused and compressed abnormal feature map f... B After feature extraction, some features of the obtained feature map are randomly masked, and then the missing parts are reconstructed to emphasize the local correlation between pixels, which is beneficial for fine-grained image reconstruction. The application of these two masking strategies can successfully solve the overgeneralization problem and effectively improve the accuracy of industrial image defect detection.

[0037] 2. Furthermore, the industrial defect detection method provided by this invention employs a normal feature reconstruction model comprising a cascaded bottleneck module, a student network, a random mask module, and a reconstruction module. The bottleneck module reduces dimensionality, removes redundant information, reduces computational load, and also reduces the amount of abnormal information contained in the features input to the student network, making it easier for the student network to recover features. Furthermore, unlike traditional knowledge distillation methods that use both the student network and the teacher network as encoders, this invention uses the teacher network as the encoder and sets the student network as its inverse, acting as the decoder, to amplify the difference between the features extracted by the student network and the teacher network, thereby improving the accuracy of anomaly localization.

[0038] 3. Furthermore, in the industrial defect detection method provided by the present invention, the reconstruction module includes: a cascaded first convolutional layer, an activation layer, and a second convolutional layer, which has a relatively simple structure and high computational efficiency.

[0039] 4. Furthermore, in the industrial defect detection method provided by this invention, x is measured based on the cosine similarity function. t The difference between the N-layer original feature map and the N-layer normal feature map, as well as the loss function of the normal feature reconstruction model, and the cosine similarity reflect the relative difference in direction, which is more accurate; in addition, the present invention fuses the differences of feature maps of each layer, wherein the shallow features mainly contain low-scale texture information, while the deep features have significant advantages in extracting large-scale structural information, and the fusion is more conducive to anomaly localization. Attached Figure Description

[0040] Figure 1 This is a flowchart illustrating the training process of a normal feature reconstruction model provided in Embodiment 1 of the present invention.

[0041] Figure 2 This is a schematic diagram of constructing an abnormal industrial image based on a normal industrial image, as provided in Embodiment 1 of the present invention. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.

[0043] To achieve the above objectives, this invention provides an industrial defect detection method based on masked reverse knowledge distillation. Its purpose is to train a model that can reconstruct normal features from abnormal features. The "normal features" reconstructed by this model will differ significantly from the input abnormal features, and this difference can serve as an important basis for anomaly localization. This invention comprehensively utilizes global and local information, enabling the model to reconstruct normal features from the input abnormal features, thereby amplifying the difference between input and output features and achieving more accurate defect localization based on this difference. To further illustrate the industrial defect detection method provided by this invention, detailed descriptions are provided below with reference to specific embodiments:

[0044] Example 1

[0045] An industrial defect detection method, comprising:

[0046] Industrial image x to be inspected t Perform N layers of feature extraction to obtain x t After obtaining the N layers of original feature maps, they are input into the normal feature reconstruction model to obtain x. t N-layer normal feature map; compare x t The difference between the N-layer original feature map and the N-layer normal feature map is used to determine whether the industrial image to be detected has an industrial defect if the difference value is greater than a preset threshold; otherwise, the industrial image to be detected is determined not to have an industrial defect; where N≥1.

[0047] It should be noted that x can be directly compared based on Euclidean distance, Manhattan distance, and other distance formulas. t The difference between the N-layer original feature map and the N-layer normal feature map can also be compared based on the cosine similarity formula. t The difference between the N-layer original feature map and the N-layer normal feature map.

[0048] Preferably, the difference is measured based on cosine similarity. Specifically, in one optional implementation, x t The difference S between the N-layer original feature map and the N-layer normal feature map AD for:

[0049] S AD =max(S) AL (h,w))

[0050] Among them, S AL (h,w) is x t The difference measurement map S between the N-layer original feature map and the N-layer normal feature map AL The pixel value in row h and column w; h = 1, 2, ..., H; w = 1, 2, ..., W; H is S AL The length of S; W is the length of S. ALThe width;

[0051]

[0052]

[0053] Φ(·) represents the upsampling operation, which is used to transform the size of the difference measurement plots of each layer to the same size H×W; For the difference measure plot of layer l, h l Line w l The pixel values ​​of the column; For x t The h-th channel of each channel in the original feature map of layer l l Line w l A vector composed of the pixel values ​​of the columns; For x t The h-th channel of the normal feature image of layer l l Line w l A vector composed of the pixel values ​​of the column; h l =1,2,…,H l ;w l =1,2,…,W l H l W is the length of the original feature map of layer l; l is the width of the original feature map of layer l.

[0054] It should be noted that Euclidean distance and other distance metrics can only reflect absolute numerical differences, while cosine similarity reflects relative differences in direction and is more accurate. In addition, this invention fuses the differences between feature maps of each layer. Shallow features mainly contain low-scale texture information, while deep features have significant advantages in extracting large-scale structural information. The fusion is more conducive to anomaly localization.

[0055] The preset threshold in this embodiment is 0.5.

[0056] Specifically, the normal feature reconstruction model is trained in the following way:

[0057] For each pair of normal industrial images x in the training sample set n and based on x n The constructed anomalous industrial image x of the same size a Perform N layers of feature extraction to obtain x n The N-layer normal feature map, and x a The N-layer anomaly feature map;

[0058] x a The N-layer abnormal feature map is input into the normal feature reconstruction model, and the normal feature reconstruction model will then convert x... aAfter fusing (summing) the N-layer feature maps by channel, they are compressed to obtain the abnormal feature map f. B ; for f B After performing N layers of feature extraction, for f B Each feature map layer is randomly masked to obtain N incomplete feature maps; the missing pixels in each incomplete feature map are reconstructed to obtain x. a N-layer normal feature map; x a Each normal feature map of a layer has the same size as the abnormal feature map of its corresponding layer.

[0059] By minimizing x n With x a The sum of differences between the corresponding layer normal feature maps is used to train the parameters in the normal feature reconstruction model.

[0060] Specifically, such as Figure 1 As shown, in one optional implementation, during the industrial defect detection process, a teacher network is used to extract N layers of features from the industrial image to be detected; in this implementation, N=3.

[0061] During the training process of the normal feature reconstruction model, a teacher network is used to train each pair of normal industrial images x in the training sample set. n and based on x n The constructed anomalous industrial image x a Perform feature extraction at N layers respectively;

[0062] Among them, the teacher network is a feature extraction model, such as the residual model, VGG model, YOLO model (YOLOv3, YOLOv4, YOLOv5), etc.

[0063] Furthermore, the normal feature reconstruction model includes: a cascaded bottleneck module, a student network, a random mask module, and a reconstruction module; the student network is the inverted structure of the teacher network, that is, the i-th layer of the student network is the M-i+1-th layer of the teacher network; M is the total number of layers in the teacher network;

[0064] The bottleneck module is used to convert x a After fusing (summing) the N-layer feature maps by channel, they are compressed along the channel dimension to obtain the anomaly feature map f. BIt should be noted that the bottleneck module can be the bottleneck module in the RD4AD network (see H. Deng and X. Li, Anomaly Detection via Reverse Distillation from One-Class Embedding, in Proceedings of IEEE Conference on Computer Vision and Pattern Recognition, 2022, pp. 9727-9736), or it can be two 1×1 convolutional layers. It should be noted that any module that can achieve channel number compression is acceptable; there are no restrictions here. The bottleneck module can reduce dimensionality, remove redundant information, reduce computational load, and also reduce the amount of anomalous information contained in the features input to the student network, making it easier for the student network to complete feature recovery.

[0065] Student networks are used for f B An N-layer feature extraction process is performed. It should be noted that in traditional knowledge distillation, the student network and teacher network are similar, both acting as encoders. This can easily lead to them extracting similar features, thus narrowing the differences between them and making it difficult to locate anomalies. This invention uses the teacher network as the encoder and sets the student network as its inverse, acting as the decoder, to increase the difference between the features extracted by the student and teacher networks, thereby improving the accuracy of anomaly localization.

[0066] The random mask module is used for f B Each layer of feature map is randomly masked to obtain N incomplete feature maps;

[0067] The reconstruction module is used to reconstruct the missing pixels in each incomplete feature map, thereby obtaining x. a The N-layer normal feature map.

[0068] It should be further noted that the reconstruction module is constructed based on convolutional layers; preferably, in one optional implementation, the reconstruction module includes: a cascaded first convolutional layer, an activation layer, and a second convolutional layer. It should be noted that the number of the first and second convolutional layers can be multiple, and is not limited to a single layer. The reconstruction module designed in this invention has a relatively simple structure and high computational efficiency.

[0069] Preferably, in one optional implementation, x is measured based on the cosine similarity formula. n With x a The sum of differences between the corresponding layer normal feature maps; specifically, used to measure x. n With x a The loss function of the normal feature reconstruction model, which is the sum of the differences between the corresponding normal feature maps, is:

[0070]

[0071] in, For x n The normal feature map of the l-th layer; For x a The normal feature map of the l-th layer; vec(·) represents the vectorization operation.

[0072] It should be noted that, in addition to using the cosine similarity formula mentioned above, other similarity formulas such as Euclidean distance, Manhattan distance, SSIM (Structural Similarity Formula), and MSE (Mean Squared Error Formula) can also be used. No specific formula is specified here.

[0073] It should be noted that Euclidean distance and other distance metrics can only reflect absolute numerical differences, while cosine similarity reflects relative differences in direction and is more accurate. In addition, this invention fuses the differences between feature maps of each layer. Shallow features mainly contain low-scale texture information, while deep features have significant advantages in extracting large-scale structural information. The fusion is more conducive to anomaly localization.

[0074] It should be noted that the following algorithms can be used: Cutpaste (see Cutpaste: Self-supervised learning for anomaly detection and localization. In: Proceedings of the IEEE / CVFConference on Computer Vision and Pattern Recognition (CVPR). pp. 9664–9674 (June 2021)), NSA (see HMSchlüter, J. Tan, B. Hou, and B. Kainz, Natural Synthetic Anomalies for Self-supervised Anomaly Detection and Localization, in: European Conference on Computer Vision, 2022, pp. 474-489), and FPI (see Tan, J., Hou, B., Batten, J., Qiu, H., Kainz, B.: Detecting outliers with foreign patch interpolation. Machine Learning for Biomedical). Imaging), PII algorithm (see Tan, J., Hou, B., Day, T., Simpson, J., Rueckert, D., Kainz, B.: Detecting outliers with poissonimage interpolation. In: Medical Image Computing and Computer Assisted Intervention–MICCAI 2021.pp.581–591. Springer International Publishing, Cham (2021)), and other methods, based on normal industrial images x n Constructing abnormal industrial images x a Preferably, such as Figure 2 As shown, in one alternative implementation, based on a normal industrial image x n Constructing abnormal industrial images x a The method is as follows: from a normal industrial image x n Cut out one or more image blocks from the x-shaped area and paste them into the x-shaped area. n At other locations, abnormal industrial images x were obtained aThis method is relatively simple and easy to implement, and also has the following advantages: 1) Utilizing Poisson image editing techniques, the synthesized anomalous regions can be naturally integrated into the original image. 2) By scaling, moving, and a novel shape sampling strategy based on gamma distribution, the diversity of generated anomalies is increased. 3) By applying background constraints, the generated anomaly patches can be more effectively pasted into the foreground of the image. Specifically, Figure 2 The first column is a normal industrial image x n The following columns are based on normal industrial images x n The constructed anomalous industrial image x a .

[0075] To further illustrate the industrial defect detection method provided by this invention, a specific embodiment is described in detail below:

[0076] In the training phase of the normal feature reconstruction model, this invention proposes a masked reverse knowledge distillation method to guide the student network to reconstruct abnormal features into normal features. This invention introduces a teacher network to extract image features. However, if the features extracted by the teacher network are simultaneously used as input and supervision signals for the student network, the student network's ability to extract high-level semantic features will be poor. Therefore, this invention aims to enable the student network to reconstruct the features of abnormal regions intact. Thus, this invention employs image-level and feature-level masks to encourage the student network to comprehensively learn global and local information, thereby extracting higher-level semantic information to alleviate the overgeneralization problem. Specifically, in the image-level mask, this invention creates abnormal samples based on normal images. The teacher network extracts two types of features—normal and abnormal—from the normal and created abnormal samples, setting the normal features as supervision signals and the abnormal features as input signals. Only the input signals are transmitted to the student network. The student network needs to utilize global information to infer and reconstruct the abnormal features from the input network into features identical to the normal features extracted by the teacher network, thereby alleviating the overgeneralization problem. In feature-level masking, this invention randomly masks a portion of the pixels output by the student network and reconstructs the entire feature using the remaining pixels through a reconstruction module. Missing pixels can be inferred from neighboring pixels, thereby enhancing the network's utilization of local information and making the reconstructed features more refined, effectively supplementing image-level masking.

[0077] 1) Image-level mask

[0078] To enable student networks to reconstruct real anomalies as normal features, this invention requires generating synthetic anomalies that resemble real anomalies. In this implementation, patches are cropped from the training set images and then pasted onto the input image x. n The above yields the synthesized abnormal image x. a .

[0079] This implementation uses a pre-trained residual network as the teacher network T to extract semantic information from the image. During training, the weights of the teacher network are frozen (remain unchanged). The output feature layer of the network is defined as follows: l∈{1,2,…N}; where l represents the number of feature layers. x n and x a Input into T to obtain normal features and abnormal features As a signal for student network input, As a monitoring signal:

[0080]

[0081] This embodiment follows the design of the RD4AD network and uses the same bottleneck module. Only... The input is fed into the bottleneck module, where compressed anomalous features f are obtained. B It was used for training students' networks.

[0082] Image-level masking fundamentally changes how networks reconstruct data, shifting from directly copying the input to the output to inferring reconstructed regions using global information. Existing methods train models only on normal samples, hoping to suppress the student network's ability to reconstruct anomalous samples. However, because the supervision signal is the same as the input signal, the student network's ability to capture global information is not fully utilized, unintentionally leading to generalization of anomalous features. Therefore, this invention uses synthetic anomalous features. As the input signal for the student network, normal characteristics are used. As a supervisory signal, in this setting, the student network focuses more on global information, inferring and reconstructing the corresponding normal image features extracted by the teacher network through understanding the semantic and structural relationships of the image.

[0083] 2) Feature-level mask

[0084] In completing the features and f B After extraction, this invention only extracts f B Input student network S to obtain output features Then randomly cover it up. Some pixels in the image are selected, and the masked feature map is input into the reconstruction module G to restore the feature map and obtain the final output feature map. G contains two convolutional layers W l1 and W l2 A ReLU activation layer. This process can be represented by the following formula:

[0085]

[0086]

[0087] Among them, R l (h,w) are random numbers in (0,1), λ represents the mask ratio, and M l It is the generated mask.

[0088] In order to generate features This is a normal data stream; this invention combines it with... Alignment. Specifically, this embodiment defines a vectorized equation vec(·) to... and Convert to a 1×D dimensional vector. Then use the cosine similarity function to compare features. and The similarity between the layers is calculated, and the values ​​from each output layer are summed to obtain the loss function value, which is defined as follows:

[0089]

[0090] Feature-level masking strategies improve the utilization of local information by masking a portion of pixels in the feature map and then restoring it. Since pixel masking is random, when the masking ratio is not particularly high, there will always be some remaining pixels around the masked pixels. These remaining pixels are compressed high-dimensional feature representations, already containing some information about the masked pixels. Therefore, normal feature reconstruction models rely more on surrounding pixels to reconstruct missing pixels, forcing them to grasp more local information.

[0091] In summary, in image-level masking, a portion of information from the normal image is first masked to synthesize the anomalous image. Then, the teacher network extracts anomalous and normal features from the synthesized anomalous and normal images, serving as the supervisory and input signals, respectively. The difference between the supervisory and input signals facilitates the network's learning of global information to guide the reconstruction of anomalous regions. In feature-level masking, some features of the student network's output layer are randomly masked, and then restored using a simple module to emphasize local correlations between pixels, which is beneficial for fine-grained image reconstruction. The application of these two masking strategies enables the proposed mask-based reverse knowledge distillation method to successfully suppress overgeneralization and effectively improve the performance of existing industrial image defect detection methods.

[0092] Furthermore, after the normal feature reconstruction model is trained, industrial defect detection is performed in the application phase:

[0093] At this point, the present invention no longer performs image-level masking, but directly applies the test image x tInput the teacher network and bottleneck module to obtain compressed features. After completing the training phase, the student network was able to restore anomalous features to normal features. therefore and The distance between them can be used to locate abnormal areas. This embodiment calculates... and The pixel-level difference metric S is obtained by using cosine similarity along the channel axis between the two channels. AL For anomaly detection, S AL The maximum value S in AD It can be expressed as and The maximum difference between them, therefore S is used. AD As an image-level anomaly score, specifically:

[0094] S AD =max(S) AL (h,w))

[0095] Among them, S AL (h,w) is x t The difference measurement map S between the N-layer original feature map and the N-layer normal feature map AL The pixel value in row h and column w; h = 1, 2, ..., H; w = 1, 2, ..., W; H is S AL The length of S; W is the length of S. AL The width;

[0096]

[0097]

[0098] Φ(·) represents the upsampling operation, which is used to transform the size of the difference measurement plots of each layer to the same size H×W; For the difference measure plot of layer l, h l Line w l The pixel values ​​of the column; For x t The h-th channel of each channel in the original feature map of layer l l Line w l A vector composed of the pixel values ​​of the columns; For x t The h-th channel of the normal feature image of layer l l Line w l A vector composed of the pixel values ​​of the column; h l =1,2,…,H l ;w l =1,2,…,W l H lW is the length of the original feature map of layer l; l is the width of the original feature map of layer l.

[0099] In summary, this invention proposes an industrial defect detection method based on masked reverse knowledge distillation. This method employs two masking strategies at the image and pixel levels, encouraging the network to enhance its comprehensive understanding of global and local information. The constructed normal feature reconstruction model can achieve complex overall reconstruction from anomalies to normal features, greatly expanding the differences between anomalies and helping to solve the overgeneralization problem existing in knowledge distillation-based anomaly detection methods.

[0100] Example 2

[0101] An industrial defect detection system includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the industrial defect detection method provided in Embodiment 1 of the present invention.

[0102] The relevant technical solutions are the same as in Embodiment 1, and will not be repeated here.

[0103] Example 3

[0104] A computer-readable storage medium includes a stored computer program, wherein the computer program, when executed by a processor, controls the device where the storage medium is located to execute the industrial defect detection method provided in Embodiment 1 of the present invention.

[0105] The relevant technical solutions are the same as in Embodiment 1, and will not be repeated here.

[0106] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An industrial defect detection method, characterized in that, include: Industrial images to be inspected Perform N layers of feature extraction to obtain After obtaining the N layers of original feature maps, they are input into the normal feature reconstruction model to obtain... N-layer normal feature maps; comparison The difference between the N-layer original feature map and the N-layer normal feature map is determined. If the difference value is greater than a preset threshold, an industrial defect is determined to exist; otherwise, no industrial defect is determined to exist. in, The normal feature reconstruction model is trained in the following way: For each pair of normal industrial images in the training sample set and based on The constructed anomalous industrial images of the same size Perform N layers of feature extraction respectively to obtain The N-layer normal feature map, and The N-layer anomaly feature map; Will The N-layer abnormal feature map is input into the normal feature reconstruction model, and the normal feature reconstruction model will... The N-layer anomaly feature maps are fused by channel and then compressed to obtain the anomaly feature map. ;right After performing N layers of feature extraction, Each feature map layer is randomly masked to obtain N incomplete feature maps; the missing pixels in each incomplete feature map are then reconstructed to obtain... N-layer normal feature map; Each normal feature map of a layer has the same size as the abnormal feature map of its corresponding layer. By minimizing and The sum of differences between the corresponding layer normal feature maps is used to train the parameters in the normal feature reconstruction model.

2. The industrial defect detection method according to claim 1, characterized in that, In the process of industrial defect detection, a teacher network is used to extract N layers of features from the industrial images to be detected. During the training process of the normal feature reconstruction model, the teacher network is used to train each pair of normal industrial images in the training sample set. and based on The constructed abnormal industrial images Perform feature extraction at N layers respectively; The teacher network is a feature extraction model.

3. The industrial defect detection method according to claim 2, characterized in that, The normal feature reconstruction model includes: a cascaded bottleneck module, a student network, a random mask module, and a reconstruction module; the student network is an inverted structure of the teacher network. The bottleneck module is used to... After fusing the N-layer anomaly feature maps by channel, they are compressed along the channel dimension to obtain the anomaly feature map. ; The student network is used for... Perform N-layer feature extraction; The random mask module is used for... Each layer of feature map is randomly masked to obtain N incomplete feature maps; The reconstruction module is used to reconstruct the missing pixels in each incomplete feature map, thereby obtaining... The N-layer normal feature map.

4. The industrial defect detection method according to claim 3, characterized in that, The reconstruction module includes: a cascaded first convolutional layer, an activation layer, and a second convolutional layer.

5. The industrial defect detection method according to claim 1, characterized in that, Cosine similarity function is used for measurement and The l Differences between normal feature maps of layers; .

6. The industrial defect detection method according to claim 5, characterized in that, The loss function of the normal feature reconstruction model is used to measure... and The sum of differences between the corresponding layer normal feature maps is as follows: in, for The l Layer normal feature map; for The l Layer normal feature map; This indicates a vectorization operation.

7. The industrial defect detection method according to claim 1, characterized in that, Based on normal industrial images Constructing abnormal industrial images The method is as follows: From normal industrial images Cut out one or more image blocks from the image and paste them into the image. Abnormal industrial images were obtained at other locations. .

8. The industrial defect detection method according to any one of claims 1-7, characterized in that, The difference between the N-layer original feature map and the N-layer normal feature map for: in, for The difference measurement map between the N-layer original feature map and the N-layer normal feature map No. Line number The pixel values ​​of the column; ; ; for Length; for The width; This indicates an upsampling operation, used to transform the size of the difference metric plots at each layer to the same size. ; For the first l Layer Difference Measurement Plot Line number The pixel values ​​of the column; for The l The first layer of the original feature map under each channel Line number A vector composed of the pixel values ​​of the columns; for The l The first layer of normal feature image under each channel Line number A vector composed of the pixel values ​​of the columns; ; ; For the first l The length of the original feature map of the layer; For the first l The width of the original feature map of the layer.

9. An industrial defect detection system, characterized in that, include: A memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the industrial defect detection method according to any one of claims 1-8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein when the computer program is run by a processor, it controls the device on which the storage medium is located to perform the industrial defect detection method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Knowledge distillation-based unsupervised industrial image anomaly detection method and system

    CN114240892A

  • Image restoration method based on confrontation multi-scale and residual multi-channel space attention

    CN114782265A