Transform detection method of industrial defect images based on cost capacity function

By using a cost-capacity function and a displacement field generated by a multi-backbone network, the problem of high false alarm rate caused by image misalignment in industrial defect detection is solved, achieving higher accuracy and robustness in defect identification.

CN121437504BActive Publication Date: 2026-03-27苏州深视信息科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-29
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing technologies suffer from high false alarm rates in industrial defect detection due to image misalignment, especially in areas with repetitive textures or sparse features where registration fails, affecting the stability and reliability of the detection system.

Method used

A cost-capacity function-based approach is adopted to generate templates and scene feature maps through a multi-backbone network. Deformable convolution adjustment is performed using the predicted offset field, and a displacement field is generated by combining the dynamic search range and temperature coefficient. The discriminant module is decoupled to identify potential defect components, thereby reducing mismatches and improving accuracy.

Benefits of technology

It effectively reduces positional deviations caused by equipment vibration, installation offset, or optical distortion, improves the accuracy and robustness of defect identification, overcomes the matching failure problem in areas with repetitive textures or sparse features, and enhances the stability and reliability of the detection system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121437504B_ABST
    Figure CN121437504B_ABST
Patent Text Reader

Abstract

The application provides a transformation detection method for industrial defect images based on a cost capacity function, and relates to industrial defect image detection, and comprises the following steps: performing offset prediction on two deep feature maps to obtain a predicted offset field with an offset vector of each position point, generating a dynamic temperature coefficient according to the two deep feature maps, and combining a cost value matrix and the predicted offset field to generate a displacement field, transforming and aligning a template feature map to the scene feature map according to the displacement field to obtain a template alignment map; calculating a difference value of each position point, and if the difference value is greater than a preset defect threshold, it is determined as a defect. By using the above method, macro information provided by the predicted offset field and micro information reflected by the cost value matrix are fused. The generated displacement field can not only conform to the overall deformation model, but also accurately fit the detailed features of the local image, and the image alignment with extremely high robustness is realized in a complex industrial scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to industrial defect image detection, specifically a transformation detection method for industrial defect images based on a cost-capacity function. Background Technology

[0002] In modern industrial production, product quality control is a core element in ensuring product qualification rates and maintaining corporate reputation. Machine vision-based automated defect detection technology, with its advantages of high efficiency, high precision, and non-contact operation, has gradually replaced traditional manual visual inspection and is widely used in industries such as 3C electronics, automobile manufacturing, and semiconductors.

[0003] Currently, mainstream defect detection methods typically rely on comparing images of the product under test with defect-free template images to identify defects through difference analysis. Pixel-level image subtraction is a common approach. However, industrial production environments present numerous uncontrollable disturbances: inherent errors in mechanical positioning systems, production line vibrations, slight camera installation offsets, and fluctuations in product placement posture can all lead to geometric misalignment between the image under test and the template image. These misalignments can cause even defect-free products to exhibit numerous false differences after image subtraction, resulting in a large number of false alarms and severely impacting the stability and reliability of the detection system.

[0004] To alleviate the misalignment problem, existing technologies attempt to employ image registration preprocessing. However, for industrial products with repetitive textures or sparse features, traditional algorithms suffer from a high registration failure rate due to the lack of stable feature points.

[0005] Therefore, developing a transformation detection method for industrial defect images that can reduce false alarms and improve defect recognition accuracy has become an urgent need in the field of industrial quality inspection. Summary of the Invention

[0006] To overcome the existing technical problems, this invention provides a transformation detection method for industrial defect images based on a cost-capacity function.

[0007] The present invention adopts the following technical solution.

[0008] A transformation detection method for industrial defect images based on a cost-capacity function includes the following steps:

[0009] Obtain a defect-free template image and a scene image to be tested, and input them into at most a backbone network to obtain a template feature map, a scene feature map, and two corresponding deep feature maps;

