Reverse learning-based two-stage intelligent identification method and system for X-ray image of unequal-thickness welding seam defect
Through the two-stage identification method of reverse learning, positive samples and negative samples are used to train the weld defect recognition model, and combined with slicing technology, the sample dependence problem of X-ray image recognition of weld defects in the existing technology is solved, and high efficiency is achieved. , Accurate weld defect identification.
Patent Information
- Application Number
- CN202410658124.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-05-24
AI Technical Summary
Existing deep learning-based automatic identification methods for weld defect X-ray images rely heavily on a large amount of training data, especially when it is difficult to obtain defective image samples. Moreover, methods that rely on a small number of samples are not accurate enough to achieve efficient and accurate identification.
A two-stage intelligent identification method using reverse learning is used. In the first stage, positive samples and negative samples are used to train the potential area identification model of weld defects. In the second stage, only negative samples are used to accurately identify defects, and the potential areas of weld defects are processed through slicing technology. , improve recognition efficiency and accuracy.
It achieves efficient and accurate identification of weld defects with a small number of samples, avoids the deep learning model's dependence on a large number of positive samples, and improves identification accuracy and efficiency.
Smart Images

Figure CN118587174A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of nondestructive testing, and more particularly to a reverse learning two-stage intelligent recognition method and system for X-ray images of weld defects of unequal thickness. Background Art
[0002] Nondestructive testing technology is widely used in the detection of weld defects. Among them, X-ray digital imaging technology is mainly used to image the welds of various aluminum and steel materials due to its high detection accuracy. Then, experienced experts judge the weld images to determine whether there are defects, or artificial intelligence algorithms are used to automatically judge the weld images. The existing artificial intelligence-based automatic recognition methods for weld defect X-ray images are heavily dependent on training data sets. For some fields, it is very difficult to obtain a large number of defective weld X-ray images. Therefore, the existing deep learning methods based on big data are not applicable, and the accuracy of the existing meta-learning and transfer learning methods that rely on a small number of samples needs to be improved, and the purpose of application cannot be achieved.
[0003] In order to realize intelligent and accurate recognition of weld defects using a small number of defective weld X-ray image samples, it is necessary to study a method different from conventional deep learning. Conventional deep learning models realize the recognition of test images by directly learning the feature patterns of positive samples. In order to learn the accurate feature patterns of positive samples, a large number of positive samples are required as training data. The reverse learning method can indirectly judge whether the target exists by learning the feature patterns of negative samples. In addition, since only a part of the weld image obtained by X-ray digital imaging technology is the weld area, the rest are useless background areas, and those useless background areas not only produce potential misidentification areas for the recognition of the target, but also reduce the recognition efficiency. Therefore, the present invention proposes a method that can intelligently and accurately recognize X-ray images of weld defects using only a small number of positive samples plus some negative samples. Summary of the invention
[0004] In view of this, the present invention provides a two-stage intelligent recognition method and system for X-ray images of unequal thickness weld defects based on reverse learning, so as to achieve the purpose of intelligent, efficient and accurate recognition of weld defects.
[0005] In order to achieve the above object, the present invention adopts the following technical solution:
[0006] A two-stage intelligent recognition method for X-ray images of unequal thickness weld defects based on reverse learning, comprising:
[0007] Acquire a weld image and establish a first data set; an image with defects in the weld image is a positive sample, and an image without defects in the weld image is a negative sample; establish a second data set based on the positive sample;
[0008] Inputting the first data set into a preset weld defect potential area recognition model to train the weld defect potential area recognition model; inputting the second data set into a preset weld defect precise recognition model to train the weld defect precise recognition model;
[0009] Acquire a weld image to be identified, input the weld image to be identified into the trained weld defect potential area identification model to identify and obtain the defect potential area of the weld image to be identified; slice the weld defect potential area to obtain a slice image, use the slice image as the input of the trained weld defect precise identification model, and identify and mark the slice image in which the defect potential area exists.
[0010] Preferably, the method further includes marking potential defect areas of the weld of the positive sample; and performing a slicing operation on the negative sample.
[0011] Preferably, the preset weld defect potential area recognition model is specifically a YOLOv8 target detection network model, and parameters trained on the ImageNet data set are used as pre-training parameters of the YOLOv8 target detection network model.
[0012] Preferably, the weld defect accurate identification model specifically includes: a generation module, a recoding module, and a discrimination module. The generation module obtains the slice feature map of the slice image and reconstructs it to obtain a slice reconstruction map; the recoding module extracts the reconstructed feature map of the slice reconstruction map; the discrimination module inputs the reconstructed feature map and the slice image, makes a judgment on the reconstructed feature map and the slice image, and helps the generation module learn the characteristics of a normal weld image.
[0013] Preferably, the generation module specifically includes an encoding submodule and a decoding submodule, and the specific structure is as follows:
[0014] The encoding submodule includes: the first layer is an input layer, the number of input channels is 3; the second layer is a convolution layer, the number of input channels is 3, the number of output channels is 32, the convolution kernel size is 3*3, and the step size is 2*2; the third layer is a Relu activation layer; the fourth layer is a convolution layer, the number of input channels is 32, the number of output channels is 64, the convolution kernel size is 3*3, and the step size is 2*2; the fifth layer is a batch normalization layer; the sixth layer is a Relu activation layer; the seventh layer is a convolution layer, the number of input channels is 64, the number of output channels is 128, the convolution kernel size is 3*3, and the step size is 2*2;
[0015] The slice feature map f output by the encoding submodule is expressed as follows:
[0016] f=G E (x;θe );
[0017] Among them, θ e represents the network parameters corresponding to the encoding submodule, G E (x;θ e ) represents the encoding submodule, and x represents the input training sample;
[0018] The decoding submodule includes a first layer being a deconvolution layer, with an input channel number of 128, an output channel number of 64, a convolution kernel size of 3*3, and a step size of 2*2; a second layer being a batch normalization layer; a third layer being a Relu activation layer; a fourth layer being a deconvolution layer, with an input channel number of 64, an output channel number of 32, a convolution kernel size of 3*3, and a step size of 2*2; a fifth layer being a batch normalization layer; a sixth layer being a Relu activation layer; and a seventh layer being a deconvolution layer, with an input channel number of 32, an output channel number of 3, a convolution kernel size of 3*3, and a step size of 2*2.
[0019] Slice reconstruction of defect potential area output by the decoding submodule It is expressed as follows:
[0020]
[0021] Among them, θ d represents the network parameters corresponding to the decoding submodule, G D (f;θ d ) represents the decoding submodule.
[0022] Preferably, the re-encoding module specifically includes:
[0023]
[0024] Among them, θ e1 Represents the network parameters corresponding to the re-encoding module, represents the re-encoding module, Represents the reconstructed feature map output by the re-encoding module.
[0025] Preferably, the discrimination module specifically includes a scale one discrimination module and a scale two discrimination module, and the specific structure is as follows:
[0026] The scale-one discrimination module includes: the first layer is an input layer, the number of input channels is 3; the second layer is a convolution layer, the number of input channels is 3, the number of output channels is 32, the convolution kernel size is 3*3, and the step length is 2*2; the third layer is a Relu activation layer; the fourth layer is a convolution layer, the number of input channels is 32, the number of output channels is 64, the convolution kernel size is 3*3, and the step length is 2*2; the fifth layer is a batch normalization layer; the sixth layer is a Relu activation layer; the seventh layer is a convolution layer, the number of input channels is 64, the number of output channels is 128, the convolution kernel size is 3*3, and the step length is 2*2; the eighth layer is a batch normalization layer; the ninth layer is a Relu activation layer; the tenth layer is a convolution layer, the number of input channels is 128, the number of output channels is 1, the convolution kernel size is 3*3, and the step length is 1*1; the eleventh layer is a Sigmoid activation layer; the output of the scale-one discrimination module is as follows:
[0027]
[0028] Among them, the result of l1 is 0 or 1. When it is 0, it means reconstructing the feature map, and when it is 1, it means slicing the image. D1 represents the network parameters corresponding to the scale-discriminant module, is the scale-discrimination module;
[0029] The scale-two discrimination module includes: the first layer is an input layer with 64 channels; the second layer is a convolution layer with 64 input channels, 128 output channels, a convolution kernel size of 3*3, and a step size of 2*2; the third layer is a batch normalization layer; the fourth layer is a Relu activation layer; the fifth layer is a convolution layer with 128 input channels, 1 output channel, a convolution kernel size of 3*3, and a step size of 1*1; the sixth layer is a Sigmoid activation layer; the output of the scale-two discrimination module is as follows:
[0030] l2=D2(G E-2 (x),G D-2 (f); θ D2 );
[0031] Among them, the result of l2 is 0 or 1. When it is 0, it means reconstructing the feature map, and when it is 1, it means slicing the image. D2 represents the network parameters corresponding to the scale-two discrimination module, G E-2 G represents the network module before and including the 4th layer of the encoding submodule in the generation module. D-2 Denotes the 4th layer of the decoding submodule and its previous network modules, D2(G E-2 (x),G D-2 (f); θ D2 ) is the scale-two discrimination module.
[0032] A two-stage intelligent recognition system for X-ray images of unequal thickness weld defects based on reverse learning, comprising:
[0033] A data set establishment module is used to acquire a weld image and establish a first data set; an image with defects in the weld image is a positive sample, and an image without defects in the weld image is a negative sample; a second data set is established based on the positive sample;
[0034] A model training module, inputting the first data set into a preset weld defect potential area recognition model to train the weld defect potential area recognition model; inputting the second data set into a preset weld defect precise recognition model to train the weld defect precise recognition model;
[0035] The region recognition module obtains a weld image to be identified, inputs the weld image to be identified into the trained weld defect potential region recognition model to identify and obtain the defect potential region of the weld image to be identified; slices the weld defect potential region to obtain a slice image, uses the slice image as input of the trained weld defect accurate recognition model, and identifies and marks the slice image in which the defect potential region exists.
[0036] It can be seen from the above technical scheme that compared with the prior art, the present invention discloses a two-stage intelligent recognition method and system for X-ray images of unequal thickness weld defects based on reverse learning. Based on deep learning technology, a new automatic recognition method for weld defects is proposed to address the problems existing in the application of existing deep learning-based methods. In the first stage, the weld defect potential area recognition network is trained with both positive and negative samples to identify the potential defect areas in the original weld image. In the second stage, only negative samples are used to train the defect recognition network. Based on the potential defect areas identified in the first stage, the defects in the second stage are accurately recognized. This not only avoids the disadvantage of relying on a large number of positive samples when training deep learning models, but also can greatly improve the recognition accuracy and efficiency of weld defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0038] Figure 1 An overview of a reverse learning intelligent recognition method for X-ray images of weld defects of unequal thickness provided by the present invention;
[0039] Figure 2A sample example of the first data set provided by the present invention;
[0040] Figure 3 A sample example of the second data set provided by the present invention;
[0041] Figure 4 A schematic diagram of a potential defect area identification model for the first stage provided by the present invention;
[0042] Figure 5 A schematic diagram of image slices in the second stage weld defect accurate identification model provided by the present invention;
[0043] Figure 6 A loss function diagram of the second-stage weld defect accurate identification model provided by the present invention;
[0044] Figure 7 An overall schematic diagram of a reverse learning intelligent recognition model for X-ray images of weld defects of unequal thicknesses provided by the present invention. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] The embodiment of the present invention discloses a two-stage intelligent recognition method for X-ray images of unequal thickness weld defects based on reverse learning, such as Figure 1 As shown, including:
[0047] Acquire weld images and establish a first data set; images with defects in the weld images are positive samples, and images without defects in the weld images are negative samples; establish a second data set based on the positive samples;
[0048] Inputting the first data set into a preset weld defect potential area recognition model to train the weld defect potential area recognition model; inputting the second data set into a preset weld defect precise recognition model to train the weld defect precise recognition model;
[0049] The weld image to be identified is obtained, and the weld image to be identified is input into the trained weld defect potential area identification model to identify the potential defect area of the weld image to be identified; the weld defect potential area is sliced to obtain a slice image, and the slice image is used as the input of the trained weld defect accurate identification model to identify and mark the slice image with the potential defect area.
[0050] The first data set is the images of welds of different thicknesses acquired by X-ray digital imaging equipment. These images include both those with defects and those without defects, but the images of normal welds without defects are the main ones. The sample examples are as follows: Figure 2 As shown; the second data set is made based on the normal weld image samples in the first data set. The potential weld defect area in the normal weld image is sliced to obtain the slice block samples of the potential weld defect area. The sample examples are as follows Figure 3 shown.
[0051] In a specific embodiment, it also includes marking the potential defect area of the weld for the positive sample; and slicing the negative sample. Slicing the potential defect area of the weld can effectively improve the recognition accuracy of small defects, as follows Figure 5 As shown in the figure, the potential area of weld defects is divided into image blocks of fixed size. After preliminary experiments, the results show that the effect is better when the size of each slice is 64×64 pixels. Compared with not slicing, slicing can effectively retain the detailed features of small defects. As shown in the figure below, when not slicing, the potential area of weld defects is large in size. After entering the defect recognition model, it must first be resized to meet the requirements of the conventional recognition model for the input sample pixel size of 640×640. After slicing, the potential area of weld defects is divided into multiple 64×64 small blocks. Therefore, it can be input into the recognition model for defect recognition without resizing.
[0052] In a specific embodiment, the preset weld defect potential area recognition model is specifically a YOLOv8 target detection network model, and the parameters trained on the ImageNet dataset are used as the pre-trained parameters of the YOLOv8 target detection network model. Since the weld defect potential area target is generally large, the existing YOLOv8 target detection model is directly used as the weld defect potential area recognition model of the present invention, as follows Figure 4 As shown in the figure, the YOLOv8 target detection model not only ensures accuracy, but also has excellent real-time performance and is easy to deploy on embedded devices.
[0053] In a specific embodiment, in order to eliminate the problem of poor model generalization performance caused by insufficient positive samples, the present invention proposes a weld defect recognition model that combines reverse learning with slicing technology. The potential weld defect area detected by the first-stage weld defect potential area recognition model is used as the input of the weld defect recognition model in this stage, and then the input weld defect potential area is sliced, and each slice is identified using the trained model. After the recognition results of each slice are comprehensively evaluated, it is finally determined whether there is a defect in the weld potential area of the defect, and the defect location is displayed. In view of the problem that conventional weld defect recognition models are overly dependent on the number of positive samples, since normal defect-free samples can be easily obtained, the limitation of insufficient positive samples can be completely circumvented. This model is based on a generative adversarial network and has made some improvements on its basis. The accurate identification model of weld defects specifically includes: a generation module, a recoding module, and a discrimination module. The generation module obtains the slice feature map of the slice image and reconstructs it to obtain a slice reconstruction map; the recoding module extracts the reconstruction feature map of the slice reconstruction map; the discrimination module inputs the reconstruction feature map and the slice image, judges the reconstruction feature map and the slice image, and helps the generation module learn the characteristics of normal weld images.
[0054] In a specific embodiment, the generation module specifically includes an encoding submodule and a decoding submodule, wherein the encoding submodule is used to obtain a slice feature map representation of an input slice image block, and is composed of three convolutional layers and their corresponding activation functions and batch normalization. The decoding submodule is used to reconstruct the image, reconstruct the slice feature map obtained by the encoding submodule, and generate a slice reconstruction map that is realistic with the slice image block of the original input defect potential area. The submodule is composed of three deconvolution layers and corresponding batch normalization and activation functions. The specific structure is as follows:
[0055] The encoding submodule includes the first layer as the input layer, the number of input channels is 3; the second layer is the convolution layer (the first convolution layer), the number of input channels is 3, the number of output channels is 32, the convolution kernel size is 3*3, and the step size is 2*2; the third layer is the Relu activation layer; the fourth layer is the convolution layer (the second convolution layer), the number of input channels is 32, the number of output channels is 64, the convolution kernel size is 3*3, and the step size is 2*2; the fifth layer is the batch normalization layer; the sixth layer is the Relu activation layer; the seventh layer is the convolution layer (the third convolution layer), the number of input channels is 64, the number of output channels is 128, the convolution kernel size is 3*3, and the step size is 2*2;
[0056] The slice feature map f output by the encoding submodule is expressed as follows:
[0057] f=G E (x;θ e );
[0058] Among them, θ erepresents the network parameters corresponding to the encoding submodule, G E (x;θ e ) represents the encoding submodule, and x represents the input training sample;
[0059] The decoding submodule includes the first layer being a deconvolution layer (the first deconvolution layer), with 128 input channels, 64 output channels, a convolution kernel size of 3*3, and a step size of 2*2; the second layer being a batch normalization layer; the third layer being a Relu activation layer; the fourth layer being a deconvolution layer (the second deconvolution layer), with 64 input channels, 32 output channels, a convolution kernel size of 3*3, and a step size of 2*2; the fifth layer being a batch normalization layer; the sixth layer being a Relu activation layer; the seventh layer being a deconvolution layer (the third deconvolution layer), with 32 input channels, 3 output channels, a convolution kernel size of 3*3, and a step size of 2*2;
[0060] Slice reconstruction of defect potential area output by the decoding submodule It is expressed as follows:
[0061]
[0062] Among them, θ d represents the network parameters corresponding to the decoding submodule, G D (f;θ d ) represents the decoding submodule.
[0063] In a specific embodiment, the re-encoding module has the same structure as the encoding submodule in the generation module, and is used to obtain an accurate feature map representation of the reconstructed slice image block, specifically including:
[0064]
[0065] Among them, θ e1 Represents the network parameters corresponding to the re-encoding module, represents the re-encoding module, Represents the reconstructed feature map output by the re-encoding module.
[0066] In a specific embodiment, the discrimination module can enable the generation module to learn only the features of normal weld images. The module includes two scales, corresponding to the scale one discrimination module and the scale two discrimination module. Each scale module is composed of a convolutional layer and its corresponding activation function and batch normalization. The specific structure is as follows:
[0067] The scale-one discriminant module includes: the first layer is the input layer, the number of input channels is 3; the second layer is the convolution layer, the number of input channels is 3, the number of output channels is 32, the convolution kernel size is 3*3, and the step size is 2*2; the third layer is the Relu activation layer; the fourth layer is the convolution layer, the number of input channels is 32, the number of output channels is 64, the convolution kernel size is 3*3, and the step size is 2*2; the fifth layer is the batch normalization layer; the sixth layer is the Relu activation layer; the seventh layer is the convolution layer, the number of input channels is 64, the number of output channels is 128, the convolution kernel size is 3*3, and the step size is 2*2; the eighth layer is the batch normalization layer; the ninth layer is the Relu activation layer; the tenth layer is the convolution layer, the number of input channels is 128, the number of output channels is 1, the convolution kernel size is 3*3, and the step size is 1*1; the eleventh layer is the Sigmoid activation layer; the scale-one discriminant module inputs the training samples x and The network performs convolution and related operations layer by layer, and finally outputs the corresponding label (real slice image block or reconstructed slice image block). The output is as follows:
[0068]
[0069] Among them, the result of l1 is 0 or 1. When it is 0, it means reconstructing the feature map, and when it is 1, it means slicing the image. D1 represents the network parameters corresponding to the scale-discriminant module, is the scale-discrimination module;
[0070] The scale-two discrimination module includes: the first layer is the input layer, with 64 channels; the second layer is the convolution layer (the first convolution layer), with 64 input channels, 128 output channels, 3*3 convolution kernel size, and 2*2 step size; the third layer is the batch normalization layer; the fourth layer is the Relu activation layer; the fifth layer is the convolution layer (the second convolution layer), with 128 input channels, 1 output channel, 3*3 convolution kernel size, and 1*1 step size; the sixth layer is the Sigmoid activation layer; the scale-two discrimination module performs layer-by-layer convolution and related operations, and finally outputs the corresponding label (real slice image block or reconstructed slice image block), and the output is as follows:
[0071] l2=D2(G E-2 (x),G D-2 (f); θ D2 );
[0072] Among them, the result of l2 is 0 or 1. When it is 0, it means reconstructing the feature map, and when it is 1, it means slicing the image. D2 represents the network parameters corresponding to the scale-two discrimination module, G E-2 G represents the network module before and including the 4th layer of the encoding submodule in the generation module. D-2Denotes the second deconvolution layer of the decoding submodule and its previous network module, D2(G E-2 (x),G D-2 (f); θ D2 ) is the scale-two discrimination module.
[0073] A two-stage intelligent recognition system for X-ray images of unequal thickness weld defects based on reverse learning, comprising:
[0074] The data set establishment module acquires weld images and establishes a first data set; images with defects in the weld images are positive samples, and images without defects in the weld images are negative samples; a second data set is established based on the positive samples;
[0075] The model training module inputs the first data set into a preset weld defect potential area recognition model to train the weld defect potential area recognition model; inputs the second data set into a preset weld defect precise recognition model to train the weld defect precise recognition model;
[0076] The region recognition module obtains the weld image to be identified, inputs the weld image to be identified into the trained weld defect potential region recognition model to identify and obtain the potential defect region of the weld image to be identified; slices the weld defect potential region to obtain a slice image, uses the slice image as the input of the trained weld defect accurate recognition model, and identifies and marks the slice image with the potential defect region.
[0077] In a specific embodiment, the second data set constructed previously is used to effectively train the second-stage weld defect accurate recognition model, such as Figure 6 As shown in the figure, the training process includes a total of 4 loss functions, namely adversarial loss, semantic loss, encoding loss and discriminative loss.
[0078] The adversarial loss represents the L2 distance-Euclidean distance (adversarial loss 1) between the “true and false” feature maps of the input slice image block and the reconstructed image block. Since the present invention calculates the adversarial loss for feature maps of two different scales at the same time, the adversarial loss also includes the L2 distance-Euclidean distance (adversarial loss 2) between the “true and false” feature maps of the input slice image block after the second convolution module of the encoding submodule and the second deconvolution module of the decoding submodule before the reconstructed image block. The generation module of the model is trained by minimizing the distance between the “true and false” feature maps of these two different scales, so that the image block reconstructed by the generation module can be indistinguishable from the real one. The specific adversarial loss 1 and adversarial loss 2 are respectively expressed as follows:
[0079]
[0080] Among them, f dRepresents the part of the discriminant network module of scale 1 and scale 2 that is used to output the “true and false” feature map. For the discriminant network module of scale 1, f d Specifically refers to the fourth layer of the scale one discriminant module and the network before it. For the scale two discriminant network module, f d Specifically refers to the first layer of the scale-two discriminant module, p x represents the data distribution of the input slice image block. f2 represents the feature map output by the second convolutional layer of the encoding submodule, G D-2 Represents the part of the module used to output the feature map of the second deconvolution layer in the decoding submodule. is the expected value, G E The encoding submodule.
[0081] The semantic loss represents the L1 distance-Manhattan distance between the original image and the reconstructed image, which is used to cooperate with the adversarial loss penalty to generate the network module. The semantic loss is specifically expressed as follows:
[0082]
[0083] G D For the decoding submodule, the encoding loss represents the L2 distance-Euclidean distance between the two different scale feature maps obtained by the encoding submodule in the generation module and the re-encoding module. The two different scale feature maps are the feature maps output by the second convolutional layer and the third convolutional layer of the encoding submodule and the re-encoding module, respectively. The encoding loss 1 and encoding loss 2 corresponding to these two different scales are expressed as follows:
[0084]
[0085] Among them, G E-2 represents the second convolutional layer of the encoding submodule in the generation module and the previous network module, E -2 Represents the second convolutional layer of the re-encoding module and the previous network modules.
[0086] The discriminant loss represents the cross entropy loss between the original image and the reconstructed image, as well as between a feature map of the original image and a feature map of the reconstructed image. It is used to judge the “true or false” of the input slice image block and the reconstructed image block (corresponding to the discriminant loss 1). It is also used to judge the “true or false” of the input slice image block after the second convolution module of the encoding submodule and the second deconvolution module of the decoding submodule before the reconstructed image block (corresponding to the discriminant loss 2). The discriminant loss 1 and the discriminant loss 2 are respectively expressed as follows:
[0087]
[0088]
[0089] Among them, pi and p i2 They represent the “true” and “false” category probabilities output by the last sigmoid function of the scale 1 discriminant module and the scale 2 discriminant module, respectively. N represents the total number of training samples. i The value of the category label is 0 or 1.
[0090] Adversarial Loss: Adversarial loss is a loss function used in Generative Adversarial Networks (GANs). By training the adversarial process between the generator and the discriminator, the realism and quality of the images generated by the generator can be improved.
[0091] Semantic Loss: Semantic loss is used to ensure that the generated image is semantically consistent with the target image, that is, the generated image can accurately express the content and features of the target image.
[0092] Encoding Loss: Encoding loss is used to keep the encoding information of the generated image consistent with that of the original image, ensuring that the generated image is similar to the original image in the feature space.
[0093] Discriminative Loss: Discriminative loss is used to train the discriminator network to help the discriminator accurately distinguish between generated images and real images, thereby improving the quality and realism of generated images.
[0094] The use of these four loss functions can constrain and optimize the model at different levels, helping the model to better learn and generate images that meet the requirements. By comprehensively utilizing these loss functions, the performance and generalization ability of the model can be improved, allowing the model to achieve better results in defect recognition tasks.
[0095] In a specific embodiment, it also includes the construction and testing of the overall model: the models of the above two stages are combined as follows Figure 7As shown, the X-ray image of the weld to be inspected is used as the input of the first-stage defect potential area recognition model, and the defect potential area output by the first-stage defect potential area recognition model is used as the input of the second-stage defect accurate recognition model. Among them, the second-stage defect accurate recognition model first slices the input defect potential area, and then encodes and re-encodes all slice images, and measures the L1 distance between the slice feature map distribution obtained after the original slice image passes through the encoding submodule and the feature map distribution obtained after the slice reconstruction image passes through the re-encoding module (the distance between the two feature map distributions is measured). Finally, if all the measurement values are not greater than the threshold, it means that there is no defect in the defect potential area, so the X-ray image of the weld to be inspected is judged to be normal; if a certain measurement value is greater than the threshold, it means that there is a defect in the defect potential area, so it is judged that there is a defect in the X-ray image of the weld to be inspected, and further locates the position of the defective slice in the defect potential area according to the defective slice, and determines the position of the slice in the original X-ray image of the weld to be inspected by the relocation method. At this point, the automatic defect recognition of the entire weld X-ray image is completed.
[0096] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0097] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A two-stage intelligent recognition method for X-ray images of unequal thickness weld defects based on reverse learning, characterized in that: include: Acquire a weld image and establish a first data set; The image with defects in the weld image is a positive sample, and the image without defects in the weld image is a negative sample; Establishing a second data set according to the positive samples; Inputting the first data set into a preset weld defect potential area recognition model to train the weld defect potential area recognition model; inputting the second data set into a preset weld defect precise recognition model to train the weld defect precise recognition model; Acquire a weld image to be identified, input the weld image to be identified into the trained weld defect potential area identification model to identify and obtain the defect potential area of the weld image to be identified; The potential weld defect area is sliced to obtain a slice image, and the slice image is used as an input of the trained weld defect accurate recognition model to identify and mark the slice image in which the potential defect area exists.
2. According to claim 1, a reverse learning two-stage intelligent recognition method for X-ray images of unequal thickness weld defects is characterized by: The method also includes marking potential defect areas of the weld of the positive sample; and performing a slicing operation on the negative sample.
3. According to claim 1, a reverse learning two-stage intelligent recognition method for X-ray images of unequal thickness weld defects is characterized in that: The preset weld defect potential area recognition model is specifically a YOLOv8 target detection network model, and parameters trained on the ImageNet dataset are used as pre-training parameters of the YOLOv8 target detection network model.
4. According to claim 1, a reverse learning two-stage intelligent recognition method for X-ray images of unequal thickness weld defects is characterized in that: The weld defect accurate identification model specifically includes: a generation module, a recoding module, and a discrimination module. The generation module obtains the slice feature map of the slice image and reconstructs it to obtain a slice reconstruction map; the recoding module extracts the reconstructed feature map of the slice reconstruction map; the discrimination module inputs the reconstructed feature map and the slice image, judges the reconstructed feature map and the slice image, and helps the generation module learn the characteristics of normal weld images.
5. According to claim 4, a reverse learning two-stage intelligent recognition method for X-ray images of unequal thickness weld defects is characterized in that: The generation module specifically includes an encoding submodule and a decoding submodule, and the specific structure is as follows: The encoding submodule includes: the first layer is an input layer, the number of input channels is 3; the second layer is a convolution layer, the number of input channels is 3, the number of output channels is 32, the convolution kernel size is 3*3, and the step size is 2*2; the third layer is a Relu activation layer; the fourth layer is a convolution layer, the number of input channels is 32, the number of output channels is 64, the convolution kernel size is 3*3, and the step size is 2*2; the fifth layer is a batch normalization layer; the sixth layer is a Relu activation layer; the seventh layer is a convolution layer, the number of input channels is 64, the number of output channels is 128, the convolution kernel size is 3*3, and the step size is 2*2; The slice feature map f output by the encoding submodule is expressed as follows: f=G E (x;θ e ); Among them, θ e represents the network parameters corresponding to the encoding submodule, G E (x;θ e ) represents the encoding submodule, and x represents the input training sample; The decoding submodule includes a first layer being a deconvolution layer, with an input channel number of 128, an output channel number of 64, a convolution kernel size of 3*3, and a step size of 2*2; a second layer being a batch normalization layer; a third layer being a Relu activation layer; a fourth layer being a deconvolution layer, with an input channel number of 64, an output channel number of 32, a convolution kernel size of 3*3, and a step size of 2*2; a fifth layer being a batch normalization layer; a sixth layer being a Relu activation layer; and a seventh layer being a deconvolution layer, with an input channel number of 32, an output channel number of 3, a convolution kernel size of 3*3, and a step size of 2*2. Slice reconstruction of defect potential area output by the decoding submodule It is expressed as follows: Among them, θ d represents the network parameters corresponding to the decoding submodule, G D (f;θ d ) represents the decoding submodule.
6. The reverse learning two-stage intelligent recognition method for X-ray images of unequal thickness weld defects according to claim 5 is characterized in that: The re-encoding module specifically includes: Among them, θ e1 Represents the network parameters corresponding to the re-encoding module, represents the re-encoding module, Represents the reconstructed feature map output by the re-encoding module.
7. The reverse learning two-stage intelligent recognition method for X-ray images of unequal thickness weld defects according to claim 5 is characterized in that: The discrimination module specifically includes a scale one discrimination module and a scale two discrimination module, and the specific structure is as follows: The scale-one discrimination module includes: the first layer is an input layer, the number of input channels is 3; the second layer is a convolution layer, the number of input channels is 3, the number of output channels is 32, the convolution kernel size is 3*3, and the step length is 2*2; the third layer is a Relu activation layer; the fourth layer is a convolution layer, the number of input channels is 32, the number of output channels is 64, the convolution kernel size is 3*3, and the step length is 2*2; the fifth layer is a batch normalization layer; the sixth layer is a Relu activation layer; the seventh layer is a convolution layer, the number of input channels is 64, the number of output channels is 128, the convolution kernel size is 3*3, and the step length is 2*2; the eighth layer is a batch normalization layer; the ninth layer is a Relu activation layer; the tenth layer is a convolution layer, the number of input channels is 128, the number of output channels is 1, the convolution kernel size is 3*3, and the step length is 1*1; the eleventh layer is a Sigmoid activation layer; the output of the scale-one discrimination module is as follows: Among them, the result of l1 is 0 or 1. When it is 0, it means reconstructing the feature map, and when it is 1, it means slicing the image. D1 represents the network parameters corresponding to the scale-discriminant module, is the scale-discrimination module; The scale-two discrimination module includes: the first layer is an input layer with 64 channels; the second layer is a convolution layer with 64 input channels, 128 output channels, a convolution kernel size of 3*3, and a step size of 2*2; the third layer is a batch normalization layer; the fourth layer is a Relu activation layer; the fifth layer is a convolution layer with 128 input channels, 1 output channel, a convolution kernel size of 3*3, and a step size of 1*1; the sixth layer is a Sigmoid activation layer; the output of the scale-two discrimination module is as follows: l2=D2(G E-2 (x),G D-2 (f);θ D2 ); Among them, the result of l2 is 0 or 1. When it is 0, it means reconstructing the feature map, and when it is 1, it means slicing the image. D2 represents the network parameters corresponding to the scale-two discrimination module, G E-2 G represents the network module before and including the 4th layer of the encoding submodule in the generation module. D-2 Denotes the 4th layer of the decoding submodule and its previous network modules, D2(G E-2 (x),G D-2 (f); θ D2 ) is the scale-two discrimination module.
8. A reverse learning two-stage intelligent recognition system for X-ray images of unequal thickness weld defects, applied to a reverse learning two-stage intelligent recognition method for X-ray images of unequal thickness weld defects as described in any one of claims 1 to 7, characterized in that: include: A data set establishment module, which acquires a weld image and establishes a first data set; The image with defects in the weld image is a positive sample, and the image without defects in the weld image is a negative sample; a second data set is established based on the positive samples; A model training module, inputting the first data set into a preset weld defect potential area recognition model to train the weld defect potential area recognition model; inputting the second data set into a preset weld defect precise recognition model to train the weld defect precise recognition model; The region recognition module obtains a weld image to be identified, inputs the weld image to be identified into the trained weld defect potential region recognition model to identify and obtain the defect potential region of the weld image to be identified; slices the weld defect potential region to obtain a slice image, uses the slice image as input of the trained weld defect accurate recognition model, and identifies and marks the slice image in which the defect potential region exists.
Citation Information
Patent Citations
Two-stage mainboard image defect detecting and positioning method based on machine vision
CN114972213A
Steel surface defect detection method based on improved YOLOv5
CN115294089A
SYSTEMS, METHODS, AND APPARATUSES FOR IMPLEMENTING DISCRIMINATIVE, RESTORATIVE, AND ADVERSARIAL (DiRA) LEARNING FOR SELF-SUPERVISED MEDICAL IMAGE ANALYSIS
US20230281805A1
Cited By
X-ray weld defect detection method, system and equipment and storage medium
CN122289260A
