Defect detection method, device, equipment, medium and product

The advanced feature matrix is ​​generated through the feature migration model and clustering algorithm, which solves the problems of insufficient data samples and feature mismatch in industrial scenarios, improves the accuracy and stability of defect detection, and reduces the risk of false alarms.

CN118799253APending Publication Date: 2024-10-18CHINA MOBILE COMM LTD RES INST +2
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410238929.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-01
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

In industrial scenarios, due to the small number of data samples, existing defect detection models are prone to the risk of false negatives, and models pre-trained based on the imagenet dataset cannot effectively represent high-level features in the industrial field, resulting in noise sensitivity and excessive false positives.

Method used

By obtaining the image samples to be detected and the standard image samples, the feature migration model is used to generate the feature matrix to be detected and the standard feature matrix set, the anomaly matrix is ​​calculated to represent the feature distance, and the network is adjusted based on the clustering algorithm and feature superposition, compression, and reconstruction modules. structure, generating high-level feature matrices to reduce the risk of false negatives.

Benefits of technology

It improves the accuracy of defect detection, reduces the risk of false negatives, reduces false positives caused by reliance on underlying features, and enhances the ability to characterize data characteristics in the industrial field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118799253A_ABST
    Figure CN118799253A_ABST
Patent Text Reader

Abstract

The invention discloses a defect detection method, device and equipment, a medium and a product. The defect detection method comprises the following steps: acquiring a to-be-detected image sample; generating a to-be-detected feature matrix of the to-be-detected image sample based on the to-be-detected image sample and the first feature migration model; based on the to-be-detected feature matrix and a first standard feature matrix set, a first abnormal matrix is generated, the first abnormal matrix is used for representing the abnormal distance between the to-be-detected feature matrix and each standard feature matrix in the first standard feature matrix set, and the first standard feature matrix set is generated based on a first feature migration model; generating a second abnormal matrix based on the first abnormal matrix, the second abnormal matrix being used for representing the maximum abnormal distance between the to-be-detected feature matrix and the first standard feature matrix set; and determining a defect position of the to-be-detected image sample based on the second anomaly matrix and an anomaly distance threshold. Therefore, the accuracy of defect detection is improved, and the risk of missing report is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of defect detection technology, and in particular to a defect detection method, device, equipment, medium and product. Background Art

[0002] In recent years, with the rise of artificial intelligence technology, defect detection models based on deep learning have developed rapidly. However, in some fields with fewer data samples, for example, in industrial scenarios, due to the long production cycle of industrial products and insufficient data samples, if defect detection samples trained with these data samples are used for defect detection, there will be a risk of missing reports.

[0003] In related technologies, feature migration can also be used to pre-train the defect detection model for defect detection. Feature migration refers to the use of model weights trained on large data sets, such as the imagenet data set, and various feature transformation strategies to obtain feature expressions of the data domain of interest (e.g., the industrial field) at a relatively low cost.

[0004] However, in practical applications, there is a large gap between the ImageNet dataset and industrial data. Most of them use low-level features as the feature library of industrial data. However, the lack of high-level features can easily cause noise sensitivity and excessive false positives, resulting in the inability of pre-trained models to accurately characterize the data characteristics of the industrial field. Summary of the invention

[0005] In view of this, the embodiments of the present application provide a defect detection method, apparatus, device, medium and product, aiming to improve the accuracy of defect detection.

[0006] The technical solution of the embodiment of the present application is implemented as follows:

[0007] In a first aspect, an embodiment of the present application provides a defect detection method, the method comprising:

[0008] Obtain an image sample to be detected;

[0009] Based on the image sample to be detected and the first feature migration model, generating a feature matrix to be detected of the image sample to be detected;

[0010] Based on the feature matrix to be detected and the first standard feature matrix set, a first abnormal matrix is ​​generated, wherein the first abnormal matrix is ​​used to characterize the distance between the feature matrix to be detected and each standard feature matrix in the first standard feature matrix set, and the first standard feature matrix set is generated based on the first feature migration model;

[0011] Based on the first abnormal matrix, a second abnormal matrix is ​​generated, where the second abnormal matrix is ​​used to represent the maximum abnormal distance between the feature matrix to be detected and the first standard feature matrix set;

[0012] Based on the second abnormality matrix and the abnormality distance threshold, the defect position of the image sample to be detected is determined.

[0013] In some embodiments, the method comprises:

[0014] Acquire multiple standard image samples;

[0015] Based on each of the standard image samples and the first feature migration model, generating a second standard feature matrix corresponding to each of the standard image samples;

[0016] Clustering each of the second standard feature matrices based on a clustering algorithm to generate a clustering result; the clustering result includes one or more clusters;

[0017] The first standard feature matrix set is generated based on cluster centers of the one or more clusters.

[0018] In some embodiments, the method further comprises:

[0019] Obtaining a pre-trained first image generation model and a training image sample;

[0020] Embedding a feature superposition module, a feature compression module, and a feature reconstruction module into the feature output layer of the pre-trained first image generation model to generate a network structure of a second image generation model, wherein the second image generation model is used to output an image generation result;

[0021] Based on the training image samples and the network structure of the second image generation model, training the second image generation model until a trained second image generation model is obtained;

[0022] The network structure of the trained second image generation model is adjusted to generate the first feature migration model, where the first feature migration model is used to output a feature matrix of the image sample.

[0023] In some embodiments, the training of the second image generation model based on the training image sample and the network structure of the second image generation model until a trained second image generation model is obtained includes:

[0024] Extracting one or more hierarchical features of the training image sample based on the training image sample and the feature output layer of the first image generation model;

[0025] The feature superposition module based on the second image generation model superimposes the one or more hierarchical features to generate a feature matrix of a first feature dimension;

[0026] The feature compression module based on the second image generation model compresses the feature matrix of the first feature dimension to generate a feature matrix of the second feature dimension;

[0027] Reconstructing the feature matrix of the second feature dimension based on the image reconstruction module to generate a reconstructed image sample;

[0028] Based on the reconstructed image samples, the training image samples and the loss function, the second image generation model is trained until a trained second image generation model is obtained.

[0029] In some embodiments, the adjusting the network structure of the trained second image generation model to generate the first feature migration model comprises:

[0030] Delete the feature reconstruction module in the network structure of the second image generation model to generate the first feature migration model.

[0031] In some embodiments, generating a second exception matrix based on the first exception matrix includes:

[0032] Obtaining each row of data of the first abnormal matrix;

