Defect detection model training method, defect detection method and electronic equipment

By combining a generative neural network and a discriminator model, and training with images of no defects and pseudo-defects, the problem of sample scarcity in the magnetic particle inspection defect detection model was solved, achieving efficient defect detection and improving detection accuracy and recall.

CN121582706APending Publication Date: 2026-02-27CRRC QISHUYAN INSTITUTE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511737840.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-25
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

Existing magnetic particle testing defect detection models suffer from poor performance due to the scarcity, heterogeneity, diversity, and imbalance of defects, making it impossible to obtain a large number of labeled samples.

Method used

A combined model of generative neural network and discriminator is adopted. The generative neural network is trained with defect-free magnetic particle inspection images, and the discriminator is trained with pseudo-defect images. The outputs of the generative neural network and the discriminator are fused by a weight fusion unit to achieve defect detection.

Benefits of technology

High detection performance can be achieved without a large number of labeled samples, reducing the quality risk of target components and improving the accuracy and recall of defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121582706A_ABST
    Figure CN121582706A_ABST
Patent Text Reader

Abstract

The invention discloses a defect detection model training method, a defect detection method and electronic equipment. Wherein the defect detection model comprises a generative neural network and a discriminator; the training method of the defect detection model comprises the following steps: acquiring a first training image, wherein the first training image is a defect-free magnetic powder inspection image obtained by performing image acquisition on a defect-free target part; inputting the first training image into a feature extractor for feature extraction to obtain a first training feature; the first training feature is input into a generative neural network for training, a trained generative neural network is obtained, and the generative neural network is used for detecting defects on the target component; and training a discriminator based on the first training feature and the acquired pseudo defect training image to obtain a trained discriminator, the discriminator being used for detecting pseudo defects on the target component. By implementing the method, high detection performance of the defect detection model can be realized without labeling a large number of training samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application generally relates to the field of artificial intelligence technology. More specifically, this application relates to a method for training a defect detection model, a defect detection method, and an electronic device. Background Technology

[0002] Magnetic particle testing is a non-destructive testing method that utilizes the magnetic field leakage of magnetic powder at the defect to form a magnetic trace, which emits a conspicuous fluorescence under ultraviolet light (or uses colored magnetic powder instead of ultraviolet light) to reveal the surface defects of the workpiece. It is widely used in fields such as rail transportation, wind power, aerospace, petrochemicals and automobile manufacturing.

[0003] After displaying the defective areas of the component under inspection using magnetic particle testing, images of the component are acquired. These acquired images are then input into a pre-trained defect detection model to obtain the defect detection results. The aforementioned defect detection model is obtained through supervised training. Such supervised training requires a large number of manually labeled defect samples (i.e., training samples) to achieve good performance. However, in industrial manufacturing environments, the inherent characteristics of defects—such as scarcity, heterogeneity, diversity, and imbalance—make it impossible to obtain a large number of defect samples, resulting in poor detection performance of the trained defect detection model.

[0004] In view of this, there is an urgent need to provide a training method for a defect detection model, a defect detection method, and an electronic device that can achieve high detection performance of the defect detection model without requiring a large number of labeled training samples. Summary of the Invention

[0005] In order to at least solve one or more of the technical problems mentioned above, this application proposes a training method for a defect detection model, a defect detection method, and an electronic device in several aspects.

[0006] In a first aspect, this application provides a training method for a defect detection model, the defect detection model comprising: a generative neural network and a discriminator; the method comprising: acquiring a first training image, the first training image being a defect-free magnetic particle inspection image obtained by image acquisition of a defect-free target component; inputting the first training image into a feature extractor for feature extraction to obtain a first training feature; inputting the first training feature into a generative neural network for training to obtain a trained generative neural network, the generative neural network being used to detect defects in the target component; and training a discriminator based on the first training feature and acquired pseudo-defect training images to obtain a trained discriminator, the discriminator being used to detect pseudo-defects on the target component.

[0007] In some embodiments, the step of inputting the first training feature into a generative neural network for training to obtain a trained generative neural network includes: inputting the first training feature into the generative neural network to obtain Gaussian distribution data of the first training feature; calculating the likelihood value of the Gaussian distribution data of the first training feature according to a variable transformation formula; calculating the loss value of the generative neural network based on the likelihood value, adjusting the model parameters of the generative neural network based on the loss value, and returning to the step of inputting the first training feature into the generative neural network until the loss value meets a set loss value condition to obtain the generative neural network.

[0008] In some embodiments, the defect detection model further includes a weight fusion unit; after obtaining a trained discriminator, the method further includes: acquiring a second training image and training annotation information of the second training image; inputting the second training image into the feature extractor for feature extraction to obtain a second training feature; inputting the second training feature into a trained generative neural network to obtain a first classification result; and inputting the second training feature into a trained discriminator to obtain a second classification result; and training the weight fusion unit based on the first classification result, the second classification result, and the training annotation information to obtain a trained weight fusion unit.