[0010] Offset prediction is performed on two deep feature maps to obtain a predicted offset field with the offset vector of each position point. Deformable convolution is applied to the template feature map based on the predicted offset field to obtain the template adjustment feature map.

[0011] A search guidance map is generated based on the predicted offset field. The search guidance map includes the dynamic search range corresponding to each location point. The search guidance map is applied to the scene feature map to calculate the similarity of each location point in the feature map with the template adjustment, and then converted into a cost matrix.

[0012] A dynamic temperature coefficient is generated based on two deep feature maps, and a displacement field is generated by combining the cost matrix and the predicted offset field. The template feature map is then transformed and aligned with the scene feature map based on the displacement field to obtain a template alignment map.

[0013] The decoupled discrimination module identifies the template alignment map and scene feature map to obtain potential defect components, and calculates the difference value of each location point. If the difference value is greater than the preset defect threshold, it is judged as a defect.

[0014] As a further improvement of the present invention, the specific steps of inputting the multi-backbone network to obtain the template feature map and the scene feature map include: inputting the multi-backbone network to generate two sets of multi-scale feature maps that correspond one-to-one with the template image or the scene image; upsampling the two sets of multi-scale feature maps to the same size and stitching them together; and obtaining the corresponding template feature map and scene feature map by convolution compression of the number of channels and normalization.

[0015] As a further improvement of the present invention, the specific steps of performing offset prediction on two deep feature maps to obtain a predicted offset field with the offset vector of each position point include: concatenating the two deep feature maps to obtain a fused offset feature map, convolving the fused offset feature map to obtain the offset vector of each position point, and integrating them to form the predicted offset field.

[0016] The specific steps for obtaining the template adjustment feature map by applying deformable convolution to the template feature map based on the predicted offset field include: for each position point in the template feature map, adjusting the position of the sampling point according to the offset vector corresponding to the position point in the predicted offset field to obtain the offset sampling point position; if the offset sampling point position is a non-integer coordinate, calculating the feature values ​​of the four different integer coordinates adjacent to the offset sampling point position, and performing a weighted average based on the distance to obtain the template adjustment feature map.

[0017] As a further improvement of the present invention, the specific steps for generating a search guidance map based on the predicted offset field include: calculating the magnitude of the offset vector at each location point to obtain the offset magnitude;

[0018] For each location point, at least several locations are selected in four or eight directions and designated as reference locations. The similarity of the offset vector direction between the location point and each reference location point is calculated. A dynamic search weight factor is generated based on the similarity of the offset vector direction. The dynamic search distance in that direction is obtained by multiplying the offset magnitude and the search weight factor. Spline interpolation is performed between the distance points of the dynamic search distance in adjacent directions to construct a smooth boundary curve, thereby forming the dynamic search range.

[0019] As a further improvement of the present invention, the specific steps for applying the search guidance map to the scene feature map to calculate the similarity of each location point in the feature map and the template adjustment feature map and converting it into a cost value matrix include: recording the location point corresponding to each dynamic search range as the center location point, calculating the similarity of each location point under the entire dynamic search range, so that each location point has multiple similarity values ​​corresponding to different center location points, integrating them to form a four-dimensional similarity matrix, and subtracting the similarity value from the numerical value to obtain the cost value, thereby converting the four-dimensional similarity matrix into a cost value matrix.

[0020] As a further improvement of the present invention, the specific steps for generating a dynamic temperature coefficient based on two deep feature maps include: generating an attention map from the two deep feature maps using a convolutional layer and a sigmoid function, and mapping the attention map to generate a dynamic temperature coefficient, the expression of which is as follows:

[0021] ,

[0022] in, It is the dynamic temperature coefficient of the j-th position in the i-th row. It is the minimum temperature coefficient. It is the maximum temperature coefficient. It is the attention weight of the j-th position in the i-th row.