[0033] The second abnormality matrix is ​​generated based on the maximum values ​​corresponding to each row of data.

[0034] In some embodiments, determining the defect position of the image sample to be detected based on the second abnormality matrix and the abnormality distance threshold includes:

[0035] Based on the second anomaly matrix and the anomaly distance threshold, generating a first defect matrix;

[0036] The first defect matrix is ​​reorganized based on the size information of the image to be detected to generate a second defect matrix, where the second defect matrix is ​​used to characterize the defect positions of the image sample to be detected.

[0037] In a second aspect, an embodiment of the present application provides a defect detection device, the defect detection device comprising:

[0038] An acquisition module, used for acquiring an image sample to be detected;

[0039] A generation module, used to generate a feature matrix to be detected of the image sample to be detected based on the image sample to be detected and the first feature migration model; generate a first abnormal matrix based on the feature matrix to be detected and the first standard feature matrix set, wherein the first abnormal matrix is ​​used to characterize the distance between the feature matrix to be detected and each standard feature matrix in the first standard feature matrix set, and the feature matrix set is generated based on the first feature migration model; generate a second abnormal matrix based on the first abnormal matrix; the matrix dimensions of the first abnormal matrix and the second abnormal matrix are different;

[0040] A determination module is used to determine the defect position of the image sample to be detected based on the second abnormality matrix and the abnormality distance threshold.

[0041] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein the processor, when used to run the computer program, executes the steps of the method described in any aspect of the embodiment of the present application.

[0042] In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in any aspect of the embodiment of the present application are implemented.

[0043] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method described in any aspect of the embodiment of the present application.

[0044] The technical solution provided by the embodiment of the present application discloses a defect detection method, which includes: obtaining an image sample to be detected; generating a feature matrix to be detected of the image sample to be detected based on the image sample to be detected and a first feature migration model; generating a first abnormality matrix based on the feature matrix to be detected and a first standard feature matrix set, the first abnormality matrix being used to characterize the abnormal distance between the feature matrix to be detected and each standard feature matrix in the first standard feature matrix set, the first standard feature matrix set being generated based on the first feature migration model; generating a second abnormality matrix based on the first abnormality matrix, the second abnormality matrix being used to characterize the maximum abnormal distance between the feature matrix to be detected and the first standard feature matrix set; and determining the defect position of the image sample to be detected based on the second abnormality matrix and the abnormality distance threshold.

[0045] The embodiment of the present application is different from the prior art that uses underlying features as the feature library of industrial data. The embodiment of the present application extracts the feature matrix to be detected of the image sample to be detected and generates a first standard feature matrix set through a first feature migration model. The first standard feature matrix set includes high-level feature data of the image sample, and performs defect detection based on the feature matrix to be detected of the image sample to be detected and the first standard feature matrix set, thereby reducing the underreporting situation that may be caused by reliance on underlying features, improving the accuracy of defect detection, and reducing the risk of underreporting. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 A schematic diagram of a defect detection method according to an embodiment of the present invention;

[0047] Figure 2 A partial shooting point map of the wheel hub industrial parts provided in the embodiment of the present application;

[0048] Figure 3 A flowchart of a feature migration phase of an application example of the present application;

[0049] Figure 4 A schematic diagram of the model structure of a feature migration strategy model of an application example of the present application;

[0050] Figure 5 The original input image of the trained feature transfer model of an application example of this application;

[0051] Figure 6 A model reconstruction diagram of a feature transfer model after training in an application example of the present application;

[0052] Figure 7 A flowchart of a defect detection phase of an application example of the present application;

[0053] Figure 8 A schematic diagram of a defect detection result of an application example of the present application;

[0054] Fig. 9 A schematic diagram of another defect detection result of an application example of the present application;

[0055] Fig.10 This is a schematic diagram of the structure of a defect detection device according to an embodiment of the present application;

[0056] Fig.11 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0057] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0059] At present, in some fields with fewer data samples, for example, in industrial scenarios, the defect detection methods mainly include three methods, which are described in detail as follows:

[0060] 1. Supervised learning method - target detection method. It includes solution 1: obtain the defect location through defect target detection, and then further obtain various defect categories through subsequent classification methods; solution 2: propose a twin network structure, generate FPN (Feature Pyramid Network) features by combining the detection image and the template image, and use it for the subsequent binary classification detection network. This method requires certain annotated data support and has the risk of missing defect types that the model has not seen.

[0061] 2. Unsupervised learning method - method based on feature embedding. For example, this method uses a model pre-trained on a large-scale data set to extract features from normal image samples to build a feature library, and uses feature similarity calculation to locate defects in defective images. This method does not require manual labeling, but the feature extraction method used is based on a model pre-trained on the imagenet data set. The imagenet data set is a very important large-scale image database in the field of computer vision, which is significantly different from industrial images and cannot obtain high-level features of industrial image data, resulting in the model being sensitive to data noise and prone to false positives;

[0062] 3. Semi-supervised learning method. For example, using an industrial image defect detection method based on a multi-head unbalanced semi-supervised network can fully deal with the problems of serious imbalance of positive and negative samples and lack of labeled data in industrial image anomaly detection. However, this method also needs to rely on certain labeled samples. For industrial image data, the lack of defective samples is very common, and this strategy also has the risk of underreporting.

[0063] However, the above solution will have the following problems:

[0064] 1) Both supervised learning methods and semi-supervised learning methods rely on the annotation information of defect sample data. Due to the long production cycle of industrial parts, insufficient data samples, and even the inability to collect a full amount of defect data samples, there is a risk of missing defect types that the model has not seen when using these methods to detect defects in industrial images.

[0065] 2) Among the unsupervised learning methods, most of them are based on feature embedding and currently use models pre-trained on large-scale datasets such as ImageNet. However, there is a large gap between the ImageNet dataset and industrial data. The features obtained by the pre-trained model through forward calculation of industrial data cannot well represent the data characteristics. In order to alleviate the feature mismatch problem caused by data differences, most of them use low-level features as the feature library of industrial data. However, the lack of high-level features can easily lead to noise sensitivity and excessive false alarms.

[0066] Based on this, the present application embodiment provides a defect detection method, referring to Figure 1 , the method comprises the following steps:

[0067] Step 110: Obtain an image sample to be detected.