[0009] In some embodiments, the second training image includes a defect-free magnetic particle inspection image, a real defect magnetic particle inspection image, and a pseudo-defect magnetic particle inspection image.

[0010] In some embodiments, training the weight fusion device based on the first classification result image, the second classification result image, and the training annotation information to obtain a trained weight fusion device includes: inputting the first classification result and the second classification result together into the weight fusion device, and outputting a first weight of the first classification result and a second weight of the second classification result; calculating a defect score of the second training image based on the first classification result and the first weight, and the second classification result and the second weight; adjusting the model parameters of the weight fusion device based on the error between the training annotation information and the defect score, and returning to the step of inputting the first classification result and the second classification result together into the weight fusion device until the error between the training annotation information and the defect score meets a set error condition, thereby obtaining a trained weight fusion device.

[0011] In some embodiments, the method further includes: obtaining a manual review result of the defect score of the second training image; if the review result indicates that the defect score is incorrect, then fine-tuning the model parameters of the trained weight fusion device based on reinforcement learning.

[0012] In some embodiments, the method further includes: acquiring a test sample carrying test annotation information; inputting the test image into a feature extractor for feature extraction to obtain test features; inputting the test features into a defect detection model, so that a trained generative neural network in the defect detection model outputs a first test result based on the test features, a trained discriminator outputs a second test result based on the test features, and a trained weight fusion unit obtains a defect detection result of the test sample based on the first test result, the second test result, and the test features; and evaluating the performance of the defect detection model based on the defect detection result of the test sample and the test annotation information.

[0013] In a second aspect, this application provides a defect detection method, the method comprising: acquiring an image to be detected, the image to be detected being a magnetic particle inspection image obtained by image acquisition of a target component to be detected; inputting the image to be detected into a feature extractor for feature extraction to obtain a feature to be detected; inputting the feature to be detected into a defect detection model to obtain a defect detection result of the image to be detected, wherein the defect detection model is trained by the defect detection training method described in the first aspect or any of the embodiments of the first aspect.

[0014] In some embodiments, after obtaining the defect detection result of the image to be detected, the method further includes: determining whether the component to be detected is qualified based on a pre-set statistical threshold and the defect detection result.

[0015] In a third aspect, this application provides a training apparatus for a defect detection model, the defect detection model comprising: a generative neural network and a discriminator; the apparatus comprising: a first training image acquisition module for acquiring a first training image, the first training image being a defect-free magnetic particle inspection image obtained by image acquisition of a defect-free target component; a first feature extraction module for inputting the first training image into a feature extractor for feature extraction to obtain a first training feature; a generative neural network training module for inputting the first training feature into a generative neural network for training to obtain a trained generative neural network, the generative neural network being used to detect defects on the target component; and a discriminator training module for training a discriminator based on the first training feature and the acquired pseudo-defect training image to obtain a trained discriminator, the discriminator being used to detect pseudo-defects on the target component.

[0016] In a fourth aspect, this application provides a defect detection apparatus, the apparatus comprising: a target image acquisition module for acquiring a target image, wherein the target image is a magnetic particle inspection image obtained by image acquisition of a target component; a third feature extraction module for inputting the target image into a feature extractor for feature extraction to obtain a target feature; and a defect detection module for inputting the target feature into a defect detection model to obtain a defect detection result of the target image, wherein the defect detection model is trained by the defect detection training method described in the first aspect or any of the embodiments of the first aspect.

[0017] In a fifth aspect, this application provides an electronic device comprising: a processor configured to execute program instructions; and a memory configured to store the program instructions, which, when loaded and executed by the processor, cause the processor to perform a training method for a defect detection model according to the first aspect or any embodiments thereof, or a defect detection method as described in the second aspect or any embodiments thereof.

[0018] In a sixth aspect, this application provides a computer-readable storage medium storing program instructions that, when loaded and executed by a processor, cause the processor to perform a training method for a defect detection model according to the first aspect or any embodiments thereof, or a defect detection method as described in the second aspect or any embodiments thereof.

[0019] Using the defect detection model training method, defect detection method, and electronic device provided above, the defect detection model in this application includes a generative neural network and a discriminator. The generative neural network is trained using defect-free magnetic particle inspection images, and the discriminator is trained using defect-free magnetic particle inspection images and pseudo-defect magnetic particle inspection images, thereby obtaining a trained defect detection model. High detection performance of the defect detection model can be achieved without a large number of labeled training samples. Using this trained defect detection model to perform defect detection on the target component can greatly reduce the quality risk of the target component. Attached Figure Description