[0023] As a further improvement of the present invention, the specific steps for generating a displacement field by combining the cost value matrix and the predicted offset field include: applying a Softmax function with a dynamic temperature coefficient to the cost value matrix to convert the cost value in the cost value matrix into probability weights to obtain the probability distribution of the position point at each displacement, then calculating the average displacement of the position point, calculating the prior offset value according to the offset vector of the position point corresponding to the predicted offset field, and summing it with the average displacement to obtain the displacement value of the position point, and integrating the displacement values ​​of each position point to form an initial displacement field.

[0024] Calculate the gradient of the initial displacement field. If the gradient is greater than the preset over-displacement threshold, perform L1 smoothing or L2 smoothing on the corresponding position points until the gradient is less than the over-displacement threshold to obtain the displacement field.

[0025] As a further improvement of the present invention, the decoupling discrimination module includes a decoupler and a discriminator;

[0026] The specific steps for identifying potential defect components by decoupling the discrimination module to identify the template alignment map and scene feature map, and calculating the difference value at each location point, include:

[0027] S11. The template alignment map is decomposed into normal template variation components and potential template defect components by a decoupler, and the scene feature map is decomposed into normal scene variation components and potential scene defect components.

[0028] S12. Verify whether the normal variation components of the template and the normal variation components of the scene can be distinguished by the discriminator. If not, generate a difference map by the potential defect components of the template and the potential defect components of the scene, calculate the L2 norm of each point in the difference map, and obtain the difference value.

[0029] If so, adjust the dynamic search range to generate a new cost matrix and adjust the dynamic temperature coefficient to generate a new displacement field, and execute step S11 again until the number of executions exceeds the preset repair threshold.

[0030] The beneficial effects of this invention are as follows:

[0031] 1. Traditional methods directly perform global registration or pixel-level differencing, which are inadequate for handling mixed global and local deformations, such as mixed global and local deformations caused by lens optical distortion. This scheme first performs deformable convolution adjustment on the template feature map by predicting the offset field, completing preliminary geometric correction at the macro level and effectively reducing positional deviations in various regions caused by equipment vibration, installation offset, or optical distortion. Then, based on this predicted offset field, a dynamic search range is dynamically generated for each location point, limiting the scope of its similarity calculation. This ensures that location points caused by the same macroscopic deformation trend tend to fall within the same dynamic search range. This avoids computational noise and mismatches caused by blind matching globally, removes a large number of interfering location points, further increases the accuracy and efficiency of subsequent calculations, and highlights the ability to identify defects.

[0032] 2. When generating the final displacement field for alignment, this scheme integrates the macroscopic information provided by the predicted offset field and the microscopic information reflected by the cost matrix. The predicted offset field indicates the general direction and trend of deformation in each region of the image, ensuring the smoothness and physical rationality of the final displacement field. The cost matrix, based on the similarity of local image content, provides a basis for fine-tuning at the pixel level. This collaborative control mechanism ensures that the generated displacement field conforms to the overall deformation model while accurately matching the detailed features of local images. This overcomes the problem of single-feature matching failing in areas with repetitive textures or sparse features, thus achieving highly robust image alignment in complex industrial scenarios. Attached Figure Description

[0033] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0034] Figure 1 This is a schematic diagram of the main process of the present invention. Detailed Implementation

[0035] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent. To better illustrate this embodiment, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual dimensions of the product.

[0036] It will be understood by those skilled in the art that certain well-known structures and their descriptions may be omitted in the accompanying drawings. The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0037] Reference Figure 1 This invention proposes a transformation detection method for industrial defect images based on a cost-capacity function, comprising the following steps:

[0038] Obtain a defect-free template image and a scene image to be tested, and input them into at most a backbone network to obtain a template feature map, a scene feature map, and two corresponding deep feature maps;

[0039] As a further improvement of the present invention, the specific steps of inputting the multi-backbone network to obtain the template feature map and the scene feature map include: inputting the multi-backbone network to generate two sets of multi-scale feature maps that correspond one-to-one with the template image or the scene image; upsampling the two sets of multi-scale feature maps to the same size and stitching them together; and obtaining the corresponding template feature map and scene feature map by convolution compression of the number of channels and normalization.