[0068] Here, the image samples to be inspected may include image data in the industrial field. In actual industrial scenarios, high-precision industrial cameras and supporting optical systems can be used to shoot target industrial parts (such as wheels) from multiple angles and multiple points to ensure that the image samples to be inspected are fully covered and clearly display the areas that may contain defects. For example, refer to Figure 2 , Figure 2 This is a partial shooting point map of wheel hub industrial parts.

[0069] Step 120: Generate a feature matrix to be detected of the image sample to be detected based on the image sample to be detected and the first feature migration model.

[0070] Here, the first feature transfer model is used to extract the feature matrix of the image sample to be detected. Based on the first feature transfer model, the feature extraction of the image sample to be detected is performed to generate the feature matrix to be detected of the image sample to be detected. The first feature transfer model adopts a convolutional neural network, which includes multiple convolutional layers to extract features in multiple layers. The convolutional layers in the model will identify and capture low-level features such as local patterns, edges, textures, etc. in the image samples, and gradually transition to higher-level features as the network depth increases, such as shapes, object parts, and even features related to the entire object category, thereby outputting a matrix with a small spatial dimension but high-level abstract features. Compared with the prior art that uses underlying features such as pixel intensity, color histogram, etc. as the feature library of industrial data, the feature matrix to be detected extracted by the first feature transfer model has better invariance to geometric transformations such as illumination changes, rotation, scaling, and a certain degree of occlusion and noise.

[0071] Here, the first feature migration model is used to extract the features of the image sample to be detected and generate a feature matrix. The feature dimensions of the feature matrix include: the spatial dimension information of the image and the number of channels. Exemplarily, assuming that the image sample to be detected is an image sample of 512x512 pixels, when the image is input into the first feature migration model, the first feature migration model will gradually extract the features of the image and generate a matrix with a smaller spatial dimension but with high-level abstract features. For example, a feature matrix with a feature dimension of 64x64x1024 can be generated, where 64x64 is the spatial dimension information, and 1024 is the number of channels at each 64x64 spatial position. For each 64x64 spatial position, the first feature migration model can generate a 1024-dimensional feature vector.

[0072] Step 130: Generate a first anomaly matrix based on the feature matrix to be detected and the first standard feature matrix set, wherein the first anomaly matrix is ​​used to characterize the anomaly distance between the feature matrix to be detected and each standard feature matrix in the first standard feature matrix set, and the first standard feature matrix set is generated based on the first feature migration model.

[0073] Here, the first standard feature matrix set is generated based on the first feature migration model. Exemplarily, the corresponding feature matrices are extracted from a large number of standard image samples based on the first feature migration model to generate the first standard feature matrix set. The first standard feature set includes high-level feature data of the first standard image samples.

[0074] Here, for one or more first standard feature matrices in the first standard feature matrix set, the distance between the first standard feature matrix and the feature matrix to be detected is calculated based on a distance algorithm, and the distance algorithm includes: Euclidean distance, cosine similarity, Mahalanobis distance, etc., so as to generate a first abnormal matrix.

[0075] Exemplarily, for an image to be detected, the feature dimension of the feature matrix to be detected corresponding to the image can be expressed as 4096x1024. The feature matrix to be detected is calculated based on the Euclidean distance with one or more first standard feature matrices. Assuming that the first standard feature matrix set includes 5 first standard feature matrices, for each row of the feature matrix to be detected, its distance from the 5 first standard feature matrices is calculated, and these distance values ​​are combined into a new matrix by column, thereby obtaining a first abnormal matrix with a feature dimension of 4096x5. In the first abnormal matrix, the 5 elements of each row respectively reflect the degree of deviation of the corresponding image to be detected at a certain image position relative to the 5 different standard feature patterns.

[0076] Here, the first anomaly matrix is ​​used to characterize the anomaly distance between the feature matrix to be detected and each standard feature matrix in the first standard feature matrix set. The anomaly distance characterizes the degree of deviation between the feature vector to be detected and a certain standard feature vector represented by each element in the first anomaly matrix. The smaller the anomaly distance, the higher the similarity between the feature matrix to be detected and the standard feature matrix.

[0077] Step 140: Based on the first abnormality matrix, a second abnormality matrix is ​​generated, where the second abnormality matrix is ​​used to represent the maximum abnormality distance between the feature matrix to be detected and the first standard feature matrix set.

[0078] Here, in order to better reflect the maximum deviation degree of the image sample to be detected, it is necessary to process the first abnormal matrix to generate a second abnormal matrix, wherein the second abnormal matrix is ​​used to characterize the maximum abnormal distance between the feature matrix to be detected and the first standard feature matrix set.

[0079] Step 150: Determine the defect position of the image sample to be detected based on the second abnormality matrix and the abnormality distance threshold.

[0080] Here, the second anomaly matrix includes one or more maximum anomaly distances, each of which corresponds to a certain position of the image to be detected. The maximum anomaly distances in the second anomaly matrix are compared with the anomaly distance threshold. If the maximum anomaly distance is greater than the anomaly distance threshold, it means that the position of the image to be detected corresponding to the maximum anomaly distance is abnormal, and the position is a defective position. If it is less than, it means that the position is normal and not a defective position, thereby determining the defective position of the image sample to be detected.

[0081] Thus, the embodiment of the present application is different from the prior art that uses underlying features as the feature library of industrial data. The embodiment of the present application extracts the feature matrix to be detected of the image sample to be detected through the first feature migration model and generates a first standard feature matrix set. The first standard feature matrix set includes high-level feature data of the image sample, and performs defect detection based on the feature matrix to be detected of the image sample to be detected and the first standard feature matrix set, thereby reducing the underreporting situation that may be caused by reliance on underlying features, improving the accuracy of defect detection, and reducing the risk of underreporting.

[0082] In some embodiments, the method comprises:

[0083] Acquire multiple standard image samples;

[0084] Based on each standard image sample and the first feature migration model, a second standard feature matrix corresponding to each standard image sample is generated;

[0085] Clustering each second standard feature matrix based on a clustering algorithm to generate a clustering result; the clustering result includes one or more clusters;

[0086] A first standard feature matrix set is generated based on cluster centers of one or more clusters.

[0087] Here, a plurality of standard image samples are first obtained from the data set, and for each of the plurality of standard image samples, feature extraction is performed based on the first feature migration model, so as to generate a second standard feature matrix corresponding to each standard image sample.

[0088] Here, the clustering algorithm includes but is not limited to: K-means and hierarchical clustering, etc. Based on the clustering algorithm (such as K-means, hierarchical clustering, DBSCAN, etc.), the second standard feature matrix is ​​clustered and analyzed to generate a clustering result. The clustering result includes one or more clusters (Cluster), and each cluster contains image samples with similar features.