[0020] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, and the same or corresponding reference numerals denote the same or corresponding parts, wherein: Figure 1 An exemplary flowchart of a training method for a defect detection model according to some embodiments of this application is shown; Figure 2This paper illustrates a schematic diagram of the training process of each module in the defect detection model of some embodiments of this application; Figure 3 An exemplary flowchart of a defect detection method according to some embodiments of this application is shown; Figure 4 An exemplary structural block diagram of a training apparatus for a defect detection model according to some embodiments of this application is shown; Figure 5 An exemplary structural block diagram of a defect detection apparatus according to some embodiments of this application is shown; Figure 6 An exemplary structural block diagram of a defect detection apparatus according to some embodiments of this application is shown. Detailed Implementation

[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0022] It should be understood that the terms "comprising" and "including" used in the specification and claims of this application indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0023] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application. As used in this specification and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this specification and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.

[0024] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0025] The specific embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0026] Figure 1 An exemplary flowchart illustrating a training method for a defect detection model according to some embodiments of this application is shown. It is understood that the above-described defect detection model training method 100 can be executed by any suitable device with data processing capabilities, such as, but not limited to, terminal devices, processors, and servers.

[0027] In this embodiment, the defect detection model refers to an artificial intelligence model used to identify surface defects of a target component. It may include a generative neural network and a discriminator, and may further include the generative neural network, the discriminator, and a weight fusion module. The generative neural network is used to extract defects on the target component, which may include both real and spurious defects. The discriminator is used to detect spurious defects on the target component. The weight fusion module is used to perform a weighted fusion of the output of the generative neural network and the output of the discriminator.

[0028] In the embodiments of this application, pseudo-defects refer to interference factors that are not caused by product quality issues, such as dust, fibers, temporary stains, etc.

[0029] like Figure 1 As shown, the training method 100 for the defect detection model includes: step S110: acquiring a first training image, which is a defect-free magnetic particle inspection image obtained by image acquisition of a defect-free target component; step S120: inputting the first training image into a feature extractor for feature extraction to obtain a first training feature; step S130: inputting the first training feature into a generative neural network for training to obtain a trained generative neural network; and step S140: training a discriminator based on the first training feature and the acquired pseudo-defect training image to obtain a trained discriminator, which is used to detect pseudo-defects on the target component.

[0030] For example, the first training image in step S110 above refers to the defect-free magnetic particle inspection image obtained by image acquisition of the defect-free target component. Here, the defect-free magnetic particle inspection image refers to an image with no structural damage or defects on the surface. In this embodiment of the application, the number of first training images is multiple.

[0031] In this application embodiment, the target component is an industrial product or part to be inspected, such as a bearing, fastener, weld, brake disc, blade, wheel axle, etc.

[0032] Before performing step S110, the target part can be cleaned, then sprayed with magnetic suspension and magnetized. Then, under ultraviolet light irradiation, an image acquisition device (e.g., an industrial camera or a regular camera) acquires images of multiple defect-free target parts at a fixed shooting angle, fixed shooting distance, and fixed exposure time to obtain the first training image (i.e., a defect-free magnetic particle inspection image).