[0040] Specifically, the deep feature map can be the deepest layer in the multi-scale feature map, i.e., the feature map closest to the output layer. Alternatively, this deep feature map can be additionally set for output based on actual needs. The upsampling method can specifically employ bilinear interpolation. Channel compression via convolution can specifically use 1x1 convolution to reduce the number of channels, thereby lowering computational complexity and highlighting important features, as the number of channels increases significantly when upsampling to the same size and then stitching together. For normalization, this invention uses L2 normalization to enhance robustness to changes in illumination. Since the scheme of generating multi-scale feature maps through a convolutional neural network structure and the specific method of L2 normalization are common techniques in the field of convolutional neural networks, this invention will not elaborate further.

[0041] Offset prediction is performed on two deep feature maps to obtain a predicted offset field with the offset vector of each position point. Deformable convolution is applied to the template feature map based on the predicted offset field to obtain the template adjustment feature map.

[0042] As a further improvement of the present invention, the specific steps of performing offset prediction on two deep feature maps to obtain a predicted offset field with the offset vector of each position point include: concatenating the two deep feature maps to obtain a fused offset feature map, convolving the fused offset feature map to obtain the offset vector of each position point, and integrating them to form the predicted offset field.

[0043] The specific steps for obtaining the template adjustment feature map by applying deformable convolution to the template feature map based on the predicted offset field include: for each position point in the template feature map, adjusting the position of the sampling point according to the offset vector corresponding to the position point in the predicted offset field to obtain the offset sampling point position; if the offset sampling point position is a non-integer coordinate, calculating the feature values ​​of the four different integer coordinates adjacent to the offset sampling point position, and performing a weighted average based on the distance to obtain the template adjustment feature map.

[0044] As a specific embodiment of the present invention, the method of calculating the offset sampling point position is to directly add the position point to the offset vector. Since the offset vector is not necessarily an integer, the calculated offset sampling point position is generally a non-integer coordinate. Therefore, when the coordinates are non-integer, the best way is to calculate it through the nearby position points. For example, for the offset sampling point position (2.6, 2.8), the nearby points are (2,2), (2,3), (3,2) and (3,3). The feature values ​​of these points are taken, and the feature value of the offset sampling point position is calculated by the relative distance.

[0045] It's important to note that applying deformable convolution to the scene feature map directly adjusts the sampling points, potentially distorting or blurring areas of defects. Defects are often localized, subtle anomalies, and this distortion can smooth or mask defect features, reducing detection sensitivity. Conversely, when deformable sampling is applied to the template feature map, defect information exists only in the scene feature map and remains unchanged. By adjusting the template feature map to match the overall structure of the scene feature map, defects can be more accurately highlighted during subsequent difference calculations. This is because the scene feature map represents the actual object to be detected, and any deformable sampling should be applied to a reference baseline, not the actual data.

[0046] A search guidance map is generated based on the predicted offset field. The search guidance map includes the dynamic search range corresponding to each location point. The search guidance map is applied to the scene feature map to calculate the similarity of each location point in the feature map with the template adjustment, and then converted into a cost matrix.

[0047] As a further improvement of the present invention, the specific steps for generating a search guidance map based on the predicted offset field include: calculating the magnitude of the offset vector at each location point to obtain the offset magnitude;

[0048] For each location point, at least several locations are selected in four or eight directions and designated as reference locations. The similarity of the offset vector direction between the location point and each reference location point is calculated. A dynamic search weight factor is generated based on the similarity of the offset vector direction. The dynamic search distance in that direction is obtained by multiplying the offset magnitude and the search weight factor. Spline interpolation is performed between the distance points of the dynamic search distance in adjacent directions to construct a smooth boundary curve, thereby forming the dynamic search range.

[0049] The expression for the dynamic search distance is as follows:

[0050] ,

[0051] in, It is a dynamic search distance. It is the base search distance. It is the offset modulus. It is a search weighting factor.