[0089] Here, after clustering is completed, each cluster will have one or more center points (cluster centers) representing the overall characteristics of the cluster. For algorithms such as K-means, the cluster center is usually the mean of the feature vectors of all samples in the cluster; the center of each cluster is extracted as a separate feature vector to form a set, which is the first standard feature matrix set. Exemplarily, if the feature dimension of each cluster is D, and K clusters are obtained through clustering, then the generated first standard feature matrix can be represented by a D×K matrix.

[0090] The embodiment of the present application generates a clustering result by clustering each second standard feature matrix based on a clustering algorithm; the clustering result includes one or more clusters; based on the cluster centers of one or more clusters, a first standard feature matrix set is generated, which can effectively classify standard image samples and improve the accuracy of the first standard feature matrix set.

[0091] In some embodiments, the method further comprises:

[0092] Obtaining a pre-trained first image generation model and a training image sample;

[0093] Embedding a feature superposition module, a feature compression module, and a feature reconstruction module into a feature output layer of a pre-trained first image generation model to generate a network structure of a second image generation model, wherein the second image generation model is used to output an image generation result;

[0094] Based on the training image samples and the network structure of the second image generation model, training the second image generation model until a trained second image generation model is obtained;

[0095] The network structure of the trained second image generation model is adjusted to generate a first feature migration model, where the first feature migration model is used to output a feature matrix of the image sample.

[0096] Here, the pre-trained first image generation model is used for image detection. Exemplarily, the first image generation model can be a deep neural network model pre-trained on a large image dataset such as ImageNet. On the basis of the pre-trained first image generation model, additional modules are embedded, such as a feature superposition module, a feature compression module, and a feature reconstruction module. Through the integration of these modules, a new network structure is constructed to generate the network structure of the second image generation model, thereby forming a second image generation model. The second image generation model can not only perform basic image detection tasks, but also has a stronger feature representation capability to improve detection accuracy. Based on the training image samples and the network structure of the second image generation model, the second image generation model is trained until a trained second image generation model is obtained.

[0097] Here, the task of the first feature transfer model is to output the feature matrix of the image sample. The embodiment of the present application adjusts the network structure of the trained second image generation model so that it no longer outputs specific detection results, but instead generates the first feature transfer model, focusing on extracting a high-level feature matrix with generalization capability from the input image to ensure the accuracy of subsequent defect detection.

[0098] In some embodiments, based on the training image samples and the feature output layer of the network structure of the second image generation model, training the second image generation model until a trained second image generation model is obtained includes:

[0099] Extracting one or more hierarchical features of the training image sample based on the training image sample and the feature output layer of the first image generation model;

[0100] A feature superposition module based on the second image generation model superimposes one or more hierarchical features to generate a feature matrix of a first feature dimension;

[0101] A feature compression module based on the second image generation model compresses the feature matrix of the first feature dimension to generate a feature matrix of the second feature dimension;

[0102] Reconstructing the feature matrix of the second feature dimension based on the image reconstruction module to generate a reconstructed image sample;

[0103] Based on the reconstructed image samples, the training image samples and the loss function, the second image generation model is trained until a trained second image generation model is obtained.

[0104] Here, the output layer of the first image generation model includes one or more, so that one or more hierarchical features can be output. The embodiment of the present application performs forward propagation calculations on the training image samples based on the pre-trained first image generation model. Based on the feature output layer of the model, one or more hierarchical features of the training image samples can be extracted. Exemplarily, the feature output layer of the model can be used as a feature extraction module to extract one or more hierarchical features. Assuming that the output layer of the first image generation model includes layer2 and layer3, the corresponding hierarchical features include the output features corresponding to layer2 and layer3.

[0105] Here, the extracted one or more hierarchical features are input into the feature superposition module in the second image generation model, and the feature superposition module obtains a unified feature expression by fusing the feature information of each hierarchical feature or channel, and generates a feature matrix of the first feature dimension with a higher dimensional expression capability. The size of the convolution kernel of the feature superposition module here is 1x1.

[0106] Here, a feature compression module is used to reduce the dimension of the generated feature matrix of the first feature dimension to reduce the amount of calculation and storage requirements, and to extract a more compact and effective feature representation to form a feature matrix of the second feature dimension. The size of the convolution kernel of the feature compression module here is 1x1.

[0107] For example, the feature compression module uses a convolution operation with a convolution kernel size of 1x1. At each position, the 1x1 convolution performs a linear combination of all channels of the input feature map, so that the feature dimension can be changed by adjusting the number of output channels. When the goal is to compress the feature dimension to 1024, the model sets the number of output channels (i.e., the number of filters) of the 1x1 convolution layer to 1024.

[0108] Here, the feature reconstruction module will perform a dimensionality increase operation on the compressed feature matrix in order to retain as much important information as possible from the original image and generate reconstructed image samples. This reconstruction helps to preserve the key details required for image recognition or detection tasks. The convolution kernel size of the feature reconstruction module can be 1x1.

[0109] Exemplarily, the image reconstruction module mainly includes three structures: a dimension-raising structure, a feature rearrangement structure, and an activation structure. The dimension-raising structure is used for the dimension-raising operation of features to support subsequent image decoding operations; in order to reduce the number of model parameters and reduce the demand for data volume for model training, the rearrangement structure uses a feature rearrangement structure to perform feature rearrangement operations, rearrange the aforementioned dimension-raising features, and set the parameter upscale=8, which means that the feature map is increased by 8 times in both height and width. For features with input dimensions of (N, 4096, H1, W1), the output dimensions are (N, 64, 8*H1, 8*W1), where N refers to the number of image samples, 4096 refers to the number of channels, H1 is the height, and W1 is the width; the purpose of the activation structure is to linearly combine features and interact between channels. Here, the number of output channels is set to 3, corresponding to the three RGB channels, which means that this layer will eventually generate pixel intensity predictions for color images. Finally, the Sigmoid activation function is used to ensure that the output value of each pixel is between 0 and 1. This is because the sigmoid function can map continuous real values ​​to the 0-1 interval, which is necessary to generate normalized image color intensity. After this series of processing, the module finally outputs a reconstructed image, which is similar in shape to the original image, but the content is based on the feature information extracted by the previous encoding.

