CN-122023277-A - Method and system for detecting image defects on inner cavity surface of pipeline type part
Abstract
The invention provides a method and a system for detecting defects of inner cavity surfaces of pipeline parts, wherein the method comprises the steps of S1, dividing an acquired inner cavity surface image of the pipeline parts into a training set and a testing set after processing, S2, constructing a pipeline part surface image defect detection model based on an improved generation countermeasure network, S3, training a generator model and a discriminator model, updating the generator model and the discriminator by using different learning rates and alternately training, and S4, inputting the testing set image into the trained discriminator model, outputting defect types and defect position coordinates, and finishing the detection of the inner cavity surface image defects of the pipeline parts. The invention constructs an improved generation countermeasure network, breaks through the constraint of insufficient real data, effectively expands a defect sample library, solves the problem of insufficient defect data quantity, and provides a double discrimination sub-network in a discriminator network, thereby improving the effective discrimination capability of the discriminator on defects.
Inventors
- LIU HUAN
- LIU XIAOJIA
- CAO LIJUN
- YANG CHEN
- LIU XING
- Wei Chuo
Assignees
- 上海航天精密机械研究所
Dates
- Publication Date
- 20260512
- Application Date
- 20260105
Claims (10)
- 1. The method for detecting the image defects of the inner cavity surface of the pipeline type part is characterized by comprising the following steps of: step S1, dividing the obtained image of the inner cavity surface of the pipeline part into a training set and a testing set after image quality enhancement, image data enhancement and defect labeling; s2, constructing a pipeline part surface image defect detection model based on an improved generation countermeasure network, wherein the improved generation countermeasure network comprises a generator model and a discriminator model; Step S3, training the generator model and the discriminator model, updating the generator model and the discriminator by using different learning rates, alternately training, constructing a generator and a discriminator loss function, adopting a gradient descent method to minimize the loss function so as to update network parameters, calculating the characteristic distribution distance between the generated image and the real image in the training process, and ending the training when the characteristic distribution distance is smaller than a threshold value; and S4, inputting the test set image into the trained discriminator model, outputting the defect type and the defect position coordinates, and finishing the detection of the surface image defects of the inner cavity of the pipeline type part.
- 2. The method for detecting the defects of the inner cavity surface image of the pipeline type part according to claim 1, wherein the calculation formula of the characteristic distribution distance is as follows: Wherein, the And The mean vectors of the real image and the generated image in the feature space are respectively, 2 Is the L 2 norm of the calculated vector difference, And Covariance matrixes of the real image and the generated image in a feature space are respectively calculated, and Tr is the trace of the matrix; In order to stabilize the coefficient of the power consumption, Is an identity matrix.
- 3. The method for detecting defects of surface images of inner cavities of pipeline parts according to claim 1, wherein the step S2 comprises: The method comprises the steps of constructing a generator network, wherein the generator network comprises a full connection layer, a Reshape layer, an embedded coding layer, a feature fusion layer, a deconvolution layer and a double-pooling attention mechanism, and the deconvolution layer comprises upsampling, BN normalization and ELU activation function operation; The original inputs of the generator network include a noise vector z, a defect type tag y, and a defect location coordinate p; The noise vector z is randomly generated by adopting Gaussian distribution, and a characteristic diagram e (z) is output after the noise vector z is input into a full-connection layer and a Reshape layer; The defect type label y adopts onehot coding mode, and outputs a characteristic diagram e (y) after being input into an embedded coding layer, a full-connection layer and a Reshape layer; The defect position coordinate p is input into the full-connection layer and the Reshape layers and then a characteristic diagram e (p) is output; the feature fusion layer performs splicing fusion on vectors e (z), e (y) and e (p), calculates the fusion feature map by adopting 1X 1 convolution to finish channel number dimension reduction of the fusion feature map, and inputs the feature map after dimension reduction into the deconvolution layer to realize three-channel RGB map output.
- 4. The method for detecting the surface image defects of the inner cavity of the pipeline part according to claim 3, wherein the generator network adopts a double-pool attention mechanism for deconvolution layers, global average pooling and global extremely pooling are carried out on the feature graphs of high H, wide W and channel number C output by each deconvolution layer, the feature graphs of [ W, H, C ] are compressed into two feature vectors with the size of [1, C ], the two feature vectors of [1, C ] are respectively input into two 1D convolution layers with the size of adaptive convolution kernel k, the output features are added, channel attention weights of [1, C ] are obtained through a Sigmoid layer, in the Scale layer, the channel attention weights of [1, C ] are multiplied with the feature graphs of [ W, H, C ] to output new [ W, H, C ] feature graphs, the convolution kernel size k is dynamically adjusted according to the channel number of input features, and the convolution kernel size k is calculated as: wherein the ODD (x) function represents an ODD number nearest to x, and C is the number of feature map channels.
- 5. The method for detecting defects of inner cavity surface images of pipeline parts according to claim 1, wherein the total loss function L G in the training process of the generator model comprises an antagonism loss L GA , a classification consistency loss L GC and a positioning consistency loss L GL ; The countermeasures loss L GA is used for judging the authenticity of the generated image by the judging sub-network D 1 of the judging device, and the generator generates the vivid image by maximizing the prediction probability of the judging device, wherein the formula is as follows: where E is the mathematical expectation of the sample distribution, An image generated by the generator under the input of z, y and p; to determine the sub-network D 1 under given y and p, an image is generated A predictive probability of authenticity; The classification consistency loss L GC is used for judging whether the defect type of the generated image is consistent with the input defect type label y by the image defect detection sub-network D 2 of the discriminator, and the formula is as follows: Wherein the method comprises the steps of Generating images for pairs of image defect detection subnetworks D2 CrossEntropy is a cross entropy loss function; The location consistency loss L GL is used for judging whether the defect position of the generated image is consistent with the input position coordinate p by the image defect detection sub-network D 2 of the discriminator, and the formula is as follows: Wherein the method comprises the steps of Generating images for pairs of image defect detection networks D 2 The calculation formula of the Smooth function is as follows: Wherein the method comprises the steps of Is the actual coordinates of the defect; Predicting coordinates for the defect location; generator total loss function Wherein In order to classify the consistency loss coefficient, To locate a consistency loss coefficient; Classification consistency loss coefficient And a positioning consistency loss coefficient The dynamic mode is adopted to change according to the characteristic distribution distance, and the initial setting is carried out Gradually approaching with training; 、 The formula is: , Wherein F is the feature distribution distance, and F t is the feature distribution distance threshold set during training.
- 6. The method for detecting defects of surface images of inner cavities of pipeline parts according to claim 1, wherein the step S2 further comprises: Constructing a discriminator network; The discriminator network comprises an image discriminating sub-network D 1 and an image defect detecting sub-network D 2 ; The image discrimination sub-network D 1 and the image defect detection sub-network D 2 share a feature extraction network, the prediction head of the image discrimination sub-network D 1 is used for image authenticity prediction, and the prediction head of the image defect detection sub-network D 2 is used for classification and regression and defect type and defect position prediction.
- 7. The method for detecting the surface image defects of the inner cavity of the pipeline type part according to claim 6, wherein the characteristic extraction network comprises a first convolution module, a second convolution module, a third convolution module, a fourth convolution module and a fifth convolution module, and each convolution module comprises a1×1 convolution, two convolution kernels with different dimensions, a characteristic fusion layer and a Pooling pooling layer; The method comprises the steps of adopting a multi-scale convolution feature fusion mode and a multi-feature image fusion mode for a discriminator network, inputting a generated image and a real image as well as a defect type label y and a defect position coordinate P corresponding to the image by the discriminator network, inputting the generated image and the real image into a first convolution module for completing channel multi-dimension of the fused feature image, adopting two convolution kernels with different scales to respectively calculate the feature images after the dimension increase, splicing and fusing the calculation results in a feature fusion layer, adopting Max-Pooling to process the fused feature images to output a feature image P 1 , inputting the feature image P 1 into a second convolution module to output the feature image P 2 , inputting the feature image P 2 into a third convolution module to output the feature image P 3 , inputting the feature image P 3 into a fourth convolution module to output the feature image P 4 , and inputting the feature image P 4 into a fifth convolution module to output the feature image P 5 ; The feature map P 1 is subjected to CBS and twice downsampling treatment and then is subjected to splicing fusion with the feature map P 3 , the spliced and fused feature map is subjected to CBS and twice downsampling treatment and then is subjected to splicing fusion with the feature map P 5 , a final feature map is generated, and the final feature map is respectively input into an image discrimination sub-network D 1 and an image defect detection sub-network D 2 to finish image authenticity discrimination, image defect type and defect position prediction.
- 8. The method for detecting defects of inner cavity surface images of pipeline parts according to claim 1, wherein in the step S3, the total loss function L A in the training process of the discriminator model is composed of the combination of the discrimination loss L AA , the defect classification loss L AC and the defect positioning loss L AL ; The discrimination loss L AA is used for discriminating the real image and the generated image by the sub-network D 1 , and the formula is as follows: Wherein the method comprises the steps of The prediction probability of the sub-network D 1 on the true image x containing the defect is judged; The defect classification loss L AC is used for judging whether the defect type of the image is consistent with the input defect type label y by the image defect detection sub-network D 2 of the discriminator, and the formula is as follows: Wherein the method comprises the steps of Predicting the defect type of the real image for the image defect detection subnetwork D 2 ; The defect localization loss L AL is used for judging whether the defect position of the image is consistent with the input defect type label p by the image defect detection sub-network D 2 of the discriminator, and the formula is as follows: Wherein the method comprises the steps of (X) Predicting the defect position of the real image for the image defect detection network D 2 ; total loss function of discriminator Wherein The loss factor is classified for the defect, Locating a loss coefficient for the defect; dynamic adjustment of defect classification loss coefficients using feature distribution distances And defect localization loss coefficient The formula is: , Wherein F is the feature distribution distance, and F t is the feature distribution distance threshold set during training.
- 9. The method for detecting the defects of the inner cavity surface image of the pipeline type part according to claim 1 is characterized in that the image data augmentation comprises random overturn, random clipping and random brightness transformation, the augmented image is subjected to defect marking, a label file containing defect types and defect position coordinates is formed after marking, and the marked image and the corresponding labels are divided into a training set and a testing set.
- 10. The utility model provides a pipeline class part inner chamber surface image defect detection system which characterized in that includes: The module M1 is used for carrying out image quality enhancement, image data enhancement and defect marking on the obtained image of the inner cavity surface of the pipeline part, and dividing the image into a training set and a testing set; The module M2 is used for constructing a pipeline part surface image defect detection model based on an improved generation countermeasure network, wherein the improved generation countermeasure network comprises a generator model and a discriminator model; Training the generator model and the discriminator model, updating the generator model and the discriminator model by using different learning rates, alternately training, constructing a generator loss function and a discriminator loss function, adopting a gradient descent method to minimize the loss function so as to update network parameters, calculating the characteristic distribution distance between a generated image and a real image in the training process, and ending the training when the characteristic distribution distance is smaller than a threshold value; and a module M4, inputting the test set image into the trained discriminator model, outputting the defect type and the defect position coordinates, and finishing the detection of the image defects on the inner cavity surface of the pipeline type part.
Description
Method and system for detecting image defects on inner cavity surface of pipeline type part Technical Field The invention relates to the technical field of defect detection, in particular to a method and a system for detecting defects of inner cavity surface images of pipeline parts, and especially relates to a method and a system for detecting defects of inner cavity surface images of pipeline parts based on a generated countermeasure network. Background In the industrial manufacturing and equipment maintenance process, the inner cavity surface defect detection of the pipeline type parts is an important link for guaranteeing the safe operation of equipment. Currently, an industrial endoscope is used as a main detection tool, and a flexible probe of the industrial endoscope penetrates into a pipeline to obtain an inner cavity surface image of a pipeline part, so that whether the inner cavity surface has defects of scratch, pit, inclusion, corrosion and the like can be checked. However, the method is highly dependent on manual experience, a detector needs to observe images frame by frame, manually mark the defect position and judge the type, has extremely low efficiency and is easily influenced by subjective factors, especially visual fatigue can be generated by the detector when the detector faces a large amount of detection tasks, and the detection omission risk is obviously increased. Currently, deep learning models are applied to the technical field of defect detection due to efficient feature extraction capability. Through FASTER RCNN, YOLO, deep, DETR and other deep learning models, target defect classification and positioning can be realized, and detection speed and consistency are greatly improved. However, the deep learning model depends on a large amount of labeling data, defect samples in an actual industrial scene are scarce, normal samples occupy a relatively high proportion, so that data distribution is seriously unbalanced, the model is easy to be under-fitted to a small number of types, meanwhile, the defect forms of pipeline parts are various and are obviously influenced by imaging conditions, and the existing open source data set is difficult to cover the complexity of the actual scene. Although the traditional data enhancement method can alleviate the overfitting, the method cannot generate defect characteristics conforming to the physical laws, has limited model generalization capability, and has large difference of defect scales of inner cavity surface images of pipeline parts, and a single convolution kernel is difficult to effectively capture local detail and global structure information. Therefore, a method for detecting the defects of the inner cavity surface image of the pipeline part based on the generation countermeasure network is needed, the constraint of real data deficiency is broken through by generating a vivid defect image through countermeasure training, a defect sample library is effectively expanded, the problems of insufficient defect data quantity, unbalanced sample distribution and large defect scale difference are solved, and the intelligent detection capability of the defects of the inner cavity surface image of the pipeline part is realized. Patent document CN210322174U discloses a connecting device for sealing test of pipeline parts, but solves the problems that the existing connecting device for pipeline parts and detection equipment is of a split structure, and phenomena such as looseness and air leakage are easy to occur in the detection process, which is different from the technical problems to be solved by the invention. Disclosure of Invention Aiming at the defects in the prior art, the invention aims to provide a method and a system for detecting the image defects of the inner cavity surface of a pipeline part. The invention provides a method for detecting image defects on the inner cavity surface of a pipeline part, which comprises the following steps: step S1, dividing the obtained image of the inner cavity surface of the pipeline part into a training set and a testing set after image quality enhancement, image data enhancement and defect labeling; s2, constructing a pipeline part surface image defect detection model based on an improved generation countermeasure network, wherein the improved generation countermeasure network comprises a generator model and a discriminator model; Step S3, training the generator model and the discriminator model, updating the generator model and the discriminator by using different learning rates, alternately training, constructing a generator and a discriminator loss function, adopting a gradient descent method to minimize the loss function so as to update network parameters, calculating the characteristic distribution distance between the generated image and the real image in the training process, and ending the training when the characteristic distribution distance is smaller than a threshold value; and S4, inputting th