[0052] Specifically, the four directions refer to the four directions of up, down, left, and right of the location point, while the eight directions refer to the location points in the four cardinal directions (up, down, left, right, upper left, upper right, lower left, and lower right). In one specific embodiment of the invention, four directions are used for larger detection objects. For smaller detection objects, either four or eight directions are used, adjusted according to the detection accuracy. If the accuracy meets expectations, four directions can be set to reduce the computational load, making the final dynamic search range tend towards a circle or ellipse. The similarity of the offset vector directions can be calculated based on cosine similarity. Furthermore, the number of reference location points in a single direction is equal to the number of reference location points included in the basic search distance.

[0053] As a specific embodiment of the present invention, taking four directions as an example, it should be noted that, in order to simplify the calculation, the left reference position point I will mention later actually refers to the five reference position points on the left, the upper reference position point refers to the five reference position points on the upper, and so on. The base search distance is 5, the offset vector of the position point is (2.1, -1.2), the offset vector of the left reference position point is (1.8, -1), the offset vector of the right reference position point is (1, -1.1), the offset vector of the upper reference position point is (2, -1.3), and the offset vector of the lower reference position point is (1.1, -0.8). The offset magnitude of the position point can be calculated to be approximately 2.42. The cosine similarity in the left direction is approximately 1, the cosine similarity in the right direction is 0.95, the cosine similarity in the upper direction is 0.99844, and the cosine similarity in the lower direction is 0.994. It can be seen that adjacent offset vectors in the same region have the same trend, therefore their calculated search weight factors are all approximately 1. Thus, the dynamic search distance in the left direction is 7.42, in the right direction it is 7.3, in the upper direction it is 7.41, and in the lower direction it is 7.4. When a position point is within this distance, it is considered to be outside the dynamic search range. For ease of understanding, we can set the offset vector of the reference point on the left as (-1.1, 1.2), an offset vector with a direction almost different from the reference point. This might indicate that the displacement of this region is exactly offset from this reference point, but this situation rarely occurs. This value is deliberately modified here for ease of understanding. At this point, the cosine similarity in the left direction is -0.95224, and the dynamic search range in the left direction is 2.4. With a base search distance of 5, only the reference points in the left two cells are calculated, forming an approximately semi-circular dynamic search range. Of course, for smaller detection objects, the base search distance could be 2 or 3, etc.

[0054] It's important to note that the dynamic search range isn't defined by calculating gradients. This is because if a region has very small gradients, but the offset vectors differ significantly after a few reference points, a large number of unwanted reference points would be within the dynamic search range. However, the solution in this invention ensures that if even one of the five reference points in a given direction exhibits a significant deviation, the search weight factor decreases rapidly and proportionally.

[0055] As a further improvement of the present invention, the specific steps for applying the search guidance map to the scene feature map to calculate the similarity of each location point in the feature map and the template adjustment feature map and converting it into a cost value matrix include: recording the location point corresponding to each dynamic search range as the center location point, calculating the similarity of each location point under the entire dynamic search range, so that each location point has multiple similarity values ​​corresponding to different center location points, integrating them to form a four-dimensional similarity matrix, and subtracting the similarity value from the numerical value to obtain the cost value, thereby converting the four-dimensional similarity matrix into a cost value matrix.

[0056] When calculating the similarity of each location point in this step, since the calculation is done in parallel, it will not take too much time. The method for calculating the similarity value is also the cosine similarity, so it will not be elaborated on here.

[0057] A dynamic temperature coefficient is generated based on two deep feature maps, and a displacement field is generated by combining the cost matrix and the predicted offset field. The template feature map is then transformed and aligned with the scene feature map based on the displacement field to obtain a template alignment map.

[0058] As a further improvement of the present invention, the specific steps for generating a dynamic temperature coefficient based on two deep feature maps include: generating an attention map from the two deep feature maps using a convolutional layer and a sigmoid function, and mapping the attention map to generate a dynamic temperature coefficient, the expression of which is as follows:

[0059] ,

[0060] in, It is the dynamic temperature coefficient of the j-th position in the i-th row. It is the minimum temperature coefficient. It is the maximum temperature coefficient. It is the attention weight of the j-th position in the i-th row.

[0061] The value range is from 0 to 1. A larger value indicates that the location is more likely to be a defect area, requiring higher alignment accuracy. By mapping the attention map to the dynamic temperature coefficient, in defect areas, the generated dynamic temperature coefficient is closer to the minimum temperature coefficient, resulting in a sharper output distribution and more certain displacement estimation. In background areas, the generated dynamic temperature coefficient is closer to the maximum temperature coefficient, resulting in a smoother distribution and suppressing displacement jitter caused by noise.

[0062] In one specific embodiment of the present invention, the minimum temperature coefficient is 0.1 and the maximum temperature coefficient is 3. If the attention weights of two location points are 0.8 and 0.2 respectively, for location point A with an attention weight of 0.8, its dynamic temperature coefficient can be calculated to be 0.68. For location point B, its dynamic temperature coefficient can be calculated to be 2.42. As mentioned above, the attention weight of location point A is greater than that of location point B, indicating that location point A is more likely to be a defect area, and its calculated dynamic temperature coefficient is closer to 0.1, resulting in a sharp distribution of subsequent output and a more certain displacement estimation. For location point B, its dynamic temperature coefficient is 2.42, resulting in a smoother distribution of subsequent output.

[0063] As a further improvement of the present invention, the specific steps for generating a displacement field by combining the cost value matrix and the predicted offset field include: applying a Softmax function with a dynamic temperature coefficient to the cost value matrix to convert the cost value in the cost value matrix into probability weights to obtain the probability distribution of the position point at each displacement, then calculating the average displacement of the position point, calculating the prior offset value according to the offset vector of the position point corresponding to the predicted offset field, and summing it with the average displacement to obtain the displacement value of the position point, and integrating the displacement values ​​of each position point to form an initial displacement field.

[0064] Calculate the gradient of the initial displacement field. If the gradient is greater than the preset over-displacement threshold, perform L1 smoothing or L2 smoothing on the corresponding position points until the gradient is less than the over-displacement threshold to obtain the displacement field.

[0065] The specific calculation expression is as follows:

[0066] ,

[0067] ,

[0068] in, It refers to the displacement coordinates of that location.

[0069] As a specific embodiment of the present invention, simplified calculations are deliberately performed here for illustrative purposes. For example, assume that the location point has nine possible displacement values: (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), and (1, 1). The dynamic temperature coefficients for each displacement are calculated to be 2.42, 2.13, 2.42, 1.26, 0.39, 1.26, 2.42, 2.13, and 2.42, respectively. The values ​​of each numerator in the formula are 0.4375, 0.4945, 0.4375, 0.4524, 0.2776, 0.4524, 0.4375, 0.4945, and 0.4375. The value of the denominator is 3.9. The calculated probability weights for each displacement are 0.1122, 0.1268, 0.1122, 0.1160, 0.0712, 0.1160, 0.1122, 0.1268, and 0.1122. It can be verified here that the probability weights are rounded to 1. The calculated average displacement is 0 (this is because the calculation has been optimized for simplicity in this invention; it is not actually equal to 0). The prior offset value is 0.5 x (0.2, 0.1) = (0.1, 0.05). Therefore, the final displacement coordinates of this point are (0.1, 0.05).

[0070] The decoupled discrimination module identifies the template alignment map and scene feature map to obtain potential defect components, and calculates the difference value of each location point. If the difference value is greater than the preset defect threshold, it is judged as a defect.

[0071] As a further improvement of the present invention, the decoupling discrimination module includes a decoupler and a discriminator;

[0072] The specific steps for identifying potential defect components by decoupling the discrimination module to identify the template alignment map and scene feature map, and calculating the difference value at each location point, include:

[0073] S11. The template alignment map is decomposed into normal template variation components and potential template defect components by a decoupler, and the scene feature map is decomposed into normal scene variation components and potential scene defect components.

[0074] S12. Verify whether the normal variation components of the template and the normal variation components of the scene can be distinguished by the discriminator. If not, generate a difference map by the potential defect components of the template and the potential defect components of the scene, calculate the L2 norm of each point in the difference map, and obtain the difference value.

[0075] If so, adjust the dynamic search range to generate a new cost matrix and adjust the dynamic temperature coefficient to generate a new displacement field, and execute step S11 again until the number of executions exceeds the preset repair threshold.

[0076] The template normal variation component and the scene normal variation component encode non-defect information such as background texture and lighting changes, while the scene potential defect component encodes information that differs significantly from the template and may be defective. By merging these two components, the template normal variation component and the scene normal variation component, a template alignment map can be basically restored.

[0077] If the discriminator cannot distinguish between the normal variation components from these two sources, it proves that the decoupler has successfully separated the common, normal texture fluctuation information into the normal variation component, while leaving the information representing potential defects in the scene's potential defect component. Specifically, during the training of the decoupling discriminator module, when the discriminator verifies that it can distinguish between the template's normal variation component and the scene's normal variation component, the discriminator can be adjusted in a random direction and by a random magnitude to change the dynamic search range (such as the base search distance) and the size of the dynamic temperature coefficient. After each adjustment, it is recorded whether it is easier to distinguish between the template's normal variation component and the scene's normal variation component. If not, the weight of future modifications in that direction and magnitude is increased, so that in actual use, the dynamic search range and dynamic temperature coefficient can be adjusted in the correct direction and magnitude.

[0078] The decoupler works by extracting common patterns by minimizing the variance of the normal variation component or maximizing its smoothness. The normal variation component is generated using techniques such as low-pass filtering, autoencoders, or average pooling to capture global or local stationary features in the image. For example, after extracting features through a convolutional neural network encoder, Gaussian smoothing or mean filtering is applied to obtain the template's normal variation component. This component should capture the overall trend of the image, such as background brightness or texture consistency. For the generation of potential defect components, the difference between the original image and the normal variation component is calculated.

[0079] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A method for transform detection of industrial defect images based on cost capacity function, characterized in that, The method comprises the following steps: obtaining a defect-free template image and a scene image to be tested, and inputting the images into a multi-bone network to obtain a template feature map and a scene feature map, and two corresponding deep feature maps; performing offset prediction on the two deep feature maps to obtain a predicted offset field with an offset vector for each position point, and applying deformable convolution to the template feature map according to the predicted offset field to obtain a template adjusted feature map; generating a search guide map according to the predicted offset field, the search guide map including a dynamic search range corresponding to each position point, calculating the similarity between each position point of the template adjusted feature map and the scene feature map by applying the search guide map to the scene feature map, and converting the similarity into a value matrix; generating a dynamic temperature coefficient according to the two deep feature maps, and generating a displacement field by combining the value matrix and the predicted offset field, and transforming and aligning the template feature map to the scene feature map according to the displacement field to obtain a template alignment map; the specific steps of generating a dynamic temperature coefficient according to the two deep feature maps include: generating an attention map by a convolution layer and a Sigmoid function from the two deep feature maps, and mapping the attention map to generate a dynamic temperature coefficient, and the expression of the dynamic temperature coefficient is as follows: , wherein, is the dynamic temperature coefficient of the i-th row j-th position point, is the minimum temperature coefficient, is the maximum temperature coefficient, is the attention weight of the i-th row j-th position point; the specific steps of generating a displacement field by combining the value matrix and the predicted offset field include: applying a Softmax function with a dynamic temperature coefficient to the value matrix to convert the value in the value matrix into a probability weight to obtain the probability distribution of each displacement of the position point, and then calculating the average displacement of the position point, and calculating the prior offset value corresponding to the offset vector of the position point in the predicted offset field, and summing the prior offset value and the average displacement to obtain the displacement value of the position point, and integrating the displacement values of each position point to form a displacement initial field; , , calculating the gradient of the displacement initial field, if the gradient is greater than a preset super displacement threshold, performing L1 smoothing processing or L2 smoothing processing on the corresponding position point until the gradient is less than the super displacement threshold, and obtaining the displacement field; identifying a latent defect component by decoupling a discrimination module from the template alignment map and the scene feature map, and calculating a difference value of each position point, if the difference value is greater than a preset defect threshold, determining that there is a defect.