[0110] Here, based on the loss function, for example, the mean square error function, the difference between the reconstructed image sample and the original training image sample is calculated, and the parameters of the second image generation model are updated by continuously iterating this process until the model reaches a predetermined performance indicator or convergence state on the training set, thereby obtaining a trained second image generation model. In this way, in this model training process, only a small amount of unlabeled data samples are needed to support the model training in an unsupervised manner until a trained second image generation model is obtained.

[0111] In addition, one or more of the feature superposition module, feature compression module and feature re-module in the embodiments of the present application adopts a convolution structure with a convolution kernel size of 1x1. When updating the model parameters in the above-mentioned training process, only the convolution parameters in the convolution structure need to be updated. Moreover, since the size of the convolution kernel is small, the second image generation model needs to update fewer parameters. Therefore, the required sample size is relatively small, thereby ensuring that an accurate second image generation model can be obtained when the sample size is limited.

[0112] In some embodiments, adjusting the network structure of the trained second image generation model to generate the first feature migration model includes:

[0113] Delete the feature reconstruction module in the network structure of the second image generation model to generate the first feature migration model.

[0114] It should be noted that since the task of the first feature transfer model is to output the feature matrix of the image sample and the output image generation result of the second image generation model, it is necessary to adjust the network architecture of the second image generation model to generate the first feature transfer model.

[0115] In the embodiment of the present application, the network architecture of the second image generation model includes the feature output layer, feature superposition module, feature compression module and feature reconstruction module of the first image generation model, the feature reconstruction module of the second image generation model is deleted, and the first feature migration model is generated. The first feature migration model includes the feature output layer, feature superposition module and feature compression module of the first image generation model, so as to ensure that the first feature migration model outputs the feature matrix of the image sample.

[0116] Therefore, in the adjusted first feature migration model, the core parts from the original input to the high-level feature extraction are retained, namely the feature output layer, the feature superposition module and the feature compression module. This ensures that the model can efficiently extract meaningful features from the input image and does not require additional reconstruction process for specific detection targets, thereby adapting to the needs of feature migration.

[0117] In some embodiments, generating a second anomaly matrix based on the first anomaly matrix includes:

[0118] Obtaining each row of data of the first abnormal matrix;

[0119] A second abnormality matrix is ​​generated based on the maximum value corresponding to each row of data.

[0120] Exemplarily, assuming that the first exception matrix is ​​4096x5, each element of each row in the first exception matrix represents the exception distance between the feature vector to be detected of the image to be detected and the 5 first standard feature matrices corresponding to each row of data in the first exception matrix, retain the maximum value of the exception distance of each row as the final value of the second exception matrix, generate the second exception matrix, and the final dimension of the second exception matrix is ​​4096x1.

[0121] In this way, the second abnormal matrix retains its maximum deviation degree relative to all standard feature matrices, which helps to improve the accuracy of defect position detection and positioning and reduce the false alarm rate.

[0122] In some embodiments, determining the defect position of the image sample to be detected based on the second abnormality matrix and the abnormality distance threshold includes:

[0123] Based on the second anomaly matrix and the anomaly distance threshold, a first defect matrix is ​​generated;

[0124] The first defect matrix is ​​reorganized based on the size information of the image to be detected to generate a second defect matrix, and the second defect matrix is ​​used to characterize the defect position of the image sample to be detected.

[0125] Here, the second abnormality matrix includes one or more maximum abnormality distances. For each abnormality distance in the second abnormality matrix, it is compared with the abnormality distance threshold. If the maximum abnormality distance is greater than the abnormality distance threshold, it means that the position of the image to be detected corresponding to the maximum abnormality distance is abnormal, and the position is a defect position. The position corresponding to the abnormal distance is set to 1. If it is less than, it means that the position is normal and not a defect position, then the position corresponding to the abnormal distance of the position is set to 0, thereby generating a first defect matrix, which is used to locate the defect position of the feature matrix to be detected.

[0126] Here, since the spatial dimension of the feature matrix to be detected generated by the first feature migration model of the image to be detected is small, the first defect matrix is ​​generated based on the feature matrix, and its size is smaller than the original image size. In order to accurately reflect the defect position of the image to be detected, it is necessary to reorganize the first defect matrix based on the size information of the image to be detected to generate a second defect matrix. The second defect matrix is ​​used to characterize the defect position of the image sample to be detected.

[0127] Exemplarily, the abnormal positioning matrix expressed by the features can be expanded to the original image size by using the nearest neighbor interpolation method, thereby generating a second defect matrix. In the second defect matrix, the area corresponding to 1 is the defect area, and the others are normal areas.

[0128] In this way, the embodiment of the present application not only takes into account the abnormal information of the image in the abstract feature space, but also combines the spatial structure of the actual image, ensuring that the positioning result can accurately reflect the defect position of the original image sample and improve the accuracy of defect detection.

[0129] The present application is further described in detail below in conjunction with application examples.

[0130] This application example provides a solution for defect detection based on unsupervised feature migration, mainly proposing a feature migration strategy. For Wideresnet50 (i.e., the aforementioned first image generation model) trained on large-scale image datasets such as imagenet, the feature output layer of Wideresnet50 is retained as a feature extraction module, and by combining feature superposition, feature compression, image reconstruction and other operations, a feature extraction module in the field of industrial image data (i.e., the aforementioned first feature migration module) is obtained. Based on the feature extraction module, features of normal image data are calculated and a core feature library (i.e., the aforementioned first standard feature matrix set) is constructed. The image to be tested (i.e., the aforementioned image sample to be tested) is represented by the feature extraction module to generate a feature matrix to be tested. The distance is calculated from the core feature library to obtain an abnormal score matrix (i.e., the aforementioned first abnormal matrix), and then the final abnormal area positioning is obtained through the abnormal distance threshold.

[0131] In this application example, it is mainly divided into two stages: feature migration stage and defect detection stage.

[0132] For the feature migration stage, its implementation flow chart is as follows: Figure 3 As shown, Figure 3 The following is a flow chart of the feature migration phase. The detailed implementation steps are as follows:

[0133] Step 301: Data preparation.

[0134] In the data accuracy stage, industrial cameras and optical systems are used to shoot multiple points of industrial parts. All the image data obtained can cover the entire industrial part, and the defects in the area can be clearly photographed, such as Figure 2 This is a partial shooting point map corresponding to the wheel hub industrial parts.

[0135] On the basis of the original data, by adding changes in light intensity and angle rotation, the model's generalization to situations such as shooting point jitter and light and shadow changes is enhanced.