[0033] For example, the feature extractor in step S120 above (corresponding to Figure 2 The neural network feature extraction is used to extract high-dimensional feature vectors (i.e., the first training features) from the input image (i.e., the first training image mentioned above). These high-dimensional feature vectors may include low-level information such as texture, color, and boundaries, as well as high-level semantic information, etc.

[0034] In this embodiment, the feature extractor (denoted as FE) can be an existing pre-trained convolutional neural network (e.g., ResNet-50, VGG16, etc.). Of course, the feature extractor can also be trained based on the magnetic particle inspection scenario. This embodiment does not specifically limit this and can be determined according to the actual situation.

[0035] For example, the generative neural network in step S130 above is used to extract defects on the target component. Specifically, during training, the generative neural network needs to learn the distribution patterns of features (i.e., the first training features) of a large number of defect-free magnetic particle inspection images. Then, during use, defects on the target component can be identified by comparing the difference between the feature to be detected and the feature distribution patterns of the defect-free magnetic particle inspection images.

[0036] As one specific implementation of this application, such as Figure 2 As shown, the generative neural network includes a channel separation module, at least two convolutional layers (i.e., 2D convolutions) and two coupling layers. After the first training feature enters the generative neural network, the channel separation module splits the first training feature into two channel features, which are then processed by different processing modules.

[0037] It should be noted that, Figure 2 The generative neural network shown is for illustrative purposes only, and any reasonable model structure is within the scope of protection of this application.

[0038] The specific training process for generative neural networks is described in the following examples, and will not be repeated here.

[0039] For example, the pseudo-defect training image in step S140 above refers to an image of the target component including the pseudo-defect, which can be simulated and generated on the first training image, for example, Figure 2In this process, simulated or actually acquired pseudo-defects are added to the first training image to form a pseudo-defect training image; or the image can be directly acquired from the target component containing the pseudo-defect.

[0040] In this embodiment, the discriminator is used to detect false defects on the target component. Specifically, the discriminator needs to learn the features of the false defect image during training, and then identify the false defects in the features to be detected during use, avoiding the defect detection model from misclassifying false defects as real defects and improving the defect detection accuracy.

[0041] In the embodiments of this application, such as Figure 2 As shown, the discriminator may include at least one convolutional layer (e.g., 1D convolution) and at least one multilayer perceptron mechanism. The discriminator is trained based on the first training features and the acquired pseudo-defect training images. Specifically, the pseudo-defect images are input into the aforementioned feature extractor for feature extraction to obtain pseudo-image features. Then, the first training features are used as positive samples for the discriminator, and the pseudo-image features are used as negative samples for the discriminator, both input together for training. This allows the discriminator to learn both defect-free and pseudo-defect features, thereby enabling the trained discriminator to identify pseudo-defects in the target component.

[0042] This application embodiment trains a generative neural network using defect-free magnetic particle inspection images and a discriminator using defect-free magnetic particle inspection images and pseudo-defect magnetic particle inspection images, thereby obtaining a trained defect detection model. High detection performance of the defect detection model can be achieved without a large number of labeled training samples. Using this trained defect detection model to detect defects in the target component can greatly reduce the quality risk of the target component.

[0043] As an optional embodiment of this application, the first training feature is input into the generative neural network for training to obtain a trained generative neural network, including: inputting the first training feature into the generative neural network to obtain Gaussian distribution data of the first training feature; calculating the likelihood value of the Gaussian distribution data of the first training feature according to the variable transformation formula; calculating the loss value of the generative neural network based on the likelihood value, and adjusting the model parameters of the generative neural network based on the loss value, and returning to execute the step of inputting the first training feature into the generative neural network until the loss value meets the set loss value condition to obtain the generative neural network.

[0044] For example, Gaussian distribution data refers to data that conforms to a normal distribution, which includes the mean and standard deviation; the normal distribution in this application embodiment can be a standard normal distribution, that is, a distribution with a mean μ of 0 and a standard deviation σ of 1.

[0045] In this embodiment of the application, the first training feature is input into the generative neural network, and the generative neural network maps the distribution of the first training feature to a standard normal distribution to obtain the Gaussian distribution data of the first training feature.

[0046] In the embodiments of this application, the likelihood value refers to the probability value of the first training feature vector x in the Gaussian distribution learned by the generative neural network. The higher the likelihood value, the more x conforms to the distribution of defect-free features, and vice versa.

[0047] The above variable transformation formula refers to a mathematical formula used to transform the probability density of a high-dimensional feature vector from the original space to a Gaussian distribution space. In this application embodiment, the variable transformation formula of a flow model can be used:

[0048] Where x represents the first training feature vector; Represents the likelihood value; z represents the Gaussian distribution vector; This represents the probability density of a Gaussian distribution vector; Represents the inverse transform function; This represents the absolute value of the Jacobian determinant of the inverse transformation.

[0049] In this embodiment, the loss function can be the negative log-likelihood loss. Calculating the loss value of the generative neural network based on the likelihood value involves inputting the likelihood value into the negative log-likelihood loss function to obtain the loss value. The negative log-likelihood loss function is shown in the following equation:

[0050] in, Indicates the loss value; N represents the sample size; This represents the feature vector of the i-th sample; Let represent the likelihood value of the i-th sample.

[0051] In the embodiments of this application, the aforementioned setting of loss value conditions refers to pre-set training termination conditions, which can be implemented in many ways, such as loss value convergence, or loss value being less than or equal to a set loss value threshold (e.g., 0.05), etc. The embodiments of this application do not specifically limit this.

[0052] The model parameters of the above-mentioned generative neural network model may include learnable parameters such as weights and biases. In the embodiments of this application, the backpropagation algorithm can be used to adjust the model parameters based on the loss value, and then the step of inputting the first training feature into the generative neural network can be returned to perform iterative training until the loss value meets the set loss value condition, and the generative neural network can be obtained.

[0053] As an optional embodiment of this application, the defect detection model further includes: a weight fusion unit; after obtaining the trained discriminator, the training method 100 of the defect detection model further includes: acquiring a second training image and training annotation information of the second training image; inputting the second training image into a feature extractor for feature extraction to obtain a second training feature; inputting the second training feature into a trained generative neural network to obtain a first classification result; and inputting the second training feature into a trained discriminator to obtain a second classification result; and training the weight fusion unit based on the first classification result, the second classification result, and the training annotation information to obtain a trained weight fusion unit.

[0054] For example, in this embodiment of the application, the number of second training images is multiple, which may include defect-free magnetic particle inspection images, real-defect magnetic particle inspection images, and pseudo-defect magnetic particle inspection images. These second training images can be acquired by an image acquisition device. Here, "real defects" refers to defects such as cracks and dents present in the target component itself.

[0055] It should be noted that the aforementioned defect-free magnetic particle inspection image can also be the aforementioned first training image, and the aforementioned pseudo-defect image can also be the pseudo-defect image obtained during the training of the discriminator.

[0056] In this embodiment, the training annotation information serves as supervision to determine the accuracy of the fusion result. It refers to the label of each pixel in the second training image; for example, a defect-free pixel is labeled 0, a pseudo-defect is labeled 1, and a real defect is labeled 2. In this embodiment, common annotation tools can be used to annotate the second training image, and the annotation results can be directly obtained.

[0057] The first classification result is the probability that each pixel in the second training image is a defect; the second classification result is the probability that each pixel in the second training image is a false defect.

[0058] In this embodiment, the weight fusion processor is trained based on the first classification result, the second classification result, and the training annotation information to obtain a trained weight fusion processor. Specifically, the process involves: inputting the first classification result and the second classification result into the weight fusion processor together, and outputting the first weight of the first classification result and the second weight of the second classification result; calculating the defect score of the second training image based on the first classification result and the first weight, the second classification result and the second weight; adjusting the model parameters of the weight fusion processor based on the error between the training annotation information and the defect score; and returning to the step of inputting the first classification result and the second classification result into the weight fusion processor together until the error between the training annotation information and the defect score meets the set error condition, thereby obtaining a trained weight fusion processor.

[0059] For example, in this embodiment, the weight fusion unit refers to a module used to weight and fuse the output of the generative neural network (i.e., the first classification result mentioned above) and the output of the discriminator (i.e., the second classification result mentioned above). By dynamically adjusting the weights, the accuracy of defect detection is improved. By setting the weight fusion unit, this embodiment can reduce the proportion of false defects in the final defect detection result.

[0060] In this embodiment, the first classification result (denoted as A) and the second classification result (denoted as B) are input together into the weight fusion unit, which outputs the first weight (denoted as W1) of the first classification result and the second weight (denoted as W2) of the second classification result, where W1 + W2 = 1. For example, if the defect probability in the first classification result A is 0.9 and the false defect probability in the second classification result B is 0.1, then the first weight W1 output by the weight fusion unit can be 0.8 and the second weight W2 can be 0.2.

[0061] In this embodiment, the defect score Y of the second training image, calculated based on the first classification result and the first weight, the second classification result and the second weight, can be specifically calculated using the following formula:

[0062] The higher the defect score Y, the higher the probability that the second training image is a real defect image.

[0063] After calculating the defect score of the second training image, the error between the training annotation information and the defect score can be calculated. This error can be the mean squared error, etc. Based on the calculated error, the model parameters of the weight fusion unit (e.g., bias, weights, etc.) are adjusted through backpropagation. Then, the process of inputting the first and second classification results into the weight fusion unit is repeated iteratively to reduce the error until the error between the training annotation information and the defect score meets the set error condition (e.g., the error is less than the set error threshold (e.g., 0.005)), resulting in the trained weight fusion unit.

[0064] As an optional embodiment of this application, after training the defect detection model, it is also necessary to evaluate the performance of the defect detection model. Specifically, the evaluation can be carried out through the following steps: obtaining test samples, which carry test annotation information; inputting the test image into a feature extractor for feature extraction to obtain test features; inputting the test features into the defect detection model, so that the trained generative neural network in the defect detection model outputs a first test result based on the test features, the trained discriminator outputs a second test result based on the test features, and the trained weight fusion unit outputs the defect detection result of the test sample based on the first test result, the second test result, and the test features; and evaluating the performance of the defect detection model based on the defect detection result and test annotation information of the test sample.

[0065] For example, the test samples mentioned above include multiple test images used to evaluate the performance of the defect detection model. These images need to include real defect images, defect-free images, and pseudo-defect images, and they must be completely different from the images used when training the defect detection model.

[0066] In this embodiment, the test samples carry test annotation information. This test annotation information can be obtained by manually annotating the test samples. For specific annotation information, please refer to the description of training annotation information in the above embodiment, which will not be repeated here.

[0067] For example, after obtaining the test sample, the test sample is input into the feature extractor to extract features and obtain test features. Then, the test features are input into the defect detection model. The generative neural network in the defect detection model outputs the first test result, and the discriminator in the defect detection model outputs the second test result. Then, the first test result and the second test result are input into the weight fusion unit in the defect detection model. The weight fusion unit outputs the weights of the first test result and the weights of the second test result. Based on the weights of the first test result and the first test result, the weights of the second test result and the second test result, the defect score (i.e., the defect detection result of the above test sample) is calculated.

[0068] Then, the performance of the defect detection model is evaluated based on the defect detection results and test annotation information of the test samples. Specifically, the model performance evaluation indicators such as recall and accuracy can be calculated by comparing the defect detection results of each test sample with the test annotation information of that test sample. Then, the performance of the defect detection model is determined based on the performance evaluation indicators. If the performance is good (e.g., recall greater than or equal to 99% or accuracy greater than or equal to 95%), the defect detection model can be directly used for defect detection. If the performance is poor (e.g., recall less than 99% or accuracy less than 95%), the defect detection model can be optimized. The specific optimization method is the same as the training method described above, and will not be repeated here.

[0069] The methods for calculating recall and precision are conventional algorithms, which can be found in relevant documentation and will not be elaborated upon here.

[0070] The embodiments of this application can train a high-performance defect detection model with a small number of labeled real defect samples. According to the test, the defect detection accuracy of the trained defect detection model can reach more than 95%, and the defect magnetic trace recall rate can reach more than 99%.

[0071] As an optional embodiment of this application, the training method 100 for the defect detection model further includes: obtaining the result of a manual review of the defect score of the second training image; if the review result indicates that the defect score is incorrect, then fine-tuning the model parameters of the trained weight fusion device based on reinforcement learning.

[0072] For example, in this embodiment of the application, it is necessary to manually sample and re-examine the defect scores of the second training image. After obtaining the re-examination results, if the re-examination results indicate that the defect scores are incorrect, i.e., inconsistent with the actual results, the model parameters of the trained weight fusion machine are fine-tuned based on reinforcement learning until the re-examination results indicate that they are normal.

[0073] This application embodiment adjusts the model parameters of the weight fusion unit in real time through reinforcement learning, and can automatically learn the situation of defect detection errors caused by changes in the detection environment (e.g., illumination, magnetic suspension concentration, etc.).

[0074] Figure 3 An exemplary flowchart of a defect detection method according to some embodiments of this application is shown.

[0075] like Figure 3As shown, the defect detection method 300 includes: step S310: acquiring an image to be detected; step S320: inputting the image to be detected into a feature extractor for feature extraction to obtain the features to be detected; step S330: inputting the features to be detected into a defect detection model to obtain the defect detection result of the image to be detected, wherein the defect detection model is trained by the defect detection training method of the above embodiment.

[0076] For example, the image to be detected in step S310 above is a magnetic particle inspection image obtained by image acquisition of the target component to be inspected. It can be a defect-free magnetic particle inspection image or a defective magnetic particle inspection image. The defective magnetic particle inspection image may include only false defects, only real defects, or both false defects and real defects. This application embodiment does not specifically limit the image to be detected.

[0077] For example, after acquiring the image to be detected, the image is input into a feature extractor to extract features and obtain the features to be detected. Then, the features to be detected are input into a defect detection model. The generative neural network in the defect detection model outputs the first detection result of the features to be detected, and the discriminator in the defect detection model outputs the second detection result of the features to be detected. Then, the first detection result and the second detection result are input into the weight fusion unit in the defect detection model. The weight fusion unit outputs the weight of the first detection result and the weight of the second detection result. Based on the weight of the first detection result and the weight of the second detection result, the defect score (i.e., the above defect detection result) is calculated.

[0078] As an optional embodiment of this application, after obtaining the defect detection result of the image to be detected, the defect detection method 300 further includes: determining whether the component to be detected is qualified based on the pre-set statistical threshold and the defect detection result.

[0079] For example, the above statistical threshold can be set in advance according to the needs, such as 60%, that is, if the defective pixels are greater than 60%, they are unqualified, otherwise they are qualified.

[0080] Figure 4 An exemplary structural block diagram of a training apparatus for a defect detection model according to some embodiments of this application is shown.

[0081] The aforementioned defect detection model includes a generative neural network and a discriminator. As shown in Figure 4, the training device 400 for the defect detection model includes: a first training image acquisition module 410, used to acquire a first training image, which is a defect-free magnetic particle inspection image obtained by image acquisition of a defect-free target component; a first feature extraction module 420, used to input the first training image into a feature extractor for feature extraction to obtain a first training feature; a generative neural network training module 430, used to input the first training feature into a generative neural network for training to obtain a trained generative neural network, which is used to detect defects on the target component; and a discriminator training module 440, used to train the discriminator based on the first training feature and the acquired pseudo-defect training image to obtain a trained discriminator, which is used to detect pseudo-defects on the target component.

[0082] As an optional embodiment of this application, the generative neural network training module 430 is specifically used for: inputting a first training feature into the generative neural network to obtain Gaussian distribution data of the first training feature; calculating the likelihood value of the Gaussian distribution data of the first training feature according to the variable transformation formula; calculating the loss value of the generative neural network based on the likelihood value, adjusting the model parameters of the generative neural network based on the loss value, and returning to execute the step of inputting the first training feature into the generative neural network until the loss value meets the set loss value condition to obtain the generative neural network.

[0083] As an optional embodiment of this application, the defect detection model further includes: a weight fusion unit; after obtaining the trained discriminator, the training device 400 of the defect detection model further includes: a second training image acquisition module, used to acquire a second training image and training annotation information of the second training image; a second feature extraction module, used to input the second training image into a feature extractor for feature extraction to obtain a second training feature; a first classification result acquisition module, used to input the second training feature into a trained generative neural network to obtain a first classification result; and a second classification result acquisition module, used to input the second training feature into a trained discriminator to obtain a second classification result; and a weight fusion unit training module, used to train the weight fusion unit based on the first classification result, the second classification result, and the training annotation information to obtain a trained weight fusion unit.

[0084] As an optional embodiment of this application, the second training image includes a defect-free magnetic particle inspection image, a real defect magnetic particle inspection image, and a pseudo-defect magnetic particle inspection image.

[0085] As an optional embodiment of this application, the weight fusion training module is specifically used to input the first classification result and the second classification result together into the weight fusion module, output the first weight of the first classification result and the second weight of the second classification result; calculate the defect score of the second training image based on the first classification result and the first weight, the second classification result and the second weight; adjust the model parameters of the weight fusion module based on the error between the training annotation information and the defect score, and return to execute the step of inputting the first classification result and the second classification result together into the weight fusion module until the error between the training annotation information and the defect score meets the set error condition, and obtain the trained weight fusion module.

[0086] As an optional embodiment of this application, the training device 400 of the above-mentioned defect detection model further includes: a fine-tuning module, used to obtain the re-examination result of the defect score of the second training image by a human, and if the re-examination result indicates that the defect score is wrong, then fine-tuning the model parameters of the trained weight fusion device based on reinforcement learning.

[0087] As an optional embodiment of this application, the training device 400 for the above-mentioned defect detection model further includes: a test sample acquisition module for acquiring test samples, wherein the test samples carry test annotation information; a test feature extraction module for inputting test images into a feature extractor for feature extraction to obtain test features; a defect detection result acquisition module for inputting the test features into the defect detection model, so that the trained generative neural network in the defect detection model outputs a first test result based on the test features, the trained discriminator outputs a second test result based on the test features, and the trained weight fusion unit outputs the defect detection result of the test sample based on the first test result, the second test result, and the test features; and a performance evaluation module for evaluating the performance of the defect detection model based on the defect detection result and test annotation information of the test sample.

[0088] Figure 5 An exemplary flowchart of a defect detection apparatus according to some embodiments of this application is shown.

[0089] like Figure 5 As shown, the defect detection device 500 includes: a target image acquisition module 510, used to acquire a target image, which is a magnetic particle inspection image obtained by image acquisition of the target component to be detected; a third feature extraction module 520, used to input the target image into a feature extractor for feature extraction to obtain the target feature; and a defect detection module 530, used to input the target feature into a defect detection model to obtain the defect detection result of the target image, wherein the defect detection model is trained by the defect detection training method described in the above embodiment.

[0090] As some embodiments of this application, the above-mentioned defect detection device 500 further includes: a qualification determination module, used to determine whether the component to be detected is qualified based on a pre-set statistical threshold and the defect detection result.

[0091] Correspondingly, embodiments of this application also provide Figure 4 or Figure 5 The hardware structure diagram of the device shown is as follows: Figure 6 As shown, the electronic device 600 can be a device for implementing the training method 100 or the defect detection method 300 of the above-described defect detection model. Figure 6 As shown, the electronic device 600 includes a processor 610 and a memory 620. The memory 620 is configured to store program instructions; the processor 610 is configured to load and execute the program instructions stored in the memory 620 to implement an embodiment of the defect detection model training method 100 or an embodiment of the defect detection method 300 as shown above.

[0092] As one embodiment, memory 620 can be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as program instructions, data, etc. For example, memory 620 can be volatile memory, non-volatile memory, or similar storage media. Specifically, memory 620 can be RAM (Random Access Memory), flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or combinations thereof.

[0093] This concludes the process. Figure 6 Description of the electronic device shown.

[0094] While numerous embodiments of this application have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will arise for those skilled in the art without departing from the spirit and intent of this application. It should be understood that various alternatives to the embodiments of this application described herein may be employed in the practice of this application. The appended claims are intended to define the scope of protection of this application and therefore cover equivalents or alternatives within the scope of these claims.

Claims

1. A training method for a defect detection model, characterized in that, The defect detection model includes a generative neural network and a discriminator; the method includes: Acquire a first training image, which is a defect-free magnetic particle inspection image obtained by image acquisition of a defect-free target component; The first training image is input into a feature extractor for feature extraction to obtain the first training features; The first training feature is input into a generative neural network for training to obtain a trained generative neural network, which is used to detect defects on a target component; and The discriminator is trained based on the first training feature and the acquired pseudo-defect training images to obtain a trained discriminator, which is used to detect pseudo-defects on the target component.

2. The method according to claim 1, characterized in that, The step of inputting the first training feature into the generative neural network for training to obtain a trained generative neural network includes: The first training feature is input into a generative neural network to obtain Gaussian distribution data of the first training feature; Calculate the likelihood value of the Gaussian distribution data of the first training feature according to the variable transformation formula; The loss value of the generative neural network is calculated based on the likelihood value, and the model parameters of the generative neural network are adjusted based on the loss value. The process then returns to the step of inputting the first training feature into the generative neural network until the loss value meets the set loss value condition, thus obtaining the generative neural network.

3. The method according to claim 1, characterized in that, The defect detection model further includes a weighted fusion unit; after obtaining the trained discriminator, the method further includes: Obtain the second training image and the training annotation information of the second training image; The second training image is input into the feature extractor for feature extraction to obtain the second training features; The second training feature is input into the pre-trained generative neural network to obtain the first classification result; and The second training feature is input into the trained discriminator to obtain the second classification result; The weight fusion device is trained based on the first classification result, the second classification result, and the training annotation information to obtain the trained weight fusion device.

4. The method according to claim 3, characterized in that, The second training images include defect-free magnetic particle inspection images, real defect magnetic particle inspection images, and pseudo-defect magnetic particle inspection images.

5. The method according to claim 3, characterized in that, The step of training the weight fusion device based on the first classification result image, the second classification result image, and the training annotation information to obtain the trained weight fusion device includes: The first classification result and the second classification result are input together into the weight fusion unit, and the first weight of the first classification result and the second weight of the second classification result are output. The defect score of the second training image is calculated based on the first classification result and the first weight, the second classification result and the second weight; The model parameters of the weight fusion unit are adjusted based on the error between the training annotation information and the defect score. The process then returns to the step of inputting the first classification result and the second classification result into the weight fusion unit together until the error between the training annotation information and the defect score meets the set error condition, thus obtaining the trained weight fusion unit.

6. The method according to claim 5, characterized in that, The method further includes: Obtain the result of manual review of the defect score of the second training image. If the review result indicates that the defect score is incorrect, fine-tune the model parameters of the trained weight fusion machine based on reinforcement learning.

7. The method according to claim 5, characterized in that, The method further includes: Obtain test samples, which carry test labeling information; The test image is input into a feature extractor for feature extraction to obtain test features; The test features are input into the defect detection model, so that the trained generative neural network in the defect detection model outputs a first test result based on the test features, the trained discriminator outputs a second test result based on the test features, and the trained weight fusion unit obtains the defect detection result of the test sample based on the first test result, the second test result, and the test features. The performance of the defect detection model is evaluated based on the defect detection results of the test samples and the test annotation information.

8. A defect detection method, characterized in that, The method includes: Acquire the image to be inspected, which is a magnetic particle inspection image obtained by image acquisition of the target component to be inspected; The image to be detected is input into a feature extractor for feature extraction to obtain the features to be detected. The feature to be detected is input into the defect detection model to obtain the defect detection result of the image to be detected, wherein the defect detection model is trained by the defect detection training method according to any one of claims 1-7.

9. The method according to claim 8, characterized in that, After obtaining the defect detection result of the image to be detected, the method further includes: The quality of the component to be tested is determined based on the pre-set statistical thresholds and the defect detection results.

10. A training device for a defect detection model, characterized in that, The defect detection model includes a generative neural network and a discriminator; the device includes: The first training image acquisition module is used to acquire a first training image, which is a defect-free magnetic particle inspection image obtained by image acquisition of a defect-free target component. The first feature extraction module is used to input the first training image into the feature extractor for feature extraction to obtain the first training features; A generative neural network training module is used to input the first training features into the generative neural network for training, thereby obtaining a trained generative neural network, which is used to detect defects on a target component; and The discriminator training module is used to train the discriminator based on the first training features and the acquired pseudo-defect training images to obtain a trained discriminator, which is used to detect pseudo-defects on the target component.

11. A defect detection device, characterized in that, The device includes: The image acquisition module is used to acquire the image to be inspected, which is a magnetic particle inspection image obtained by image acquisition of the target component to be inspected. The third feature extraction module is used to input the image to be detected into the feature extractor for feature extraction to obtain the features to be detected; A defect detection module is used to input the features to be detected into a defect detection model to obtain the defect detection result of the image to be detected, wherein the defect detection model is trained by the defect detection training method according to any one of claims 1-7.

12. An electronic device, characterized in that, include: A processor, configured to execute program instructions; as well as A memory configured to store the program instructions, which, when loaded and executed by the processor, cause the processor to perform the training method of the defect detection model according to any one of claims 1-7 or the defect detection method according to any one of claims 8-9.

13. A computer-readable storage medium storing program instructions, characterized in that, When the program instructions are loaded and executed by the processor, the processor performs the training method of the defect detection model according to any one of claims 1-7 or the defect detection method according to any one of claims 8-9.