2. The method of claim 1, wherein the cost volume based industrial defect image transformation method is characterized by, The specific steps of inputting the template feature map and the scene feature map into the multi-bone network include: inputting the multi-bone network to generate two groups of multi-scale feature maps corresponding to the template image or the scene image, upsampling the two groups of multi-scale feature maps to the same size for splicing, and obtaining the corresponding template feature map and the scene feature map by convolution compression of the channel number and normalization.

3. The method of claim 1, wherein the cost volume based industrial defect image transformation method is characterized by, The specific steps of performing offset prediction on the two deep feature maps to obtain a predicted offset field with an offset vector for each position point include: splicing the two deep feature maps to obtain a fused offset feature map, performing convolution on the fused offset feature map to obtain an offset vector for each position point, and integrating the offset vectors to form the predicted offset field. The specific steps of applying deformable convolution to the template feature map according to the predicted offset field to obtain a template adjustment feature map include: for each position point of the template feature map, adjusting the position of a sampling point according to the offset vector of the position point in the predicted offset field to obtain an offset sampling point position, if the offset sampling point position is a non-integer coordinate, calculating the feature values of four different integer coordinates adjacent to the offset sampling point position, and performing weighted averaging according to the distances to obtain the template adjustment feature map.

4. The method of claim 1, wherein the cost volume based industrial defect image transformation method is characterized by, The specific steps of generating a search guide map according to the predicted offset field include: calculating the length of the offset vector of each position point to obtain an offset length; Each position point extends in four directions or eight directions to select at least a plurality of position points as reference position points, the direction similarity of the offset vector of the position point and each reference position point is calculated, a dynamic search weight factor is generated according to the direction similarity of the offset vector, and a dynamic search distance in the direction is obtained according to the product of the offset length and the search weight factor. The distance points between the dynamic search distances of adjacent directions are spline interpolated to construct a smooth boundary curve to form a dynamic search range.

5. The method of claim 1, wherein the cost volume based industrial defect image transformation method is characterized by, The specific steps of applying the search guide map to the scene feature map to calculate the similarity of each position point of the template adjustment feature map and convert it into a value matrix include: recording the position point corresponding to each dynamic search range as a center position point, calculating the similarity of each position point under all dynamic search ranges, so that each position point has a plurality of similarity values corresponding to different center position points, integrating to form a four-dimensional similarity matrix, and obtaining a value by subtracting the similarity value from the numerical value, and then converting the four-dimensional similarity matrix into a value matrix.

6. The method of claim 1, wherein, The decoupling discrimination module includes a decoupler and a discriminator; The specific steps of identifying the template alignment map and the scene feature map through the decoupling discrimination module to obtain the latent defect component and calculating the difference value of each position point include: S11, decompose the template alignment map into a template normal change component and a template latent defect component through the decoupler, and decompose the scene feature map into a scene normal change component and a scene latent defect component; S12, verify whether the template normal change component and the scene normal change component can be distinguished through the discriminator, if not, generate a difference map through the template latent defect component and the scene latent defect component, calculate the L2 norm of each position point in the difference map to obtain the difference value; If yes, adjust the dynamic search range to generate a new value matrix, adjust the dynamic temperature coefficient to generate a new displacement field, and execute step S11 again until the execution times exceed the preset repair threshold.

Citation Information

Patent Citations

  • Precision etching net surface defect intelligent detection method

    CN117670828A

  • Industrial image anomaly detection method based on deep learning

    CN120976191A