[0136] Step 302: Construct a feature transfer model based on the imagenet pre-trained Wideresnet50 (i.e., the aforementioned first image generation model).

[0137] Here, in the feature migration model of Wideresnet50 pre-trained by imagenet (i.e. the aforementioned first image generation model), feature superposition, feature compression, image reconstruction and other modules are added to construct a feature migration strategy model (i.e. the aforementioned second image generation model). The model structure diagram of the feature migration strategy model is as follows: Figure 4 As shown, Figure 4 It consists of four parts: A, B, C and D.

[0138] A. Feature extraction of Wideresnet50 based on imagenet pre-training.

[0139] exist Figure 4 In actual applications, the imagenet-pre-trained Wideresnet50 includes one or more feature output layers, such as feature_1, feature_2…feature_n. Exemplarily, the output features of its underlying features layer2 and layer3 are used. That is, the feature output layer of Wideresnet50 is retained, and the feature output layer of the imagenet-pre-trained Wideresnet50 is used as a feature extraction module to extract feature_1, feature_2…feature_n.

[0140] B. Feature overlay module.

[0141] For the output features of each level, the feature superposition module is used to fuse the features of each level to obtain a unified feature expression. The resize in the feature superposition module represents a bilinear interpolation operation, through which the original W*H feature map is transformed into a 2W*2H feature map. Conv1x1 represents a convolution operation with a convolution kernel size of 1x1, which is used for channel alignment of the feature matrix.

[0142] C. Feature compression module.

[0143] conv1x1 corresponds to a convolution operation with a convolution kernel size of 1x1, and the output channel (number of channels) = 1024 (the number of target channels), which is used to compress the feature dimension of each position of the feature map to 1024.

[0144] D. Image reconstruction module.

[0145] The image reconstruction module mainly includes three structures (1) dimensionality-enhancing structure conv1x1channel=4096. Conv1x1 corresponds to the convolution operation with a convolution kernel size of 1x1, and the output channel (number of channels) is 4096, which is used for feature dimensionality-enhancing operations to support subsequent image decoding operations.

[0146] (2) Rearrangement structure, PixelShuffle (pixel reorganization) upscale = 8. In order to reduce the number of model parameters and reduce the demand for data volume for model training, it is proposed to use the PixelShuffle feature reordering operation to reorder the features after the above-mentioned dimensionality increase, and set the parameter upscale = 8. For features with input dimensions of (N, 4096, H1, W1), N here refers to the number of image samples, 4096 refers to the number of channels, and H1 and W1 here are the input height and width of the image in the reordered structure. The output dimension is (N, 64, 8*H1, 8*W1).

[0147] (3) Activation structure conv1x1channel=3Sigmoid. For the rearranged output features, a convolution with a kernel size of 1x1 and 3 output channels is used, combined with Sigmoid activation to output the reconstructed image.

[0148] Step 303: training the feature transfer model obtained by training in step 302 (i.e. the aforementioned second image detection model). Specifically, it includes:

[0149] A. Perform normalization preprocessing on the input data.

[0150] B. The processed input data is forward calculated through the feature transfer model to obtain the corresponding reconstructed output image.

[0151] C. Calculate the MSE loss of the processed input image and output image.

[0152] Specifically, SGD gradient descent is used in combination with the learning rate cosine annealing decay strategy to minimize the loss of input and output images. During the gradient descent process, the Wideresnet50 parameters are frozen and only all conv1x1 convolution parameters in the model are updated.

[0153] The feature migration model in this application example adds a simple conv1x1 convolution structure and updates its parameters using the unsupervised method mentioned above, thereby migrating the features of the original imagenet data domain to the features of the industrial image data domain. The model requires fewer parameters to be updated, so only a small amount of training data is needed to complete the parameter update.

[0154] Based on the model pre-trained based on the imagenet dataset, this application example adds a simple 1x1 convolution structure and uses industrial image data and image reconstruction operations to complete the conversion from imagenet domain features to industrial image data domain features. The conversion process only requires a small amount of unlabeled industrial image data support. Compared with the method of directly using the pre-trained model, it can obtain high-level feature representations in the field of industrial image data and reduce noise data interference. For the subsequent defect detection process, it can improve generalization and reduce the false alarm rate.

[0155] Step 304: Industrial image data feature extraction module (ie, the aforementioned first feature migration model).

[0156] After the training is completed, the feature extraction module, feature superposition module, and feature compression module of the feature migration model based on the imagenet pre-training Wideresnet50 constitute the feature extraction module of the final defect detection part.

[0157] Thus, this application example proposes an industrial image defect detection method based on unsupervised feature migration, and proposes a feature migration strategy. Based on the model obtained by pre-training in a large-scale data set, a feature superposition module and a feature compression module are constructed by using a simple 1x1 convolution structure, etc., to obtain the feature expression of industrial image data, and then a simple 1x1 convolution structure, PixelShuffle feature rearrangement and image reconstruction operation are used to directly use industrial image data, and the parameters of the feature superposition module and the feature compression module are fitted and calculated by minimizing the error between the input data and the reconstructed data, so as to obtain the final industrial image data feature extraction module. In the whole process, only the 1x1 convolution structure parameters need to be trained, and the number of parameters is small. Only a small amount of unlabeled data is needed to support the feature extraction module in the field of industrial image data, obtain high-level feature expressions, reduce data noise sensitivity, and reduce defect false alarms.

[0158] like Figure 5 and Figure 6 As shown, Figure 5 and Figure 6 This is a partial test result diagram of the feature transfer model after training, where Figure 5 is the input original image of the trained feature transfer model, Figure 6 Model reconstruction graph for the trained feature transfer model.

[0159] For the defect detection stage, the implementation flow chart is as follows: Figure 7 , Figure 7 The figure is a flow chart of the defect detection phase, and the detailed implementation steps are as follows:

[0160] Step 701: constructing a core feature set (ie, the aforementioned first standard feature matrix set).

[0161] The specific implementation process is as follows: using the normal image data samples of industrial image data (i.e. the aforementioned standard image samples), based on the feature extraction module obtained in the feature migration stage (i.e. the aforementioned first feature migration model), the normal data features are obtained through forward calculation. This proposal uses an image size of 512x512 as input, and the feature extraction module will obtain a feature matrix of 64x64x1024 (number of channels), corresponding to a feature sample of 4096x1024.

