Defect detection method and device, electronic equipment and storage medium
By constructing a defect detection model with visual feature representation and noise suppression loss calculation modules, and using noisy training images for model training, the problem of misjudgment in the detection of micro-defects on the surface of industrial components is solved, achieving high-precision and low-cost detection results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUZHOU MEGAROBO TECH CO LTD
- Filing Date
- 2025-12-23
- Publication Date
- 2026-05-01
AI Technical Summary
In existing technologies, industrial component surface micro-defect detection models are prone to misjudgment under noisy training data, resulting in decreased detection accuracy and reliability, making them difficult to apply effectively in complex production environments.
A defect detection model based on multiple training images is adopted. The model is constructed through a visual feature representation module, a visual feature difference calculation module, and a noise suppression loss calculation module. The model is trained using noisy training images, and noise reduction processing is performed to improve detection accuracy.
It can maintain high detection accuracy even in noisy training data, reduce the cost of training image preparation, improve the generalization ability and adaptability of the model, and ensure the detection accuracy and reliability in noisy environments.
Smart Images

Figure CN121962020A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and more specifically to a defect detection method, a defect detection device, an electronic device, a storage medium, and a computer program product. Background Technology
[0002] In the field of industrial component manufacturing, surface integrity is a core element determining the reliability of end products. As manufacturing processes evolve towards higher precision, the potential negative impact of micro-defects on component surfaces (such as particle adhesion, scratches, pores, and fractures) on product functionality is becoming increasingly prominent. The accuracy of defect detection has become a core bottleneck restricting the improvement of production yield. Current industrial practice commonly employs advanced solutions that deeply integrate generative deep learning-driven intelligent visual analysis frameworks with Automated Optical Inspection (AOI) systems to construct defect identification systems. The performance of this system highly depends on using clean, normal samples free of defects and interference as training benchmarks. However, in actual production environments, obtaining such ideal datasets faces numerous challenges—inherent noise from imaging equipment, uncontrollable ambient light fluctuations, continuous interference from mechanical vibrations during production, and natural differences in material surface textures, among other factors. These multiple factors make obtaining truly noise-free images of normal components a costly and technically challenging task. Typically, available training data consists mainly of normal component images, but inevitably includes background interference caused by the aforementioned noise sources. When the model is trained on noisy data, these noisy features are misclassified as non-defect features. While this phenomenon can suppress noise-induced misjudgments to some extent, it leads to a blurring of the model's threshold for identifying real defects, resulting in a non-linear increase in the false negative rate. This significantly limits the detection accuracy of the detection system. Therefore, constructing a defect detection model capable of accurately detecting defects has become a key technical challenge that urgently needs to be overcome in modern industrial manufacturing. Summary of the Invention
[0003] The present invention was proposed in view of the above-mentioned problems. The present invention provides a defect detection method, a defect detection device, an electronic device, a storage medium, and a computer program product.
[0004] According to one aspect of the present invention, a defect detection method is provided. The method includes: acquiring a test image comprising an industrial component; inputting the test image into a trained defect detection model to obtain target image features corresponding to the test image, wherein the trained defect detection model is trained based on multiple sets of training images comprising training components, and an incompletely trained defect detection model includes a visual feature representation module, a visual feature difference calculation module, and a noise suppression loss calculation module; each training component in each training image is free of defects; and for each set of training images, the visual feature representation module performs feature extraction processing on that set of training images. The system obtains a set of visual features corresponding to the training images, the set of visual features including the visual features corresponding to each training image in the set of training images. The visual feature difference calculation module is used to determine the distinguishing features between every two visual features in the set of visual features, which is used as the distinguishing feature set. The noise suppression loss calculation module is used to obtain the loss value corresponding to the training images based on the distinguishing feature set through noise reduction processing. Based on the difference between the target image features and the reference features, the system determines the defect detection result of the industrial component, wherein the reference features are determined based on at least one of the multiple training images through the trained defect detection model.
[0005] For example, based on this set of distinguishing features, a noise reduction process is performed to obtain the loss value corresponding to the set of training images, including:
[0006] Based on the set of distinguishing features corresponding to the set of training images, determine the weight features corresponding to the set of training images.
[0007] Based on the weight feature and the set of distinguishing features, the noise region evaluation score feature corresponding to each distinguishing feature in the set of distinguishing features is determined, which is used as the set of noise region evaluation score features corresponding to the training images.
[0008] Based on the noise region evaluation score feature set corresponding to the training images, noise reduction processing is performed to obtain the loss value corresponding to the training images.
[0009] For example, based on the set of evaluation score features of the noisy regions corresponding to the set of training images, noise reduction processing is performed to obtain the loss value corresponding to the set of training images, including:
[0010] Based on the set of noise region evaluation score features and the evaluation score threshold corresponding to the set of training images, the set of noise reduction features corresponding to the set of training images is determined.
[0011] Based on the set of noise reduction features corresponding to the training images, the loss value corresponding to the training images is determined.
[0012] For example, if the number of training rounds of an untrained defect detection model is less than a preset rounds threshold, the evaluation score threshold is negatively correlated with the number of training rounds of the untrained defect detection model.
[0013] For example, based on the set of noise reduction features corresponding to the set of training images, the loss value corresponding to the set of training images is determined, including:
[0014] The noise reduction feature set corresponding to the training images is subjected to feature fusion processing to obtain the noise reduction representative feature set corresponding to the training images.
[0015] The set of denoised representative features corresponding to the training images is normalized to obtain the loss value corresponding to the training images.
[0016] For example, based on the set of discriminative features corresponding to the set of training images, the weight features corresponding to the set of training images are determined, including:
[0017] The set of distinguishing features corresponding to the training images is subjected to feature fusion processing to determine the distinguishing statistical fusion features corresponding to the set of distinguishing features.
[0018] Based on the difference statistical fusion features corresponding to the difference feature set, or the difference statistical fusion features corresponding to the difference feature set and the weight features corresponding to the previous set of training images, determine the weight features corresponding to the set of training images.
[0019] According to another aspect of the present invention, a defect detection device is also provided, the device comprising:
[0020] The module includes an acquisition module for acquiring a test image containing industrial components; and a target image feature determination module for inputting the test image into a trained defect detection model to obtain the target image features corresponding to the test image. The trained defect detection model is trained based on multiple sets of training images containing training components. An incompletely trained defect detection model includes a visual feature representation module, a visual feature difference calculation module, and a noise suppression loss calculation module. No defects exist in the training components of each training image. For each set of training images, the visual feature representation module performs feature extraction processing on that set of training images to obtain the corresponding training image. The system includes a set of visual features corresponding to each training image in the set of training images. The visual feature difference calculation module is used to determine the distinguishing features between every two visual features in the set of visual features, which are used as the distinguishing feature set. The noise suppression loss calculation module is used to obtain the loss value corresponding to the set of training images by performing noise reduction processing based on the distinguishing feature set. The defect determination module is used to determine the defect detection result of the industrial component based on the difference between the target image features and the reference features, wherein the reference features are determined based on at least one of the multiple training images by the trained defect detection model.
[0021] According to another aspect of the present invention, an electronic device is also provided. The electronic device includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, are used to perform the aforementioned defect detection method.
[0022] According to another aspect of the present invention, a storage medium is also provided. Program instructions are stored on this storage medium, which, when executed, are used to perform the aforementioned defect detection method.
[0023] According to another aspect of the present invention, a computer program product is also provided. This computer program product includes computer program instructions that, when executed by a processor, are used to perform the aforementioned defect detection method.
[0024] According to the above-described scheme of the present invention, a test image including an industrial component can be acquired. Then, the test image is input into a trained defect detection model to obtain target image features corresponding to the test image. Finally, based on the difference between the target image features and the baseline features, the defect detection result of the industrial component is determined. The baseline features are determined by the trained defect detection model based on at least one of multiple training images. Even when the training image used to train the defect detection model is a noisy industrial component image, the above scheme can still effectively utilize the noisy training image to complete the model training. That is, even with a certain proportion of noise mixed into the training data, the trained defect detection model can still maintain detection accuracy comparable to a model trained using pure, defect-free, and noise-free training data. Furthermore, the training process of the above-described defect detection model eliminates the need for rigorous data cleaning and screening of the training images, which helps reduce the preparation cost of the training images. It also improves the generalization ability and adaptability of the defect detection model, enabling it to be stably applied to production scenarios with various noise interferences, thus ensuring the accuracy and reliability of the above-described defect detection method to a certain extent. Attached Figure Description
[0025] The above and other objects, features, and advantages of the present invention will become more apparent from the more detailed description of the embodiments of the invention in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same parts or steps.
[0026] Figure 1 A schematic flowchart of a defect detection method according to an embodiment of the present invention is shown;
[0027] Figure 2 A schematic diagram of an untrained defect detection model according to an embodiment of the present invention is shown;
[0028] Figure 3 A schematic block diagram of a defect detection apparatus according to an embodiment of the present invention is shown;
[0029] Figure 4 A schematic block diagram of an electronic device according to an embodiment of the present invention is shown. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of the present invention more apparent, exemplary embodiments according to the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely a part of the embodiments of the present invention, and not all of the embodiments of the present invention. It should be understood that the present invention is not limited to the exemplary embodiments described herein. Based on the embodiments of the present invention described herein, all other embodiments obtained by those skilled in the art without inventive effort should fall within the protection scope of the present invention.
[0031] To at least partially solve the above problems, embodiments of the present invention provide a defect detection method. Figure 1 A schematic flowchart of a defect detection method according to an embodiment of the present invention is shown. Figure 1 As shown, the method may include the following steps S110 to S130.
[0032] In step S110, an image of the object to be tested, including industrial components, is acquired.
[0033] The industrial components in the image to be tested can be industrial components that require defect detection.
[0034] The image to be tested can be a still image or any video frame from a dynamic video. The image to be tested can be an image captured by an image acquisition device (e.g., an image captured by an image sensor in a camera), or an image obtained after preprocessing (e.g., digitization, normalization, smoothing, etc.) the image captured by the image acquisition device.
[0035] In step S120, the image to be tested is input into the trained defect detection model to obtain the target image features corresponding to the image to be tested.
[0036] The trained defect detection model is trained on multiple sets of training images containing training industrial components. Each training image contains industrial components that are free of defects. For example, the defect detection model can be an unsupervised anomaly detection model based on normalizing flows (e.g., PyramidFlow, FastFlow, MSFlow, etc.). While each training image contains industrial components free of target defects, the training images may contain noise introduced during image acquisition or transmission. Understandably, the target defects can be those that need to be detected by the trained defect detection model, such as foreign objects, scratches, cracks, etc.
[0037] The untrained defect detection model includes a visual feature representation module, a visual feature difference calculation module, and a noise suppression loss calculation module. For each set of training images in a set of training images, the visual feature representation module performs feature extraction processing on that set of training images to obtain a visual feature set corresponding to that set of training images. The visual feature set includes the visual features corresponding to each training image in the set. The visual feature difference calculation module determines the distinguishing features between every two visual features in the visual feature set, which serves as the distinguishing feature set. The noise suppression loss calculation module performs noise reduction processing based on this distinguishing feature set to obtain the loss value corresponding to that set of training images. For example, Figure 2 A schematic diagram of an untrained defect detection model according to an embodiment of the present invention is shown. Figure 2 As shown, the defect detection model includes a visual feature representation module, a visual feature difference calculation module, and a noise suppression loss calculation module. The input of the visual feature representation module can receive training images, and its output can be connected to the input of the visual feature difference calculation module. The output of the visual feature difference calculation module can be connected to the input of the noise suppression loss calculation module. The output of the noise suppression loss calculation module can be used to output the loss value. Users can adjust the parameters of each module in the incompletely trained defect detection model based on this loss value. When the loss value output by the incompletely trained defect detection model tends to stabilize and no longer decreases significantly, it can be determined that the defect detection model has been successfully trained.
[0038] For example, consider a set of training images input to an incompletely trained defect detection model, including training image X1, training image X2, and training image X3. The input of the visual feature representation module can receive these three training images (i.e., a set of training images). The visual feature representation module can extract features from training images X1, X2, and X3 respectively to obtain a set of visual features corresponding to this set of training images. This set of visual features may include visual features T1 of training image X1, visual features T2 of training image X2, and visual features T3 of training image X3. Then, the visual feature representation module can output this set of corresponding visual features to the visual feature difference calculation module. The visual feature difference calculation module can calculate the distinguishing features between every two visual features in this set of visual features based on the input set of visual features (i.e., visual features T1 to T3) and the difference calculation formula (e.g., the absolute difference sum calculation formula, the Euclidean distance calculation formula, etc.), thus obtaining a set of distinguishing features. The set of distinguishing features may include: distinguishing features between visual feature T1 and visual feature T2, distinguishing features between visual feature T1 and visual feature T3, and distinguishing features between visual feature T2 and visual feature T3. It is understood that both visual features and distinguishing features can be represented in the form of feature maps, and the size of the feature map corresponding to each distinguishing feature (hereinafter referred to as the distinguishing feature map) is the same as the size of the feature map corresponding to each visual feature (hereinafter referred to as the visual feature map). Furthermore, the feature value corresponding to each feature cell in the distinguishing feature map is used to represent the degree of difference between the feature value of the feature cell corresponding to that feature cell in the first visual feature map and the feature value of the feature cell corresponding to that feature cell in the second visual feature map. The aforementioned first visual feature map and second visual feature map are two visual feature maps used to determine the distinguishing feature map. Since each set of training images consists of images of defect-free industrial components, under normal circumstances, the differences in visual features between different training images should originate from noise in the images. Therefore, the set of distinguishing features determined by the visual feature difference calculation module can be used to reflect feature fluctuations caused by noise. The visual feature difference calculation module can output its generated set of distinguishing features to the noise suppression loss calculation module. The noise suppression loss calculation module inputs each distinct feature from the set of input distinct features into its internal autoencoder (e.g., a convolutional denoising autoencoder, or CDAE). This autoencoder is trained collaboratively with other modules of the defect detection model to denoise each distinct feature, resulting in a denoised feature for each feature. Then, the loss value is calculated by comparing the difference (i.e., the reconstruction residual) between each distinct feature and its corresponding denoised feature. It is understood that the larger the loss value, the weaker the current defect detection model's ability to filter noise.Users can adjust the parameters of each module in an untrained defect detection model based on the loss value.
[0039] This invention provides an example for reference. When the loss value output by the untrained defect detection model stabilizes, or the number of iterations reaches a preset number, it is determined that the defect detection model has completed training. When the defect detection model has completed training, the image features obtained by the defect detection model through feature extraction processing of the test image can be used as the target image features.
[0040] In step S130, the defect detection result of the industrial component is determined based on the difference between the target image features and the reference features.
[0041] The baseline feature can be determined based on at least one of multiple training images by the trained defect detection model. For example, after the defect detection model has been trained, at least one training image is input into the trained defect detection model to obtain at least one visual feature output by the visual feature representation module. The baseline feature can be determined based on this at least one visual feature. It is understood that when there is only one training image input into the trained defect detection model, the visual feature output by the visual feature representation module based on that training image can be used as the baseline feature. When there are multiple training images input into the trained defect detection model, the visual feature representation module can output multiple visual features based on the multiple training images. The baseline feature can be determined based on these multiple visual features. The feature value of each feature unit in the baseline feature can be one of the average, median, or other similar features of the corresponding feature values of that feature unit among the multiple visual features.
[0042] This invention provides an example for reference. Given target image features and reference features, the difference between the target image features and reference features can be calculated using a difference calculation formula (e.g., absolute difference sum calculation formula, Euclidean distance calculation formula, etc.). If the difference is greater than a preset difference threshold (which can be determined by the user), it is determined that a defect exists in the image under test. If the difference is less than the preset difference threshold, it is determined that no defect exists in the image under test.
[0043] According to the above-described scheme of the present invention, a test image including an industrial component can be acquired. Then, the test image is input into a trained defect detection model to obtain target image features corresponding to the test image. Finally, based on the difference between the target image features and the baseline features, the defect detection result of the industrial component is determined. The above scheme can effectively utilize noisy industrial component images as training images for the defect detection model, even when the training images used to train the defect detection model are noisy training images. That is, by mixing a certain proportion of noise into the training data, the trained defect detection model can still maintain detection accuracy comparable to a model trained using pure, defect-free, and noise-free training data. Furthermore, the training process of the above-described defect detection model eliminates the need for rigorous data cleaning and screening of the training images, which helps reduce the preparation cost of training images and improves the generalization ability and adaptability of the defect detection model, enabling it to be stably applied to production scenarios with various noise interferences, thus ensuring the accuracy and reliability of the above-described defect detection method to a certain extent.
[0044] For example, the loss value corresponding to the group of training images obtained by noise reduction based on the set of distinguishing features in step S120 above may include steps S121 to S123.
[0045] In step S121, the weight features corresponding to the training images are determined based on the set of distinguishing features corresponding to the training images.
[0046] An example of this invention is provided herein for reference. For example... Figure 2As shown, when a set of training images is input into an untrained defect detection model, the fusion value corresponding to each feature unit in the discriminative feature set corresponding to the set of training images can be determined based on the feature values corresponding to each feature unit in different discriminative features (see step S120 above). (For example, for the discriminative feature set, the fusion value corresponding to each feature unit is the median or average of the corresponding feature values of the feature unit in all discriminative features, etc.). The aforementioned weight features can also be represented in the form of feature maps, and the size of the feature map corresponding to the weight features (hereinafter referred to as the weight feature map) can be the same as the size of each discriminative feature map. The feature value of each feature unit in the weight feature map can be the fusion value of the feature unit corresponding to that feature unit in the discriminative feature map. Specifically, for example, the discriminative feature set includes: discriminative feature C1, discriminative feature C2, and discriminative feature C3. Each discriminative feature includes feature unit L1, feature unit L2, feature unit L3, and feature unit L4. In distinguishing feature C1, the eigenvalues corresponding to feature units L1 to L4 are 1, 2, 2, and 1, respectively. In distinguishing feature C2, the eigenvalues corresponding to feature units L1 to L4 are 1, 4, 1, and 1, respectively. In distinguishing feature C3, the eigenvalues corresponding to feature units L1 to L4 are 5, 2, 1, and 1, respectively. When the fusion value corresponding to each feature unit is the median of its eigenvalues, the fusion values of each feature unit from L1 to L4 are 1, 2, 1, and 1, respectively. In the above case, the eigenvalue of the feature unit corresponding to feature unit L1 in the above weighted feature graph is 1 (i.e., the fusion value of feature unit L1), the eigenvalue of the feature unit corresponding to feature unit L2 is 2 (i.e., the fusion value of feature unit L2), the eigenvalue of the feature unit corresponding to feature unit L3 is 1 (i.e., the fusion value of feature unit L3), and the eigenvalue of the feature unit corresponding to feature unit L4 is 1 (i.e., the fusion value of feature unit L4). This allows us to determine the above weighted features.
[0047] In step S122, based on the weight feature and the set of distinguishing features, the noise region evaluation score feature corresponding to each distinguishing feature in the set of distinguishing features is determined, so as to serve as the set of noise region evaluation score features corresponding to the group of training images.
[0048] An example of this invention is provided herein for reference. For example... Figure 2As shown, continuing with the example in step S121 above, the noise area assessment score feature set includes the noise area assessment score feature corresponding to each distinguishing feature in the distinguishing feature set. Taking the calculation of the noise area assessment score feature corresponding to distinguishing feature C1 as an example, the noise area assessment score feature corresponding to distinguishing feature C1 can be determined through the noise scoring calculation formula, weight features, and the feature value of each feature unit in distinguishing feature C1. Specifically, for example, the above noise area assessment score feature calculation formula is: Noise area assessment score feature = Distinguishing feature / (Weight feature + 1 × 10) -6 The noise region evaluation score feature corresponding to feature unit L1 in distinguishing feature C1 is 1 / (1+1×10). -6 The noise region evaluation score feature corresponding to feature unit L2 in feature C1 is approximately equal to 1, and the feature score is 2 / (2+1×10). -6 The score of the noise region evaluation feature corresponding to feature unit L3 in feature C1 is approximately 1, which is 2 / (1+1×10). -6 The score of the noise region corresponding to feature unit L4 in feature C1 is approximately 2, which is 1 / (1+1×10). -6 The noise region evaluation score features corresponding to the distinguishing feature C1 are approximately equal to 1. Finally, the noise region evaluation score features corresponding to feature unit L1 are determined to be: 1 for feature unit L1, 1 for feature unit L2, 2 for feature unit L3, and 1 for feature unit L4. Then, by performing aggregation operations (e.g., summation, averaging, or max pooling) on the noise region evaluation score features corresponding to the distinguishing feature C1 along the feature channel dimension, the noise region evaluation score features corresponding to the distinguishing feature C1 are obtained. Based on the same process, the noise region evaluation score features corresponding to distinguishing features C2 and C3 can be determined. Wherein, the 1×10 in the above noise region evaluation score feature calculation formula... -6 This is used to ensure that the denominator in the formula is not zero. It is understandable that... Figure 2 The noise region assessment score feature set includes the noise region assessment score feature corresponding to each distinguishing feature in the distinguishing feature set.
[0049] In step S123, based on the set of noise region evaluation features corresponding to the set of training images, noise reduction processing is performed to obtain the loss value corresponding to the set of training images.
[0050] This invention provides an example for reference. Each noise region evaluation score feature in the noise region evaluation score feature set corresponding to the training images can be input into an autoencoder (e.g., a convolutional denoising autoencoder, or CDAE) within the noise suppression loss calculation module. This autoencoder is trained collaboratively with other modules of the defect detection model to denoise each noise region evaluation score feature, resulting in a denoised feature for each noise region evaluation score feature. Then, the loss value can be calculated by comparing the difference (i.e., the reconstruction residual) between each noise region evaluation score feature and its corresponding denoised feature. It is understood that the larger the loss value, the weaker the noise filtering ability of the current defect detection model.
[0051] According to the above-described scheme of the present invention, the weight features corresponding to the set of distinguishable features corresponding to the set of training images can be determined. Then, based on the weight features and the set of distinguishable features, the noise region evaluation score feature corresponding to each distinguishable feature in the set of distinguishable features can be determined as the noise region evaluation score feature set corresponding to the set of training images. Subsequently, based on the noise region evaluation score feature set corresponding to the set of training images, noise reduction processing can be performed to obtain the loss value corresponding to the set of training images. The above scheme can construct a noise region evaluation score feature set by evaluating the noise level of each distinguishable feature, which is beneficial to improving the accuracy of the defect detection model in distinguishing between real differences in industrial component features and noise interference. Furthermore, the noise suppression loss calculation module in the above scheme can filter noise components based on the noise region evaluation score feature set, removing noise interference that is meaningless to the defect detection model as much as possible, and retaining feature differences that are meaningful for defect detection, thereby ensuring that the loss value can, to a certain extent, truly reflect the differences in the features of industrial components, rather than noise interference.
[0052] For example, step S123 may include step S1231 and step S1232.
[0053] In step S1231, based on the noise region evaluation score feature set and evaluation score threshold corresponding to the group of training images, the noise reduction feature set corresponding to the group of training images is determined.
[0054] An example of this invention is provided herein for reference. For example... Figure 2As shown, for each noise region evaluation score feature in the noise region evaluation score feature set, the noise region dimensionality reduction feature corresponding to the noise region evaluation score feature can be obtained by aggregating the noise region evaluation score feature along the feature channel dimension (dim). Based on the noise region dimensionality reduction feature and the evaluation score threshold, feature units with feature values higher than the evaluation score threshold are marked as "0", and feature units with feature values lower than or equal to the evaluation score threshold are marked as "1", thereby generating the noise mask feature map corresponding to the noise region dimensionality reduction feature. Each noise region dimensionality reduction feature can form... Figure 2 A set of dimensionality-reduced features for medium-noise regions. The noise mask feature map corresponding to the dimensionality-reduced features of each noise region can be combined to form... Figure 2 The noise mask feature map set is used. Through the noise mask feature map corresponding to the dimensionality reduction feature of the noise region, the feature values of the distinguishing features corresponding to the dimensionality reduction feature of the noise region are subjected to element-wise multiplication masking (i.e., feature units with a mask value of "1" retain their corresponding feature values, and feature units with a mask value of "0" have their corresponding feature values masked and set to 0), thus obtaining the denoising feature corresponding to the distinguishing feature. Based on the same process, the denoising feature corresponding to the dimensionality reduction feature of each noise region can be determined, and thus the denoising feature set corresponding to the training images can be obtained. It is understood that the above evaluation score threshold can be a fixed value (which can be determined by the user), or it can decrease linearly or non-linearly to a fixed value (which can be determined by the user) with the number of training rounds when the defect detection model is not fully trained.
[0055] In step S1232, based on the denoising feature set corresponding to the group of training images, the loss value corresponding to the group of training images is determined.
[0056] This invention provides an example for reference. The noise reduction feature set can be fused (e.g., averaging, weighted averaging, attention fusion, etc.) to obtain a benchmark fused feature reflecting the normal characteristics of a defect-free industrial component. The difference between each noise reduction feature in the noise reduction feature set and this benchmark fused feature (e.g., Euclidean distance, mean square error, etc.) is used as a loss sub-value. This loss value can be determined by the loss sub-value corresponding to each noise reduction feature in the noise reduction feature set.
[0057] According to the above-described scheme of the present invention, a denoising feature set corresponding to the set of training images can be determined based on the noise region evaluation score feature set and the evaluation score threshold corresponding to the set of training images. Then, based on the denoising feature set corresponding to the set of training images, the loss value corresponding to the set of training images is determined. By introducing a denoising mechanism based on the noise region evaluation score feature set and the evaluation score threshold, the above scheme can effectively filter and accurately suppress interference information during the training process to a certain extent, which is beneficial to improving the training stability and generalization ability of the defect detection model. Furthermore, by calculating the loss value based on the denoising feature set, the above scheme ensures to a certain extent that the defect detection model can focus on real and reliable differences in the characteristics of industrial components, rather than false signals contaminated by noise. This helps to avoid overfitting or training oscillation problems caused by noise interference in traditional methods, making the detection results output by the trained defect detection model more accurate.
[0058] For example, if the number of training rounds of an untrained defect detection model is less than a preset rounds threshold, the evaluation score threshold is negatively correlated with the number of training rounds of the untrained defect detection model.
[0059] This invention provides an example for reference. The formula for calculating the evaluation score threshold is: Evaluation score threshold = Base threshold * (1 - 0.1 * min(number of training epochs, preset epoch threshold)). In the above formula, the base threshold can be set by the user according to actual conditions, and the number of training epochs can be determined based on the batch of images that have completed training. For example, if a training epoch requires a batch of 1000 images, a training epoch is considered complete once the batch of images has completed forward propagation, loss calculation, and model parameter updates. It is understood that the preset epoch threshold in the above evaluation score threshold calculation formula can be changed according to actual conditions. Since the defect detection model usually converges initially within the first 10 training epochs, if the value corresponding to the number of training epochs is not limited, the evaluation score threshold will decay infinitely. In the later stages of defect detection model training, the evaluation score threshold will approach 0 infinitely, causing the defect detection model to consider most areas in the input training images as defect areas. Therefore, the preset epoch threshold can be set to 9. Furthermore, fixing the lower limit of the evaluation score threshold at 0.1 * the base threshold (i.e., evaluation score threshold = base threshold × (1 - 0.1 × 9) = base threshold × 0.1) ensures that the detection sensitivity of the defect detection model is controllable.
[0060] According to the above-described scheme of the present invention, when the number of training epochs of the untrained defect detection model is less than a preset epoch threshold, the evaluation score threshold is negatively correlated with the number of training epochs of the untrained defect detection model. The above scheme adopts a more lenient noise tolerance strategy (i.e., a higher evaluation score threshold) in the early stages of defect detection model training, and gradually tightens the denoising standard as the number of training epochs increases, thereby effectively balancing the stability and accuracy of defect detection model learning. In the early stages of training (when the number of training epochs is less than the preset epoch threshold), the defect detection model has not yet fully converged. If a low evaluation score threshold (strict denoising) is applied too early, it is easy to eliminate effective feature differences that are yet to be learned, leading to training bias or convergence difficulties. Using a higher evaluation score threshold (i.e., a lower denoising intensity) can retain more potentially useful information, promoting the rapid establishment of basic feature representation capabilities by the defect detection model. As the number of training epochs increases, the evaluation score threshold gradually decreases, and the denoising standard becomes stricter, allowing the defect detection model to focus on high-confidence, low-noise feature differences, thereby refining parameter optimization.
[0061] For example, step S1232 above, which determines the loss value corresponding to the set of denoising features corresponding to the set of training images, may include steps S12321 to S12322.
[0062] In step S12321, the noise reduction feature set corresponding to the training images is subjected to feature fusion processing to obtain the noise reduction representative feature set corresponding to the training images.
[0063] This invention provides an example for reference. Each denoising feature in the denoising feature set corresponding to the set of training images can be fused to obtain a representative denoising feature corresponding to that denoising feature. Based on the same principle, representative denoising features corresponding to other denoising features in the denoising feature set can be calculated. This set of representative denoising features consists of the representative denoising features corresponding to each denoising feature in the denoising feature set. Specifically, for each denoising feature in the denoising feature set, the average of the sum of the feature values of all feature units in that denoising feature can be used as the representative denoising feature corresponding to that denoising feature. Based on the same process, the representative denoising features corresponding to all denoising features in the denoising feature set can be obtained, that is, the set of representative denoising features corresponding to that denoising feature set.
[0064] In step S12322, the noise reduction representative feature set corresponding to the training images is normalized to obtain the loss value corresponding to the training images.
[0065] This embodiment of the invention provides an example for reference, which can be based on the normal region (i.e. marked "1") in the noise mask feature map corresponding to each noise reduction feature (see the content in step S1231 above) (all normal regions can be referenced). Figure 2 The total number of feature units in the normal region of the noise mask feature map set is used to normalize the corresponding denoising representative feature, thus obtaining the loss sub-value corresponding to the denoising representative feature. Based on the same process, the loss sub-values corresponding to other denoising representative features in the denoising representative feature set corresponding to this set of training images can be determined. The loss value corresponding to this set of training images can be determined by the loss sub-values corresponding to all denoising representative features in the denoising representative feature set corresponding to this set of training images.
[0066] According to the above-described scheme of the present invention, feature fusion processing can be performed on the denoised feature set corresponding to the set of training images to obtain the denoised representative feature set corresponding to the set of training images. Then, the denoised representative feature set corresponding to the set of training images is normalized to obtain the loss value corresponding to the set of training images. The above scheme, by normalizing the denoised representative features, transforms the feature differences between different training images into a numerical measure under a unified scale, and directly uses it as the loss value for the set of training images. This loss value not only reflects the degree of fitting of the current defect detection model to the "normal pattern" (i.e., the highly consistent feature distribution or structural regularity presented in the training images of multiple industrial components under defect-free conditions), but also naturally suppresses non-defect changes caused by illumination, imaging conditions, or minor process fluctuations, which is beneficial to improving the detection accuracy of defect detection methods.
[0067] For example, step S121 above, which determines the weight features corresponding to the set of distinguishing features corresponding to the set of training images, may include steps S1211 and S1212.
[0068] In step S1211, feature fusion processing is performed on the set of distinguishing features corresponding to the set of training images to determine the distinguishing statistical fusion features corresponding to the set of distinguishing features.
[0069] An example is provided herein for reference. The process of obtaining the distinguishing statistical fusion features can be found in the process of obtaining the weight features in step S121 above, and will not be repeated here.
[0070] In step S1212, the weight features corresponding to the set of training images are determined based on the difference statistical fusion features corresponding to the set of difference features, or the difference statistical fusion features corresponding to the set of difference features and the weight features corresponding to the set of training images preceding the set of training images.
[0071] In one example, the weighted features corresponding to the set of discriminative features can be determined based on the discriminative statistical fusion features corresponding to this set of discriminative features. For example, such as Figure 2 As shown, when the defect detection model that has not been trained generates the above-mentioned set of distinguishing features based on the first set of training images, the distinguishing statistical fusion features corresponding to the set of distinguishing features (i.e., the distinguishing statistical fusion features corresponding to the set of distinguishing features in step S1211 above) can be used as the weight features corresponding to the set of training images.
[0072] In another example, the weight features corresponding to the set of distinguishable features can be determined based on the distinguishable statistical fusion features corresponding to the set of distinguishable features and the weight features corresponding to the previous set of training images. For example, if an untrained defect detection model generates the above distinguishable feature set based on the nth (n greater than or equal to 2) set of training images, the weight features corresponding to the set of training images can be calculated using the weight feature calculation formula (weight features corresponding to the set of training images = 0.9 * weight features corresponding to the previous set of training images + 0.1 * distinguishable statistical fusion features corresponding to the set of distinguishable features), the weight features corresponding to the previous set of training images, and the distinguishable statistical fusion features corresponding to the set of training images. Therefore, the weight features corresponding to the set of training images = 0.9 * weight features corresponding to the previous set of training images + 0.1 * distinguishable statistical fusion features corresponding to the set of training images. It is understandable that after determining the weight features corresponding to the set of training images, the defect detection model can save the weight features corresponding to the set of training images for use in calculating the corresponding weight features of the next set of training images. It is also understandable that the weight design in the weight feature calculation formula is based on the exponential moving average (EMA) mechanism. The weight of 0.9 retains the stable features accumulated in the previous training, and the weight of 0.1 introduces new feature information of the current group to achieve smooth updates.
[0073] According to the above-described scheme of the present invention, feature fusion processing is performed on the distinguishing feature set corresponding to the group of training images to determine the distinguishing statistical fusion features corresponding to the distinguishing feature set. Then, based on the distinguishing statistical fusion features corresponding to the distinguishing feature set and the weight features corresponding to the previous group of training images, the weight features corresponding to the group of training images can be determined. The above scheme first performs feature fusion on the distinguishing feature set of the current group of training images to generate distinguishing statistical fusion features, and then combines the weight features learned from the previous group of training images to dynamically update the weight features of the current group through weighted fusion. This allows the defect detection model to gradually accumulate and refine the common feature representations of defect-free industrial components in the training images, which helps to avoid feature drift caused by single-set data bias or local noise interference. At the same time, it helps to enhance the adaptability of the defect detection model to non-defect factors such as process fluctuations and changes in imaging conditions, making the training process smoother and convergence more reliable.
[0074] This invention also provides a defect detection device. Figure 3 A schematic block diagram of a defect detection apparatus 200 according to an embodiment of the present invention is shown. (In conjunction with...) Figure 3 As shown, the detection device 200 may include: an acquisition module 210, a feature determination module 220, and a defect determination module 230.
[0075] The acquisition module 210 can be used to acquire images of the target, including industrial components.
[0076] The target image feature determination module 220 can be used to input the image to be tested into the trained defect detection model to obtain the target image features corresponding to the image to be tested. The trained defect detection model is trained based on multiple sets of training images including training elements. The incompletely trained defect detection model includes a visual feature representation module, a visual feature difference calculation module, and a noise suppression loss calculation module. There are no defects in the training elements in each training image. For each set of training images in the multiple sets of training images, the visual feature representation module is used to perform feature extraction processing on the set of training images to obtain the visual feature set corresponding to the set of training images. The visual feature set includes the visual features corresponding to each training image in the set of training images. The visual feature difference calculation module is used to determine the distinguishing features between every two visual features in the set of visual features to serve as the distinguishing feature set. The noise suppression loss calculation module is used to obtain the loss value corresponding to the set of training images based on the distinguishing feature set through noise reduction processing.
[0077] The defect determination module 230 can be used to determine the defect detection result of the industrial component based on the difference between the target image features and the reference features, wherein the reference features are determined by a trained defect detection model based on at least one of a plurality of training images.
[0078] For example, the denoising module can be further configured to determine weight features corresponding to the set of discriminative features corresponding to the set of training images. Based on the weight features and the set of discriminative features, the module determines the noise region evaluation score feature corresponding to each discriminative feature in the set of discriminative features, which serves as the noise region evaluation score feature set corresponding to the set of training images. Based on the noise region evaluation score feature set corresponding to the set of training images, denoising processing is performed to obtain the loss value corresponding to the set of training images.
[0079] For example, the denoising module can be further used to determine the denoising feature set corresponding to the set of training images based on the set of noise region evaluation score features and the evaluation score threshold. Based on the denoising feature set corresponding to the set of training images, the loss value corresponding to the set of training images is determined.
[0080] For example, if the number of training rounds of an untrained defect detection model is less than a preset rounds threshold, the evaluation score threshold is negatively correlated with the number of training rounds of the untrained defect detection model.
[0081] For example, the denoising module can further be used to perform feature fusion processing on the denoising feature set corresponding to the set of training images to obtain a representative denoising feature set corresponding to the set of training images. The representative denoising feature set corresponding to the set of training images is then normalized to obtain the loss value corresponding to the set of training images.
[0082] For example, the noise reduction module can be further used to perform feature fusion processing on the set of distinguishing features corresponding to the set of training images to determine the distinguishing statistical fusion features corresponding to the set of distinguishing features. Based on the distinguishing statistical fusion features corresponding to the set of distinguishing features, or the distinguishing statistical fusion features corresponding to the set of distinguishing features and the weight features corresponding to a set of training images preceding the set of training images, the weight features corresponding to the set of training images are determined.
[0083] According to another aspect of the present invention, an electronic device is also provided. Figure 4 A schematic block diagram of an electronic device 300 according to an embodiment of the present invention is shown. Figure 4 As shown, the electronic device 300 includes a processor 310 and a memory 320. The memory 320 stores a computer program, and the computer program instructions are executed by the processor 310 to perform the aforementioned defect detection method.
[0084] Furthermore, according to another aspect of the present invention, a storage medium is also provided, on which program instructions are stored. When the program instructions are executed by a computer or processor, the computer or processor performs corresponding steps of the defect detection method described above in the embodiments of the present invention, and is used to implement corresponding modules in the defect detection apparatus or electronic device described above in the embodiments of the present invention. The storage medium may, for example, include a memory card of a smartphone, a storage component of a tablet computer, a hard disk of a personal computer, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disc read-only memory (CD-ROM), a USB memory, or any combination of the above storage media.
[0085] According to another aspect of the present invention, a computer program product is also provided, comprising computer program instructions, which, when executed by a computer or processor, cause the computer or processor to perform corresponding steps of the defect detection method described above.
[0086] Those skilled in the art can understand the specific implementation schemes of the above-mentioned electronic devices and storage media by reading the relevant descriptions of the defect detection methods. For the sake of brevity, they will not be described in detail here.
[0087] Although exemplary embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above exemplary embodiments are merely illustrative and are not intended to limit the scope of the invention. Various changes and modifications can be made therein by those skilled in the art without departing from the scope and spirit of the invention. All such changes and modifications are intended to be included within the scope of the invention as claimed in the appended claims.
[0088] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0089] In the several embodiments provided by this invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed.
[0090] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0091] Similarly, it should be understood that, in order to streamline the invention and aid in understanding one or more of the various aspects of the invention, features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the description of exemplary embodiments of the invention. However, this approach should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the corresponding claims, its inventive point lies in solving the corresponding technical problem with fewer features than all of those in a single disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into that detailed description, wherein each claim itself is a separate embodiment of the invention.
[0092] Those skilled in the art will understand that, apart from the mutual exclusion of features, all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or apparatus so disclosed can be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0093] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the claims, any of the claimed embodiments can be used in any combination.
[0094] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some modules in the defect detection apparatus according to embodiments of the present invention. The present invention can also be implemented as an apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0095] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0096] The above description is merely a specific embodiment of the present invention or an explanation of that embodiment. The scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. The scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for detecting defects, characterized in that, The method includes: Acquire images of the target components, including industrial parts; The image to be tested is input into the trained defect detection model to obtain the target image features corresponding to the image to be tested. The trained defect detection model is trained based on multiple sets of training images including training elements. The incompletely trained defect detection model includes a visual feature representation module, a visual feature difference calculation module, and a noise suppression loss calculation module. The training elements in each training image are free of defects. For each set of training images, the visual feature representation module is used to perform feature extraction processing on the set of training images to obtain the visual feature set corresponding to the set of training images. The visual feature set includes the visual features corresponding to each training image in the set of training images. The visual feature difference calculation module is used to determine the distinguishing features between every two visual features in the set of visual features to serve as the distinguishing feature set. The noise suppression loss calculation module is used to obtain the loss value corresponding to the set of training images based on the distinguishing feature set through noise reduction processing. The defect detection result of the industrial component is determined based on the difference between the target image features and the reference features, wherein the reference features are determined by a trained defect detection model based on at least one of multiple training images.
2. The method as described in claim 1, characterized in that, The step of obtaining the loss value corresponding to the set of training images through noise reduction based on the distinguishing feature set includes: Based on the set of distinguishing features corresponding to the set of training images, determine the weight features corresponding to the set of training images. Based on the weight feature and the set of distinguishing features, the noise region evaluation score feature corresponding to each distinguishing feature in the set of distinguishing features is determined, which is used as the set of noise region evaluation score features corresponding to the training images. Based on the noise region evaluation score feature set corresponding to the training images, noise reduction processing is performed to obtain the loss value corresponding to the training images.
3. The method as described in claim 2, characterized in that, The method of evaluating score features based on the noisy regions corresponding to the set of training images, and obtaining the loss value corresponding to the set of training images through noise reduction processing, includes: Based on the set of noise region evaluation score features and the evaluation score threshold corresponding to the set of training images, the set of noise reduction features corresponding to the set of training images is determined. Based on the set of noise reduction features corresponding to the training images, the loss value corresponding to the training images is determined.
4. The method as described in claim 3, characterized in that, If the number of training rounds of an untrained defect detection model is less than a preset rounds threshold, the evaluation score threshold is negatively correlated with the number of training rounds of the untrained defect detection model.
5. The method as described in claim 3, characterized in that, The step of determining the loss value corresponding to the set of denoising features corresponding to the set of training images includes: The noise reduction feature set corresponding to the training images is subjected to feature fusion processing to obtain the noise reduction representative feature set corresponding to the training images. The set of denoised representative features corresponding to the training images is normalized to obtain the loss value corresponding to the training images.
6. The method as described in claim 2, characterized in that, The step of determining the weight features corresponding to the set of distinguishing features corresponding to the set of training images includes: The set of distinguishing features corresponding to the training images is subjected to feature fusion processing to determine the distinguishing statistical fusion features corresponding to the set of distinguishing features. Based on the difference statistical fusion features corresponding to the difference feature set, or the difference statistical fusion features corresponding to the difference feature set and the weight features corresponding to the previous set of training images, determine the weight features corresponding to the set of training images.
7. A defect detection device, characterized in that, The device includes: The acquisition module is used to acquire images of the industrial components to be tested. The target image feature determination module is used to input the image to be tested into the trained defect detection model to obtain the target image features corresponding to the image to be tested. The trained defect detection model is trained based on multiple sets of training images including training elements. The incompletely trained defect detection model includes a visual feature representation module, a visual feature difference calculation module, and a noise suppression loss calculation module. There are no defects in the training elements in each training image. For each set of training images, the visual feature representation module is used to perform feature extraction processing on the set of training images to obtain the visual feature set corresponding to the set of training images. The visual feature set includes the visual features corresponding to each training image in the set of training images. The visual feature difference calculation module is used to determine the distinguishing features between every two visual features in the set of visual features to serve as the distinguishing feature set. The noise suppression loss calculation module is used to obtain the loss value corresponding to the set of training images based on the distinguishing feature set through noise reduction processing. The defect determination module is used to determine the defect detection result of the industrial component based on the difference between the target image features and the reference features, wherein the reference features are determined by a trained defect detection model based on at least one of a plurality of training images.
8. An electronic device, characterized in that, The device includes a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the computer program to implement the defect detection method as described in any one of claims 1-6.
9. A storage medium storing computer program instructions, characterized in that, The computer program instructions, when executed, are used to perform the defect detection method as described in any one of claims 1-6.
10. A computer program product comprising computer program instructions, characterized in that, The computer program instructions, when executed by a processor, are used to perform the defect detection method as described in any one of claims 1-6.