Defect detection method and device based on feature symmetry compression and electronic equipment
Patent Information
- Application Number
- CN202311327307.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-13
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-10-13
AI Technical Summary
[0025]本发明的有益效果:本发明利用无缺陷图像特征关于零点的对称性来剔除冗余信息,避免了对特征间距离的迭代计算,解决现有技术特征压缩效率低的问题;本发明不需要对不同特征层进行上采样,从而节约了内存消耗以及检测推理时间,解决了现有技术缺陷检测速度慢的问题。
Smart Images

Figure CN117372364B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image defect detection technology, and in particular to defect detection methods, apparatus and electronic devices based on feature symmetry compression. Background Technology
[0002] Product image defect detection is a crucial area in intelligent manufacturing. The defect detection process primarily utilizes artificial intelligence technology to detect and locate defects such as scratches, cracks, and foreign objects in product images. Since defective products are relatively rare in actual production and are difficult to collect and label, unsupervised defect detection methods are commonly used. Unsupervised defect detection can be further divided into reconstruction-based methods and representation-based methods. Among these, representation-based methods utilize pre-trained neural networks to extract feature representations from images, resulting in higher accuracy. Representation-based methods generally assume, to some extent, that features follow a normal distribution. Representative works include "Padim: a patch distribution modeling framework for anomaly detection and localization" (PaDiM) published at ICPR in 2021 by Thomas Defard, Aleksandr Setkov, Angelique Loesch, and Romaric Audigier; "Towards Total Recall in Industrial Anomaly Detection" (PatchCore) published at CVPR in 2022 by Karsten Roth, Latha Pemula, and Joaquin Zepeda; "Industrial Image Anomaly Localization Based on Gaussian Clustering of Pre-trained Feature" (GCPF) published at IEEE TIE in 2021 by Qian Wan, Liang Gao, Xinyu Li, and Long Wen; and Chinese patent CN202210419979.0, etc.
[0003] However, these methods and their variants all suffer from two problems. The first is that, because the extracted image features contain a large amount of redundant information, these features need to be compressed and reduced in dimensionality. Existing techniques for removing redundant information either require iterative calculation of the distances between different features, such as PatchCore, GCPF, and CN202210419979.0 mentioned earlier, which leads to excessive processing time when there are many normal sample images; or they use purely random removal, such as PaDiM mentioned earlier, which results in unstable performance. The second problem is that different feature layers have inconsistent sizes. Existing techniques upsample all feature layers to the size of the largest feature layer, which increases memory usage and slows down detection speed. Summary of the Invention
[0004] The technical problem solved by the present invention: The present invention provides a defect detection method, device and electronic device based on feature compression, which solves the problems of low feature compression efficiency and slow image defect detection speed in the prior art.
[0005] The technical solution adopted by this invention to solve the above-mentioned technical problems is a defect detection method based on feature symmetry compression, comprising the following steps:
[0006] Step a: Input the defect-free images from the defect-free image set into the pre-trained ResNet-like network to obtain M feature layers, where M is a set positive integer and is not greater than the number of convolutional block layers of the ResNet-like network. The M feature layers correspond one-to-one with the outputs of the M convolutional block layers of the ResNet-like network.
[0007] Step b: For each channel at each location in each feature layer, count the number of element values greater than zero in each channel of the feature layer along the dimension of the defect-free image set, and select the top K channels with the largest number of values. m One channel is removed, the K m Let m be a set positive integer, where m is the feature layer number, 1≤m≤M, to obtain the effective channels at each position of each feature layer;
[0008] Step c: Divide the first M-1 feature layers into small feature blocks, connect the effective channels of each feature block after the division of each feature layer, and connect them with the effective channels of the corresponding positions of the next feature layer, until they are connected with the effective channels of the Mth feature layer, to obtain the effective feature set of the defect-free image set.
[0009] Step d: Input the image to be detected into the pre-trained ResNet-like network, extract the effective features of the image to be detected using step c, and calculate the distance between the effective features and the effective feature set of the defect-free image set. Based on the distance, determine whether the image to be detected has defects and the specific location of the defects.
[0010] Furthermore, in step a, the pre-trained ResNet-like network is one of ResNet-18, ResNet-34, ResNet-50, ResNet-101, ResNet-152, WideResnet-50, and WideResnet-101, containing four convolutional block layers, with the output of each convolutional block layer being a feature layer.
[0011] Furthermore, in step a, the size of the m-th feature layer is (R m C m The number of channels is L. m The relationship between adjacent feature layers is R. m =a*R m+1 C m =b*C m+1 The range of values for m is 1 ≤ m ≤ M.
[0012] Furthermore, step b specifically includes the following steps:
[0013] b1. For the (r,c) position of the m-th feature layer in the i-th defect-free image, i.e., at the r-th row and c-th column, determine the element value l of the l-th channel. im If (r,c) is greater than zero, then the count F[l] of the l-th channel is... im If (r,c)] is 1, otherwise count F[l] im [r,c] is set to 0, where 1≤r≤R m 1≤c≤C m , 1≤i≤S, 1≤m≤M, 1≤l≤L m S is the number of defect-free images contained in the defect-free image set;
[0014] b2. Count F[l] of the l-th channel at the m-th feature layer (r,c) of all defect-free images. im Add (r,c) together to get the total count.
[0015] b3. Place L at the m-th feature layer (r, c) m Total count of channels Arrange from largest to smallest, the first K m The channels corresponding to the total counts are redundant information channels and are deleted. The remaining L... m -K m Each channel is a valid channel at the m-th feature layer (r, c);
[0016] b4. Perform b1-b3 on all positions of all feature layers to obtain the effective channels for each position of each feature layer.
[0017] Furthermore, step c specifically includes the following steps:
[0018] c1. Divide the m-th feature layer evenly into R... m+1 ×C m+1 A feature block, (R) m+1 C m+1 Let (a, b) be the size of the next feature layer, and let (a, b) be the size of each feature block. The position of the feature block in row r′ and column c′ is denoted as (r′, c′), where 1 ≤ r′ ≤ R. m+1 , 1≤c′≤C m+1 The position (r′, c′) of the feature block corresponds one-to-one with the position in the r′ row and c′ column of the next feature layer. Then, all effective channels of the feature block located at (r′, c′) are connected to obtain the number of effective channels of the feature block at (r′, c′) as (a*b)*(L). m -K m ), L m -K m For the effective number of channels at each position of the m-th feature layer, the (a*b)*(L) m -K m Connect the effective channels of the m-th feature layer to the effective channels at the r′-th row and c′-th column of the next feature layer. Traverse each feature block and connect the effective channels of each feature block of the m-th feature layer to the effective channels at the corresponding positions of the next feature layer.
[0019] c2. Perform c1 on the first M-1 feature layers, connecting the effective channels at each corresponding position of the M feature layers together to obtain a size of (R). M C M The number of channels is The effective features, of which (R) M C M ) represents the size of the Mth feature layer;
[0020] c3. For each defect-free image in the defect-free image set, perform c1-c2 to obtain S images of size (R). M C M The number of channels is The effective features are used to form the effective feature set; S is the number of defect-free images contained in the defect-free image set.
[0021] Furthermore, in step d, the distance is the Mahalanobis distance, and the formula for calculating the Mahalanobis distance is: Where (r”, c”) represents the position of the effective feature in the r”th row and c”th column, 1≤r”≤R M ,1≤c≤C M , (R M CM ) represents the size of the effective feature, x (r”,c”) The value of the effective feature of the image to be detected at (r”, c”) is a variable of length . The row vector, μ (r”,c”) Let represent the sample mean of the effective feature set of the defect-free image set at (r”, c”). The inverse of the sample variance of the effective feature set of the defect-free image set at (r”, c”), (x (r”,c”) -μ (r”,c”) ) T It means (x) (r”,c”) -μ (r”,c”) The transpose of ); the sample mean of the effective feature set of the defect-free image set at (r”, c”). The sample variance of the effective feature set of the defect-free image set at (r”, c”) Where S represents the number of defect-free images, e (r”,c”) (i) represents the value of the effective feature of the i-th defect-free image at (r”, c”), which is a string of length . A row vector, 1≤i≤S, where I represents (R M C M A Mahalanobis distance matrix is obtained by calculating the Mahalanobis distance at each location of a valid feature using an identity matrix of size 1.
[0022] Furthermore, in step d, determining whether the image to be inspected has defects and the specific location of the defects based on distance includes: using the Mahalanobis distance matrix... Linear interpolation is performed to the size of the image to be inspected, and a detection threshold is set for each position in the image to be inspected. Regions with a Mahalanobis distance matrix greater than the detection threshold are considered defective regions, while regions with a distance not greater than the detection threshold are considered normal regions.
[0023] The defect detection device based on feature compression, applied to the aforementioned defect detection method based on feature compression, includes a feature extraction module, a feature compression module, a channel connection module, and a defect judgment module. The feature extraction module is used to extract features from a set of defect-free images. The feature compression module is used to remove redundant information in the feature layers. The channel connection module is used to connect the effective channels of different feature layers to obtain an effective feature set. The defect judgment module is used to calculate the distance between the effective features of the image to be detected and the effective feature set of the set of defect-free images, and then determine whether there is a defect in the image to be detected and the specific location of the defect based on the distance.
[0024] The defect detection electronic device based on feature compression includes a computer-readable storage medium, a processor, a communication interface, and a communication bus; the communication bus enables communication between the processor and the computer-readable storage medium through the communication interface, and the computer-readable storage medium is used to store instructions; the processor is used to invoke the instructions to execute the defect detection method based on feature symmetry compression as described in any one of claims 1-7.
[0025] The beneficial effects of this invention are as follows: This invention utilizes the symmetry of defect-free image features about zero points to eliminate redundant information, avoiding iterative calculation of distances between features and solving the problem of low feature compression efficiency in existing technologies; This invention does not require upsampling of different feature layers, thereby saving memory consumption and detection inference time, and solving the problem of slow defect detection speed in existing technologies. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating the defect detection method based on feature compression in this invention.
[0027] Figure 2 This is an example of the m-th feature layer in this invention, with a size of (4, 4) and a channel count of 3;
[0028] Figure 3 This is an example of the (m+1)th feature layer in this invention, with a size of (2, 2) and 2 channels;
[0029] Figure 4 This is an example of the m-th feature layer after removing redundant channels in this invention, with 2 remaining effective channels;
[0030] Figure 5 This is an example of the (m+1)th feature layer after removing redundant channels in this invention, with the remaining number of effective channels being 1.
[0031] Figure 6 This is an example of the feature block in the first row and first column after the mth feature layer is divided into 2×2=4 feature blocks in this invention. The size of each feature block is (2, 2).
[0032] Figure 7 This is an example of connecting all the valid channels of the feature blocks in the first row and first column in this invention;
[0033] Figure 8 This is an example of the present invention where all the effective channels of the feature blocks in the first row and first column are connected together and then connected to the effective channels at the corresponding positions of the (m+1)th feature layer.
[0034] Where 1-98 represent the values of the elements. Detailed Implementation
[0035] This invention provides a defect detection method based on feature symmetry compression, such as... Figure 1 The above includes the following steps:
[0036] Step a: Input the defect-free images from the defect-free image set into the pre-trained ResNet-like network to obtain M feature layers, where M is a set positive integer and is not greater than the number of convolutional block layers of the ResNet-like network. The M feature layers correspond one-to-one with the outputs of the M convolutional block layers of the ResNet-like network.
[0037] Specifically, the pre-trained ResNet-like network is one of ResNet-18, ResNet-34, ResNet-50, ResNet-101, ResNet-152, WideResNet-50, and WideResNet-101. For a ResNet-like network, it typically includes four convolutional layers. When extracting features, the outputs of the first three convolutional layers or the outputs of the second and third convolutional layers are used. The size of the m-th feature layer is (R... m C m The number of channels is L. m The relationship between adjacent feature layers is R. m =a*R m+1 C m =b*C m+1 The value of m ranges from 1 to m to M. For example, if ResNet-18 is used as the output of the ResNet-like network and the first three convolutional blocks to extract features, then an image can obtain three feature layers: the first feature layer has a size of (56, 56) and 64 channels; the second feature layer has a size of (28, 28) and 128 channels; and the third feature layer has a size of (14, 14) and 256 channels.
[0038] Step b: For each channel at each location in each feature layer, count the number of element values greater than zero in each channel of the feature layer along the dimension of the defect-free image set, and select the top K channels with the largest number of values. m One channel is removed, the K m Let m be a set positive integer, where m is the feature layer number, 1≤m≤M, to obtain the effective channels at each position of each feature layer;
[0039] Specifically, step b includes the following steps:
[0040] b1. For the (r,c) position of the m-th feature layer in the i-th defect-free image, i.e., at the r-th row and c-th column, determine the element value l of the l-th channel. im If (r,c) is greater than zero, then the count F[l] of the l-th channel is... imIf (r,c)] is 1, otherwise count F[l] im [r,c] is set to 0, where 1≤r≤R m 1≤c≤C m , 1≤i≤S, 1≤m≤M, 1≤l≤L m S is the number of defect-free images contained in the defect-free image set;
[0041] b2. Count F[l] of the l-th channel at the m-th feature layer (r,c) of all defect-free images. im Add (r,c) together to get the total count.
[0042] b3. Place L at the m-th feature layer (r, c) m Total count of channels Arrange from largest to smallest, the first K m The channels corresponding to the total counts are redundant information channels and are deleted. The remaining L... m -K m Each channel is a valid channel at the m-th feature layer (r, c);
[0043] Specifically,
[0044] b4. Perform b1-b3 on all positions of all feature layers to obtain the effective channels for each position of each feature layer.
[0045] Specifically, the activation function used by ResNet-like networks sets the pre-activation values of feature layers that are less than or equal to zero to zero, while keeping the pre-activation values of feature layers that are greater than zero unchanged. Therefore, a count of 1 indicates that the pre-activation value of that channel is greater than zero. The L value at (r,c) of the m-th feature layer of all defect-free images is then used. m The counts of each channel are added together, and the top K results are the largest. m One channel is deleted for redundant information. This is because the pre-activation values of features extracted by a pre-trained ResNet-like network from a defect-free image set usually follow a normal distribution with a zero mean, and are therefore symmetrical about the zero point. That is, the number of values greater than zero and less than zero is not much different. Therefore, if most of the pre-activation values of a certain channel are greater than zero, it means that the channel is distorted by redundant information, and thus the channel is removed.
[0046] This invention utilizes the symmetry of defect-free image features about zero points to eliminate redundant information, avoiding iterative calculation of distances between features. Even if there are 10,000 defect-free normal sample images, this invention can quickly perform feature compression, while existing technologies require iterative calculations of 10,000 × 10,000 times, resulting in low feature compression efficiency.
[0047] For example, using ResNet-18 as the output of the ResNet-like network and the first three convolutional block layers to extract features, when extracting features from 320 defect-free images, the first feature layer removes 58 redundant information channels and retains 6 effective channels, the second feature layer removes 110 redundant information channels and retains 18 effective channels, and the third feature layer removes 196 redundant information channels and retains 60 effective channels.
[0048] Step c: Divide the first M-1 feature layers into small feature blocks, connect the effective channels of each feature block after the division of each feature layer, and connect them with the effective channels of the corresponding positions of the next feature layer, until they are connected with the effective channels of the Mth feature layer, to obtain the effective feature set of the defect-free image set.
[0049] Specifically, step c includes the following steps:
[0050] c1. Divide the m-th feature layer evenly into R... m+1 ×C m+1 A feature block, (R) m+1 C m+1 Let (a, b) be the size of the next feature layer, and let (a, b) be the size of each feature block. The position of the feature block in row r′ and column c′ is denoted as (r′, c′), where 1 ≤ r′ ≤ R. m+1 , 1≤c′≤C m+1 The position (r′, c′) of the feature block corresponds one-to-one with the position in the r′ row and c′ column of the next feature layer. Then, all effective channels of the feature block located at (r′, c′) are connected to obtain the number of effective channels of the feature block at (r′, c′) as (a*b)*(L). m -K m ), L m -K m For the effective number of channels at each position of the m-th feature layer, the (a*b)*(L) m -K m Connect the effective channels of the m-th feature layer to the effective channels at the r′-th row and c′-th column of the next feature layer. Traverse each feature block and connect the effective channels of each feature block of the m-th feature layer to the effective channels at the corresponding positions of the next feature layer.
[0051] c2. Perform c1 on the first M-1 feature layers, connecting the effective channels at each corresponding position of the M feature layers together to obtain a size of (R). M C M The number of channels is The effective features, of which (R) M C M ) represents the size of the Mth feature layer;
[0052] c3. For each defect-free image in the defect-free image set, perform c1-c2 to obtain S images of size (R). M C M The number of channels is The effective features are used to form the effective feature set; S is the number of defect-free images contained in the defect-free image set.
[0053] Existing technologies upsample all feature layers to the size of the largest feature layer, which increases memory usage and slows down detection speed. This invention eliminates the need for upsampling different feature layers, thus saving memory consumption and detection inference time, and solving the problem of slow detection speed inherent in existing technologies.
[0054] For example, the m-th feature layer is as follows Figure 2 As shown, the size is (4, 4), the number of channels is 3, and each number represents the element value of the channel at that position. For example, 18 represents the element value of the second channel in the first row and second column. The value at each position can be seen as a vector of length 3. For example, the value at the third row and fourth column is [12, 28, 44]. The next feature layer, i.e., the (m+1)th feature layer, is as follows: Figure 3 As shown, the size is (2, 2), and the number of channels is 2; after removing redundant channels from the m-th feature layer, it is as follows: Figure 4 As shown, the remaining effective number of channels is 2; after removing redundant channels in the (m+1)th feature layer, as shown... Figure 5 As shown, the remaining effective channel count is 1; the m-th feature layer is divided into 2×2=4 feature blocks, each feature block having a size of (2, 2), and the feature block in the first row and first column is as follows. Figure 6 As shown, its corresponding position in the next feature layer is also the first row and first column, with an element value of 91; after connecting all the valid channels of the feature block in the first row and first column, as shown... Figure 7 As shown, and connected to the effective channel at the corresponding position of the (m+1)th stratum, as follows: Figure 8 As shown, the effective channels of each feature block in the m-th feature layer are connected to the corresponding effective channels in the next feature layer. For the first M-1 feature layers, the channels are connected in the above manner to obtain effective features. For each defect-free image, one effective feature can be obtained in the above manner. S defect-free images can obtain S effective features, forming an effective feature set.
[0055] Specifically, taking ResNet-18 as an example, the first feature layer has a size of (56, 56). This first feature layer is then evenly divided into 28×28 (28×28 is the size of the second feature layer) feature blocks, resulting in a size of (2, 2) for each feature block. Each feature block is connected to the corresponding position in the second feature layer via 6 effective channels, adding 4×6 = 24 channels to the second feature layer, making the effective channel count 4×6 + 18 = 42. Similarly, the second feature layer is evenly divided into 14×14 feature blocks, each also with a size of (2, 2). These blocks are then connected to the corresponding positions in the third feature layer via 42 effective channels, making the effective channel count 42×4 + 60 = 228 for the third feature layer, which is the smallest feature layer. Using 320 defect-free images as an example, ResNet18 can yield an effective feature set consisting of 320 effective features of size (14, 14) and 228 channels.
[0056] Step d: Input the image to be detected into the pre-trained ResNet-like network, extract the effective features of the image to be detected using step c, and calculate the distance between the effective features and the effective feature set of the defect-free image set. Based on the distance, determine whether the image to be detected has defects and the specific location of the defects.
[0057] Specifically, the distance can be the Mahalanobis distance, and the formula for calculating the Mahalanobis distance is: Where (r”, c”) represents the position of the effective feature in the r”th row and c”th column, 1≤r”≤R M ,1≤c≤C M , (R M C M ) represents the size of the effective feature, x (r”,c”) The value of the effective feature of the image to be detected at (r”, c”) is a variable of length . The row vector, μ (r”,c”) Let represent the sample mean of the effective feature set of the defect-free image set at (r”, c”). The inverse of the sample variance of the effective feature set of the defect-free image set at (r”, c”), (x (r”,c”) -μ (r”,c”) ) T It means (x) (r”,c”) -μ (r”,c”) The transpose of ); the sample mean of the effective feature set of the defect-free image set at (r”, c”). The sample variance of the effective feature set of the defect-free image set at (r”, c”) Where S represents the number of defect-free images, e (r”,c”)(i) represents the value of the effective feature of the i-th defect-free image at (r”, c”), which is a string of length . A row vector, 1≤i≤S, where I represents (R M C M A Mahalanobis distance matrix is obtained by calculating the Mahalanobis distance at each location of a valid feature using an identity matrix of size 1. The Mahalanobis distance matrix Linear interpolation is performed to the size of the image to be inspected, and a detection threshold is set for each position in the image to be inspected. Regions with a Mahalanobis distance matrix greater than the detection threshold are considered defective regions, while regions with a distance not greater than the detection threshold are considered normal regions.
[0058] This invention also provides a defect detection device based on feature compression, applied to the aforementioned defect detection method based on feature compression, comprising a feature extraction module, a feature compression module, a channel connection module, and a defect judgment module; the feature extraction module is used to extract features from a set of defect-free images; the feature compression module is used to remove redundant information in the feature layers; the channel connection module is used to connect the effective channels of different feature layers to obtain an effective feature set; the defect judgment module is used to calculate the distance between the effective features of the image to be detected and the effective feature set of the set of defect-free images, and then determine whether the image to be detected has a defect and the specific location of the defect based on the distance.
[0059] The present invention also provides a defect detection electronic device based on feature compression, comprising a computer-readable storage medium, a processor, a communication interface, and a communication bus; the communication bus enables communication between the processor and the computer-readable storage medium through the communication interface, the computer-readable storage medium being used to store instructions; the processor being used to invoke the instructions to execute the aforementioned defect detection method based on feature symmetry compression.
Claims
1. A defect detection method based on feature symmetry compression, characterized in that, Includes the following steps: Step a: Input the defect-free images from the defect-free image set into the pre-trained ResNet-like network to obtain M feature layers, where M is a set positive integer and is not greater than the number of convolutional block layers of the ResNet-like network. The M feature layers correspond one-to-one with the outputs of the M convolutional block layers of the ResNet-like network. Step b: For each channel at each location in each feature layer, count the number of element values greater than zero in each channel of the feature layer along the dimension of the defect-free image set, and select the top K channels with the largest number of values. m One channel is removed, the K m Let m be a set positive integer, where m is the feature layer number, 1≤m≤M, to obtain the effective channels at each position of each feature layer; Step c: Divide the first M-1 feature layers into small feature blocks, connect the effective channels of each feature block after the division of each feature layer, and connect them with the effective channels of the corresponding positions of the next feature layer, until they are connected with the effective channels of the Mth feature layer, to obtain the effective feature set of the defect-free image set. Step d: Input the image to be detected into the pre-trained ResNet-like network, extract the effective features of the image to be detected using step c, and calculate the distance between the effective features and the effective feature set of the defect-free image set. Based on the distance, determine whether the image to be detected has defects and the specific location of the defects.
2. The defect detection method based on feature symmetry compression according to claim 1, characterized in that, In step a, the pre-trained ResNet-like network is one of ResNet-18, ResNet-34, ResNet-50, ResNet-101, ResNet-152, WideResnet-50, and WideResnet-101, containing four convolutional block layers, with the output of each convolutional block layer being a feature layer.
3. The defect detection method based on feature symmetry compression according to claim 1, characterized in that, In step a, the size of the m-th feature layer is (R m C m The number of channels is L. m The relationship between adjacent feature layers is R. m =a*R m+1 C m =b*C m+1 The range of values for m is 1 ≤ m ≤ M.
4. The defect detection method based on feature symmetry compression according to claim 3, characterized in that, Step b specifically includes the following steps: b1. For the (r, c) position of the m-th feature layer in the i-th defect-free image, i.e., at the r-th row and c-th column, determine the element value l of the l-th channel. im If (r, c) is greater than zero, then the count F[l] of the l-th channel is... im [r, c] is set to 1, otherwise count F[l] im [r, c)] is set to 0, where 1 ≤ r ≤ R m 1≤c≤C m , 1≤i≤S, 1≤m≤M, 1≤l≤L m S is the number of defect-free images contained in the defect-free image set; b2. Count F[l] of the l-th channel at the m-th feature layer (r, c) of all defect-free images. im Adding (r, c) together gives the total count. b3. Place the L at the m-th feature layer (r, c) m Total count of channels Arranged from largest to smallest, the channels corresponding to the first Km total counts are redundant information channels and are deleted. The remaining L... m -K m Each channel is an effective channel at the m-th feature layer (r, c); b4. Perform b1-b3 on all positions of all feature layers to obtain the effective channels for each position of each feature layer.
5. The defect detection method based on feature symmetry compression according to claim 4, characterized in that, Step c specifically includes the following steps: c1. Divide the m-th feature layer evenly into R... m+1 ×C m+1 A feature block, (R) m+1 C m+1 Let (a, b) be the size of the next feature layer, and let (a, b) be the size of each feature block. The position of the feature block in row r′ and column c′ is denoted as (r′, c′), where 1 ≤ r′ ≤ R. m+1 , 1≤c′≤C m+1 The position (r′, c′) of the feature block corresponds one-to-one with the position in the r′ row and c′ column of the next feature layer. Then, all effective channels of the feature block located at (r′, c′) are connected to obtain the number of effective channels of the feature block at (r′, c′) as (a*b)*(L). m -K m ), L m -K m For the effective number of channels at each position of the m-th feature layer, the (a*b)*(L) m -K m Connect the effective channels of the m-th feature layer to the effective channels at the r′-th row and c′-th column of the next feature layer. Traverse each feature block and connect the effective channels of each feature block of the m-th feature layer to the effective channels at the corresponding positions of the next feature layer. c2. Perform c1 on the first M-1 feature layers, connecting the effective channels at each corresponding position of the M feature layers together to obtain a size of (R). M C M The number of channels is The effective features, of which (R) M C M ) represents the size of the Mth feature layer; c3. For each defect-free image in the defect-free image set, perform c1-c2 to obtain S images of size (R). M C M The number of channels is The effective features are used to form the effective feature set; S is the number of defect-free images contained in the defect-free image set.
6. The defect detection method based on feature symmetry compression according to claim 5, characterized in that, In step d, the distance is the Mahalanobis distance, and the formula for calculating the Mahalanobis distance is: Where (r″, c″) represents the position of the effective feature in the r″-th row and c″-th column, 1≤r″≤R M , 1≤c″≤C M , (R M C M Let be the size of the effective features, and let x(r″, c″) represent the value of the effective features of the image to be detected at (r″, c″), which is a variable of length . The row vector, μ (r″,c″) Let represent the sample mean of the effective feature set of the defect-free image set at (r″, c″). The inverse of the sample variance of the effective feature set of the defect-free image set at (r″, c″), (x (r″,c″) -μ (r″,c″) ) T It means (x) (r″,c″) -μ (r″,c″) The transpose of ); the sample mean of the effective feature set of the defect-free image set at (r″, c″). The sample variance of the effective feature set of the defect-free image set at (r″, c″) Where S represents the number of defect-free images, e (r″,c″) (i) represents the value of the effective feature of the i-th defect-free image at (r″, c″), which is a variable of length . A row vector, 1≤i≤S, where I represents (R M C M A Mahalanobis distance matrix is obtained by calculating the Mahalanobis distance at each location of a valid feature using an identity matrix of size 1.
7. The defect detection method based on feature symmetry compression according to claim 6, characterized in that, In step d, determining whether the image to be inspected has defects and the specific location of the defects based on distance includes: using the Mahalanobis distance matrix... Linear interpolation is performed to the size of the image to be inspected, and a detection threshold is set for each position in the image to be inspected. Regions with a Mahalanobis distance matrix greater than the detection threshold are considered defective regions, while regions with a distance not greater than the detection threshold are considered normal regions.
8. A defect detection device based on feature symmetry compression, applied to the defect detection method based on feature symmetry compression as described in any one of claims 1-7, characterized in that, It includes a feature extraction module, a feature compression module, a channel connection module, and a defect judgment module; the feature extraction module is used to extract features from a set of defect-free images; the feature compression module is used to remove redundant information in the feature layers; the channel connection module is used to connect the effective channels of different feature layers to obtain an effective feature set; the defect judgment module is used to calculate the distance between the effective features of the image to be detected and the effective feature set of the set of defect-free images, and then determine whether there is a defect in the image to be detected and the specific location of the defect based on the distance.
9. A defect detection electronic device based on feature symmetry compression, characterized in that, The device includes a computer-readable storage medium, a processor, a communication interface, and a communication bus; the communication bus enables communication between the processor and the computer-readable storage medium via the communication interface, and the computer-readable storage medium is used to store instructions; the processor is used to invoke the instructions to execute the defect detection method based on feature symmetry compression as described in any one of claims 1-7.
Citation Information
Patent Citations
Unsupervised defect detection method based on deep learning feature correlation
CN114862772A
Defect detection method and device based on image reconstruction and feature extraction
CN117408990A