[0162] The normal data feature samples (second standard feature matrix) of all normal image data are clustered and the cluster centers are obtained. The cluster center set is the final core feature set of normal data. This proposal clusters into five clusters and obtains 5 cluster centers as the core feature set of normal data.

[0163] Step 702: Defect location process, the specific implementation process is as follows:

[0164] In practical applications, the industrial image data to be tested (i.e., the aforementioned image samples to be tested) uses the feature extraction module (i.e., the aforementioned first feature migration model) to obtain feature expression through forward calculation. For a single image, the feature expression dimension obtained by this proposal is 4096x1024.

[0165] Here, the obtained test data feature matrix (i.e. the aforementioned feature matrix to be detected) and the core feature set are calculated to calculate the anomaly score matrix. This proposal uses Euclidean distance as the measurement of anomaly score. After the calculation is completed, a 4096x5 anomaly score matrix (i.e. the aforementioned first anomaly matrix) will be obtained, and the maximum value of each row will be retained as the final anomaly score matrix (i.e. the aforementioned second anomaly matrix). The final matrix dimension is 4096x1.

[0166] Set the anomaly score threshold, locate the abnormal area, set the position in the anomaly score matrix that is greater than the threshold to 1, otherwise to 0, where 1 indicates that the current position is abnormal and 0 indicates normal. Further reorganize the above matrix into the corresponding input feature map size, that is, the anomaly location matrix corresponding to the feature expression of the test image. Further, use the nearest neighbor interpolation method to expand the feature expression of the anomaly location matrix to the original image size (512x512) to obtain the final defect detection result of the test image (that is, the aforementioned second defect matrix). The area corresponding to 1 is the defect area (that is, the aforementioned defect position), and the others are normal areas. Figure 8 and Fig. 9 Some defect detection results. Figure 8 and Fig. 9 Schematic diagram of defect detection results.

[0167] The defect detection solution of this application example can be used for defect detection in industrial images. In view of the fact that industrial images are difficult to obtain, various benchmark models that have been published and pre-trained based on large-scale data sets are effectively used to complete feature migration at the lowest cost and obtain high-level feature expressions of industrial image data. Compared with directly using pre-trained models, the features extracted by this application example can more accurately represent the characteristics of the industrial field, effectively improve the subsequent defect detection effect based on feature embedding, reduce the interference of noise data, and effectively reduce model false alarms.

[0168] In order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a defect detection device, which corresponds to the above-mentioned defect detection method, and each step in the above-mentioned defect detection method embodiment is also fully applicable to the embodiment of the present defect detection device.

[0169] like Fig.10 As shown, the defect device 1000 includes: an acquisition module 1001, a generation module 1002 and a determination module 1003. The acquisition module 1001 is used to acquire an image sample to be detected; the generation module 1002 is used to generate a feature matrix to be detected of the image sample to be detected based on the image sample to be detected and the first feature migration model; based on the feature matrix to be detected and the first standard feature matrix set, a first abnormality matrix is ​​generated, the first abnormality matrix is ​​used to characterize the distance between the feature matrix to be detected and each standard feature matrix in the first standard feature matrix set, and the feature matrix set is generated based on the first feature migration model; based on the first abnormality matrix, a second abnormality matrix is ​​generated, the second abnormality matrix is ​​used to characterize the maximum abnormal distance between the feature matrix to be detected and the first standard feature matrix set; the determination module 1003 is used to determine the defect position of the image sample to be detected based on the second abnormality matrix and the abnormality distance threshold.

[0170] In some embodiments, the acquisition module 1001 is also used to acquire multiple standard image samples; the generation module 1002 is also used to generate a second standard feature matrix corresponding to each standard image sample based on each standard image sample and the first feature migration model; cluster each second standard feature matrix based on a clustering algorithm to generate a clustering result; the clustering result includes one or more clusters; based on the cluster center of one or more clusters, a first standard feature matrix set is generated.

[0171] In some embodiments, the acquisition module 1001 is also used to acquire a pre-trained first image generation model and a training image sample; the defect detection device also includes an embedding module 1004, which is used to embed a feature superposition module, a feature compression module and a feature reconstruction module into the feature output layer of the pre-trained first image generation model to generate a network structure of a second image generation model, and the second image generation model is used to output the image generation result; the defect detection device also includes a training module 1005, which is used to train the second image generation model based on the training image sample and the network structure of the second image generation model until a trained second image generation model is obtained; the defect detection device also includes an adjustment module 1006, which is used to adjust the network structure of the trained second image generation model to generate a first feature migration model, and the first feature migration model is used to output a feature matrix of the image sample.

[0172] In some embodiments, the defect detection device also includes an extraction module 1007, which is used to extract one or more hierarchical features of the training image sample based on the training image sample and the feature output layer of the first image generation model; the generation module 1002 is also used to superimpose one or more hierarchical features based on the feature superposition module of the second image generation model to generate a feature matrix of the first feature dimension; based on the feature compression module of the second image generation model, the feature matrix of the first feature dimension is compressed to generate a feature matrix of the second feature dimension; based on the image reconstruction module, the feature matrix of the second feature dimension is reconstructed to generate a reconstructed image sample; the training module 1005 is used to train the second image generation model based on the reconstructed image sample, the training image sample and the loss function until a trained second image generation model is obtained.

[0173] In some embodiments, the adjustment module 1006 is used to delete the feature reconstruction module in the network structure of the second image generation model to generate a first feature migration model.

[0174] In some embodiments, the acquisition module 1001 is further used to acquire each row of data of the first abnormal matrix; the generation module 1002 is further used to generate a second abnormal matrix based on the maximum value corresponding to each row of data.

[0175] In some embodiments, the generation module 1002 is also used to generate a first defect matrix based on the second abnormality matrix and the abnormality distance threshold; reorganize the first defect matrix based on the size information of the image to be detected to generate a second defect matrix, and the second defect matrix is ​​used to characterize the defect position of the image sample to be detected.

[0176] In actual application, the acquisition module 1001, the generation module 1002, the determination module 1003, the embedding module 1004, the training module 1005, the adjustment module 1006 and the extraction module 1007 can be implemented by a processor in an electronic device. Of course, the processor needs to run the computer program in the memory to implement its functions.

[0177] It should be noted that: the defect detection device provided in the above embodiment only uses the division of the above program modules as an example when performing defect detection. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the defect detection device provided in the above embodiment and the defect detection method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0178] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device. Fig.11 Only an exemplary structure of the electronic device is shown, not all structures, and it can be implemented as needed. Fig.11 Partial or complete structure shown.

[0179] like Fig.11 As shown, the electronic device 1100 provided in the embodiment of the present application includes: one or more processors 1101, a memory 1102, a user interface 1103 and one or more network interfaces 1104. The various components in the electronic device 1100 are coupled together through a bus system 1105. It can be understood that the bus system 1105 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 1105 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Fig.11 Various buses are labeled as bus system 1105.

[0180] The user interface 1103 may include a display, a keyboard, a mouse, a trackball, a click wheel, keys, buttons, a touch pad or a touch screen.

[0181] The memory 1102 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0182] The defect detection method disclosed in the embodiment of the present application can be applied to the processor 1101, or implemented by the processor 1101. The processor 1101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the defect detection method can be completed by the hardware integrated logic circuit or software instructions in the processor 1101. The above-mentioned processor 1101 can be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 1101 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiment of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 1102. The processor 1101 reads the information in the memory 1102 and completes the steps of the defect detection method provided in the embodiment of the present application in combination with its hardware.

[0183] In an exemplary embodiment, the electronic device may be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.

[0184] It can be understood that the memory 1102 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memories described in the embodiments of the present application are intended to include, but are not limited to, these and any other suitable types of memories.

[0185] In an exemplary embodiment, the present application also provides a computer storage medium, which can be a computer-readable storage medium, for example, a memory 1102 storing a computer program, and the computer program can be executed by a processor 1101 of an electronic device to complete the steps of the method of the present application. The computer-readable storage medium can be a memory such as a ROM, a PROM, an EPROM, an EEPROM, a Flash Memory, a magnetic surface memory, an optical disk, or a CD-ROM.

[0186] Illustratively, an embodiment of the present application further provides a computer program product, including a computer program, which can be executed by the processor 1101 of the electronic device 1100 to complete any of the aforementioned method steps.

[0187] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0188] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.

[0189] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A defect detection method, characterized in that: The method comprises: Obtain an image sample to be detected; Based on the image sample to be detected and the first feature migration model, generating a feature matrix to be detected of the image sample to be detected; Based on the feature matrix to be detected and the first standard feature matrix set, a first abnormality matrix is ​​generated, wherein the first abnormality matrix is ​​used to characterize the abnormal distance between the feature matrix to be detected and each standard feature matrix in the first standard feature matrix set, and the first standard feature matrix set is generated based on the first feature migration model; Based on the first abnormal matrix, a second abnormal matrix is ​​generated, where the second abnormal matrix is ​​used to represent the maximum abnormal distance between the feature matrix to be detected and the first standard feature matrix set; Based on the second abnormality matrix and the abnormality distance threshold, the defect position of the image sample to be detected is determined.

2. The defect detection method according to claim 1, characterized in that: The method comprises: Acquire multiple standard image samples; Based on each of the standard image samples and the first feature migration model, generating a second standard feature matrix corresponding to each of the standard image samples; Clustering each of the second standard feature matrices based on a clustering algorithm to generate a clustering result, wherein the clustering result includes one or more clusters; The first standard feature matrix set is generated based on cluster centers of the one or more clusters.

3. The defect detection method according to claim 1, characterized in that: The method further comprises: Obtaining a pre-trained first image generation model and a training image sample; Embedding a feature superposition module, a feature compression module, and a feature reconstruction module into the feature output layer of the pre-trained first image generation model to generate a network structure of a second image generation model, wherein the second image generation model is used to output an image generation result; Based on the training image samples and the network structure of the second image generation model, training the second image generation model until a trained second image generation model is obtained; The network structure of the trained second image generation model is adjusted to generate the first feature migration model, where the first feature migration model is used to output a feature matrix of the image sample.

4. The defect detection method according to claim 3, characterized in that: The step of training the second image generation model based on the training image sample and the network structure of the second image generation model until a trained second image generation model is obtained comprises: Extracting one or more hierarchical features of the training image sample based on the training image sample and the feature output layer of the first image generation model; The feature superposition module based on the second image generation model superimposes the one or more hierarchical features to generate a feature matrix of a first feature dimension; The feature compression module based on the second image generation model compresses the feature matrix of the first feature dimension to generate a feature matrix of the second feature dimension; Reconstructing the feature matrix of the second feature dimension based on the image reconstruction module to generate a reconstructed image sample; Based on the reconstructed image samples, the training image samples and the loss function, the second image generation model is trained until a trained second image generation model is obtained.

5. The defect detection method according to claim 3, characterized in that: The step of adjusting the network structure of the trained second image generation model to generate the first feature migration model includes: Delete the feature reconstruction module in the network structure of the second image generation model to generate the first feature migration model.

6. The defect detection method according to claim 1, characterized in that: The step of generating a second abnormality matrix based on the first abnormality matrix comprises: Obtaining each row of data of the first abnormal matrix; The second abnormality matrix is ​​generated based on the maximum values ​​corresponding to each row of data.

7. The defect detection method according to claim 1, characterized in that: The step of determining the defect position of the image sample to be detected based on the second abnormality matrix and the abnormality distance threshold comprises: Based on the second anomaly matrix and the anomaly distance threshold, generating a first defect matrix; The first defect matrix is ​​reorganized based on the size information of the image to be detected to generate a second defect matrix, where the second defect matrix is ​​used to characterize the defect positions of the image sample to be detected.

8. A defect detection device, characterized in that: The defect detection device comprises: An acquisition module, used for acquiring an image sample to be detected; A generation module, configured to generate a feature matrix to be detected of the image sample to be detected based on the image sample to be detected and the first feature migration model; generate a first abnormality matrix based on the feature matrix to be detected and the first standard feature matrix set, wherein the first abnormality matrix is ​​used to characterize the distance between the feature matrix to be detected and each standard feature matrix in the first standard feature matrix set, wherein the feature matrix set is generated based on the first feature migration model; generate a second abnormality matrix based on the first abnormality matrix, wherein the second abnormality matrix is ​​used to characterize the maximum abnormal distance between the feature matrix to be detected and the first standard feature matrix set; A determination module is used to determine the defect position of the image sample to be detected based on the second abnormality matrix and the abnormality distance threshold.

9. An electronic device, characterized in that: include: A processor and a memory for storing a computer program that can be executed on the processor, wherein: The processor is used to execute the steps of the method according to any one of claims 1 to 7 when running a computer program.

10. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Large model-based DC professional converter valve equipment image detection method, apparatus and device, and storage medium

    CN119205791A