Transform-based oil and gas pipeline circumferential weld defect intelligent detection method
By introducing a multi-scale fusion module and a small-object feature enhancement encoder, and combining a generative adversarial network to generate virtual samples, the problem of insufficient small-object detection accuracy in the DETR model in weld defect detection is solved, and efficient and accurate weld defect detection is achieved.
Patent Information
- Application Number
- CN202510541784.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-08-08
AI Technical Summary
The existing Transformer-based DETR model lacks the performance of small target detection in weld defect detection and limited training data, resulting in low detection accuracy and efficiency, making it difficult to meet the high-precision detection requirements of oil and gas pipelines.
A multi-scale fusion module and a small-object feature enhancement encoder are introduced, combined with the generative adversarial network VQ-GAN to generate virtual samples, enhance data sets, and a Transformer-based weld defect detection model is designed, and the detection ability of small-objectives is improved through multi-layer feature fusion and local attention adjustment.
It improves the detection accuracy of small-size weld defects, shortens model training time, reduces dependence on professionals, and achieves efficient end-to-end detection.
Smart Images

Figure SMS_1 
Figure SMS_2 
Figure HDA0005379570910000011
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent detection of weld defects in oil and gas pipelines, and specifically to an intelligent weld defect detection method based on deep learning target detection. Background Art
[0002] As my country's oil and gas pipeline construction continues to expand, the service life of these pipelines is also increasing. However, during long-term operation, pipelines are often affected by various factors such as corrosion, weld defects, and third-party sabotage. These issues can lead to serious safety accidents. Weld defects are considered a major safety hazard for pipelines, posing a significant threat to their integrity and reliability.
[0003] Currently, weld quality assessment based on X-ray imaging is the most widely used weld quality inspection method in the field. This method not only improves the accuracy of weld inspection but also enables pipeline integrity management. However, it is worth noting that the defect images generated by the inspection require professional technicians to analyze for accurate positioning and evaluation, a process that requires a significant investment of human resources. Although manual film evaluation excels in accuracy and reliability, its low efficiency makes the inspection process more time-consuming and cumbersome, making it difficult to meet the needs of rapid response.
[0004] With technological advancements, existing intelligent weld inspection technologies can be divided into two major categories. The first category is based on traditional professional methods, including ultrasonic testing, electromagnetic acoustic wave testing, eddy current testing, and magnetic flux leakage testing. These methods utilize unique principles to assess weld quality. While they perform well in many cases, they still rely on the experience and skills of professionals and are often difficult to adapt to complex and changing real-world operating environments. The second category is the emerging weld inspection technology based on deep learning. With the development of deep learning models such as convolutional neural networks (CNNs), more and more companies are developing intelligent solutions for weld inspection. A common framework is the two-stage object detection model Faster R-CNN proposed in the paper "Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks." The paper "You Only Look Once" (YOLO) treats object detection as a single regression problem, directly predicting bounding boxes and class probabilities from the entire image. It is one of the fastest object detection algorithms and demonstrates excellent object detection capabilities. In the invention patent "A method for detecting welds and weld defects based on deep learning" (patent number: CN201910213482.1), a weld defect detection system based on the YOLOv3 model was constructed, a two-stage training dataset suitable for multiple welds and multiple types of defects was constructed, and an end-to-end deep learning training process was designed, which enables weld identification and defect location to be completed in a single measurement.
[0005] However, these CNN-based object detectors still require a lot of manual intervention during design, including the setting of preset boxes and post-processing operations, which to a certain extent limits the performance ceiling of the model. In recent years, the Detection Transformer (DETR) model proposed in the paper "End-to-End Object Detection with Transformers" has pioneered a new paradigm for object detection. The DETR model abandons the manually designed components in traditional detectors and adopts an encoder-decoder structure based on the Transformer architecture, redefining the object detection task as a set prediction problem. The model captures the global contextual information of the image through a self-attention mechanism, and directly predicts the category and location of the target through a set of learnable object queries, completely avoiding post-processing steps such as anchor box design and non-maximum suppression, and realizing a true end-to-end training and inference process. DETR uses the Hungarian algorithm for bipartite graph matching to solve the one-to-many mapping problem in training, while leveraging the parallel processing capabilities of the Transformer decoder to predict all targets simultaneously, significantly simplifying the detection process.
[0006] Although the DETR model has brought revolutionary changes to the field of target detection, it still faces significant challenges when dealing with small target detection tasks such as weld defects. Due to the DETR model's over-reliance on global information during feature extraction and target positioning, it is not sensitive enough to local detail information, which in turn affects the detection performance of small-sized targets. In addition, the DETR model converges slowly and usually requires a longer training cycle to achieve ideal results. More importantly, the existing technology has not yet effectively addressed the limitations of the DETR model in small target detection, especially for scenarios requiring high-precision detection such as weld defects.
[0007] At the same time, my country's oil pipelines utilize high-quality, advanced welding processes, resulting in extremely limited weld defect data, further complicating model training. These deep learning models generally rely on large numbers of labeled samples, making it difficult to fully leverage their performance advantages with limited sample sizes. This is particularly true for weld inspection tasks that require precise location of minute defects, where existing technologies still have significant shortcomings. Summary of the Invention
[0008] The present invention aims to overcome the aforementioned problems by providing a defect detection method based on the DETR model. This method employs a multi-scale fusion algorithm and a special encoder structure for small target feature enhancement, focusing more on weld defect characteristics. Furthermore, the method introduces the latest generative adversarial network model, VQ-GAN. This method can generate virtual samples from limited defect samples to increase the amount of labeled data, ensuring the integrity and generalization of target detection model training. The proposed model enables real-time quality monitoring of oil and gas pipelines, ensuring their safe operation.
[0009] The disclosed weld defect detection method comprises the following steps:
[0010] S1. Based on the collected dataset, train the VQ-GAN network to generate a rich weld defect dataset;
[0011] S2. Preprocess the weld defect dataset according to the model's requirements for input images;
[0012] S3. Using the preprocessed data set, train the target detection model of the present invention:
[0013] (1) Backbone feature extraction network: The input image is passed through the backbone network ResNet50 to obtain image features. ResNet50 is a 50-layer deep residual neural network. Its innovation lies in the introduction of the residual connection (jump connection) mechanism, which solves the gradient vanishing problem in the deep neural network training process. This network has excellent performance in large-scale image recognition tasks and has become a classic backbone network in the field of computer vision. In the invention, ResNet50 is mainly responsible for the preliminary pre-processing of the image and preliminary feature extraction to obtain high-dimensional, high-channel image features;
[0014] (2) Multi-scale fusion module: responsible for fusing and interacting the features after passing through the backbone network, amplifying the features of small objects, and increasing the richness of the feature map;
[0015] (3) Small target encoder E: Design an encoder based on target offset to increase the model’s attention score on small targets and enhance the local attention of the target;
[0016] (4) Decoder D: obtains information about the prediction box from the encoder through training queries based on multi-layer self-attention and cross-attention;
[0017] S4. Apply the model of the present invention to perform defect detection and analysis on the weld image.
[0018] As a preference, the weld defect dataset obtained in step S1 can be found in the attached Figure 1 The specific steps of using the VQ-GAN network to expand the data set in step S1 are:
[0019] S11. Arrange the collected weld inspection data set and statistically mark each defect category;
[0020] S12. Preprocess the existing data, including cropping based on the annotation box and enhancing the data defect area. This step is completed through the following sub-steps:
[0021] S121, cropping the original defect image according to the Labelme annotation information, cropping a defect image of size 4096×3072 to a size that is 1.5-2.0 times the width and height of the defect size;
[0022] S122. Use enhancement methods in the field of image processing, such as filtering noise reduction, binarization black and white enhancement, quantization noise reduction processing, and MSRCR image color enhancement, to make the defect area more contrasty in the original image;
[0023] S13. Based on the preprocessed dataset, the VQ-GAN network is used to generate richer weld defect data samples, expand the dataset size, and balance the number of samples in each category.
[0024] As a preference, the model of the present invention described in step S3 can be found in the attached Figure 2 , the specific steps are:
[0025] S31. After the weld defect data is extracted through the backbone network, a feature map is output. The feature map is input into the multi-scale feature fusion structure. The structure can be found in the attached Figure 3 The structure is completed by the following sub-steps:
[0026] S311, receive feature maps of different scales, marked as C1, C2, C3 respectively;
[0027] S312, perform a 1×1 convolution layer on the C3 feature map, changing the number of channels without changing the size, and obtain C3 conv ;
[0028] S313, performing a block fusion (PM) operation on C1 and C2 respectively, and passing the C1 feature map after the PM operation through a spatial pyramid pooling fast module (SPPF), and then splicing it with the C2 feature map after the PM operation;
[0029] S314: The spliced feature map is passed through the F fusion module. This operation is completed through the following sub-steps:
[0030] S3141. Divide the concatenated feature map into two paths, one of which passes through a 1×1 convolution layer, and the other passes through a 1×1 convolution layer and then performs a PM operation. Then, the feature maps obtained from the two paths are added element by element.
[0031] S3142, flattening the feature map after element-by-element addition;
[0032] S315, C3 conv The feature maps after the F fusion module are input into the PANNetX network structure to obtain the four final multi-scale feature maps P3, P4, P5, and P6; the PANNetX structure can be found in the attached Figure 4 , which is accomplished through the following sub-steps:
[0033] S3151. C4, C5, and C6 are divided into two paths. Taking the C4 feature map as an example, one path does not undergo any operation, and the other path performs PM operation on the feature map and adds it to the C5 feature map for multi-scale fusion.
[0034] S3152, performing PM operation on the C5 feature map after multi-scale fusion again and adding it to the C6 feature map for further multi-scale fusion;
[0035] S3153, the C6 feature map after multi-scale fusion is fused with the original C6 feature map;
[0036] S3154, upsampling the integrated C6 feature map and fusing it with the unprocessed C5 feature map;
[0037] S3155, upsampling the fused C5 feature map and fusing it with the unprocessed C4 feature map to obtain a P6 feature map;
[0038] S3156, further fusing the P6 feature map with the fused C5 feature map after the PM operation to obtain the P5 feature map;
[0039] S3157, further fusing the P5 feature map with the fused C6 feature map after PM operation to obtain the P4 feature map;
[0040] S3158, the P4 feature map is subjected to a PM operation to obtain the P3 feature map, so that four feature maps (P3, P4, P5, P6) are obtained;
[0041] S32, after the multi-scale fusion module, outputs four feature maps (P3, P4, P5, P6). Using these four feature maps to simultaneously encode weld defects can enhance the feature richness and the attention score of small targets;
[0042] S33, using the small target feature enhancement encoder proposed in the present invention, dynamically adjust the attention position based on the target area and calculate the attention scores of different areas. The structure can be found in the attached Figure 5 The small target feature enhancement encoder in the present invention is completed by the following sub-steps:
[0043] S331, input four feature maps (P3, P4, P5, P6) generated by the multi-scale fusion module, among which P6 has the highest resolution and is responsible for capturing tiny defects; P3 has the lowest resolution and contains deep semantic information;
[0044] S332: Input the four feature maps into independent deformable self-attention modules respectively. Each feature map generates a local attention window according to its assigned defect target box (sorted by defect area and then bound), and only calculates the feature correlation within the window;
[0045] S333, based on the position information (x, y, w, h) of the annotated defect, dynamically adjusts the attention window size of each feature map to a fixed size (s×s) by learning the coordinate offset through a multi-layer perceptron (MLP). For example, the P6 window focuses on small defects in high-resolution areas, while the P3 window covers large target areas at low resolution.
[0046] S334. Concatenate the output sequences of the four feature maps after attention calculation according to spatial positions to form a unified feature representation, fully integrate multi-scale information, and enhance the expression ability of small objects;
[0047] S34, the decoder adopts the DETR standard structure, and fuses the multi-scale sequence output by the encoder with the query vector through cross attention. Finally, the prediction head generates the coordinates (x, y, w, h) of the detection box and the defect category probability;
[0048] S35. By comparing the model prediction results with the real labeled data, the loss function value is calculated, and the back propagation algorithm is used to automatically adjust the network parameters to improve the model's detection accuracy and positioning accuracy for weld defects.
[0049] Preferably, the specific process of using the model of the present invention to detect the image in step S4 is as follows:
[0050] S41. Use a camera to collect image data of the girth weld of the oil and gas pipeline to ensure that the image quality meets the requirements of subsequent inspections;
[0051] S42. Preprocessing the collected image to be detected according to the requirements of the present model for input data;
[0052] S43, inputting the pre-processed image to be detected into the defect detection model of the present invention to perform automatic reasoning analysis;
[0053] S44. Output the target detection frame and the corresponding defect category probability through model reasoning, and accurately locate and classify weld defects.
[0054] In summary, the distinguishing features of the technology disclosed in this invention include at least:
[0055] 1. The present invention introduces a multi-scale fusion module into the DETR architecture. After extracting multi-layer features (C1-C3), it performs feature fusion through block fusion (PM) and 1×1 convolution adjustment channels, combined with a spatial pyramid pooling fast module, and introduces the PANNetX structure. Through upsampling and block fusion operations, it completes the bidirectional path fusion of features at each scale, realizes the interactive fusion of shallow fine-grained features and deep semantic features, thereby strengthening the combination of shallow fine-grained features and deep semantic features, and further improving the accuracy of small target defect detection.
[0056] 2. This paper proposes a small target feature enhancement encoder. This encoder generates a local attention window based on defect location information. A multi-layer perceptron (MLP) predicts the offset and adaptively adjusts the window position and size to focus on the features of the defect area. The encoder dynamically matches feature maps of varying resolutions with target size, capturing tiny defects at high resolutions. This improves small target detection capabilities, effectively reduces feature information loss caused by distracted attention, and significantly enhances weld defect detection accuracy.
[0057] Compared with the prior art, the present invention has the following beneficial effects:
[0058] 1. Improve the detection accuracy of small-scale weld defects. By combining the multi-scale feature fusion module with the small target encoder, the detection capability of small or low-contrast defects (such as pores, cracks, and lack of fusion) is enhanced.
[0059] 2. Shorten model training convergence time and improve end-to-end detection efficiency. Multi-scale fusion and targeted small-target attention mechanism enable the model to achieve high detection accuracy in fewer training rounds while still maintaining a certain real-time detection speed.
[0060] 3. Simplified structure, reduced manual reliance. Unlike traditional CNN detectors, which require extensive manual design of prior anchor boxes and non-maximum suppression, this invention uses the DETR model as its core and combines it with innovative modules to simplify the deployment process and reduce reliance on professionals. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 The expanded dataset obtained using the VQ-GAN network
[0062] Figure 2 This is the model structure proposed by the present invention for weld defects
[0063] Figure 3 Multi-scale feature fusion module
[0064] Figure 4 PANNetX module structure
[0065] Figure 5 Hybrid encoder structure for small targets DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to illustrate the present invention and are not intended to limit the present invention. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present invention belongs.
[0067] The present invention will be further described below with reference to the accompanying drawings and examples.
[0068] Example 1:
[0069] The proposed model is similar to the original DETR model, both using a ResNet50 backbone network pre-trained on ImageNet-1K. Table 1 below shows the statistics of the expanded dataset, and Table 2 below demonstrates that the proposed model outperforms the comparison model in various performance metrics.
[0070] Table 1 Defect category data after data enhancement based on generative network
[0071]
[0072] Table 2 Model performance index results
[0073]
[0074] Note:
[0075] The AP50 metric is the average precision calculated with the intersection-over-union (IoU) threshold set to 0.50.
[0076] The AP75 metric is the average precision calculated with the intersection-over-union (IoU) threshold set to 0.75.
[0077] mAP (mean average precision) is a core metric for measuring the overall performance of object detection models. It first calculates the average precision (AP) for each class that the model can detect, and then takes the arithmetic mean of the AP values across all classes. mAP comprehensively considers the model's precision and recall performance across all classes.
[0078] The data in the analysis table show that the model of the present invention has a high accuracy rate for defect recognition of different sizes. Among them, the overall weld defect recognition accuracy (mAP) is improved by 12.15% compared to the traditional DETR model. The model of the present invention can achieve rapid convergence with fewer training rounds and simultaneously obtain higher detection accuracy. Its AP50 and AP75 are improved by 11.23% and 11.84% respectively. This example shows that the model of the present invention effectively solves the problem of low accuracy in identifying weld defects in small-sized oil and gas pipelines.
[0079] The above description, combined with the figures, describes the specific embodiments of the present invention, but does not limit the scope of protection of the present invention. Based on the technical solution of the present invention, various modifications or variations that can be made by relevant technicians without creative work are still within the scope of protection of the present invention.
Claims
1. A Transformer-based intelligent detection method for girth weld defects in oil and gas pipelines, characterized by: The following steps are involved: S1. Based on the collected dataset, train the VQ-GAN network to generate a rich weld defect dataset; S2. Preprocess the weld defect dataset according to the model's requirements for input images; S3. Using the preprocessed data set, train the target detection model of the present invention: (1) Backbone feature extraction network: The input image is passed through the backbone network ResNet50 to obtain image features. ResNet50 is a 50-layer deep residual neural network. Its innovation lies in the introduction of the residual connection (jump connection) mechanism, which solves the gradient vanishing problem in the deep neural network training process. This network has excellent performance in large-scale image recognition tasks and has become a classic backbone network in the field of computer vision. In the invention, ResNet50 is mainly responsible for the preliminary pre-processing of the image and preliminary feature extraction to obtain high-dimensional, high-channel image features; (2) Multi-scale fusion module: responsible for fusing and interacting the features after passing through the backbone network, amplifying the features of small objects, and increasing the richness of the feature map; (3) Small target encoder E: Design an encoder based on target offset to increase the model’s attention score on small targets and enhance the local attention of the target; (4) Decoder D: obtains information about the prediction box from the encoder through training queries based on multi-layer self-attention and cross-attention; S4. Apply the model of the present invention to perform defect detection and analysis on the weld image.
2. The intelligent detection method for girth weld defects in oil and gas pipelines based on Transformer according to claim 1 is characterized in that: The specific steps of the multi-scale fusion module described in step S3 are: S31. After the weld defect data is extracted through the backbone network, a feature map is output. The feature map is input into the multi-scale feature fusion structure. The structure can be seen in Figure 3. This structure is completed through the following sub-steps: S311, receive feature maps of different scales, marked as C1, C2, C3 respectively; S312, perform a 1×1 convolution layer on the C3 feature map, changing the number of channels without changing the size, and obtain C3 conv ; S313, performing a block fusion (PM) operation on C1 and C2 respectively, and passing the C1 feature map after the PM operation through a spatial pyramid pooling fast module (SPPF), and then splicing it with the C2 feature map after the PM operation; S314: The spliced feature map is passed through the F fusion module. This operation is completed through the following sub-steps: S3141. Divide the concatenated feature map into two paths, one of which passes through a 1×1 convolution layer, and the other passes through a 1×1 convolution layer and then performs a PM operation. Then, the feature maps obtained from the two paths are added element by element. S3142, flattening the feature map after element-by-element addition; S315, C3 conv The feature maps after the F fusion module are input into the PANNetX network structure to obtain the four final multi-scale feature maps P3, P4, P5, and P6. The PANNetX structure can be seen in Figure 4. The specific steps are as follows: S3151. C4, C5, and C6 are divided into two paths. Taking the C4 feature map as an example, one path does not undergo any operation, and the other path performs PM operation on the feature map and adds it to the C5 feature map for multi-scale fusion. S3152, performing PM operation on the C5 feature map after multi-scale fusion again and adding it to the C6 feature map for further multi-scale fusion; S3153, the C6 feature map after multi-scale fusion is fused with the original C6 feature map; S3154, upsampling the integrated C6 feature map and fusing it with the unprocessed C5 feature map; S3155, upsampling the fused C5 feature map and fusing it with the unprocessed C4 feature map to obtain a P6 feature map; S3156, further fusing the P6 feature map with the fused C5 feature map after the PM operation to obtain the P5 feature map; S3157, further fusing the P5 feature map with the fused C6 feature map after PM operation to obtain the P4 feature map; S3158. The P4 feature map is subjected to a PM operation to obtain the P3 feature map. Thus, four feature maps (P3, P4, P5, and P6) are obtained.
3. The intelligent detection method for girth weld defects in oil and gas pipelines based on Transformer according to claim 1 is characterized in that: The specific steps of the small target feature enhancement encoder designed in step S3 are as follows: S32, after the multi-scale fusion module, outputs four feature maps (P3, P4, P5, P6). Using these four feature maps to simultaneously encode weld defects can enhance the feature richness and the attention score of small targets; S33. Using the small target feature enhancement encoder proposed in the present invention, the attention position is dynamically adjusted based on the target area and the attention scores of different areas are calculated. The structure can be seen in Figure 5. The small target feature enhancement encoder in the present invention is completed by the following sub-steps: S331, input four feature maps (P3, P4, P5, P6) generated by the multi-scale fusion module, among which P6 has the highest resolution and is responsible for capturing tiny defects; P3 has the lowest resolution and contains deep semantic information; S332: Input the four feature maps into independent deformable self-attention modules respectively. Each feature map generates a local attention window according to its assigned defect target box (sorted by defect area and then bound), and only calculates the feature correlation within the window; S333, based on the position information (x, y, w, h) of the annotated defect, dynamically adjusts the attention window size of each feature map to a fixed size (s×s) by learning the coordinate offset through a multi-layer perceptron (MLP). For example, the P6 window focuses on small defects in high-resolution areas, while the P3 window covers large target areas at low resolution. S334. Concatenate the output sequences of the four feature maps after attention calculation according to their spatial positions to form a unified feature representation, fully integrate multi-scale information, and enhance the expression ability of small targets.
Citation Information
Patent Citations
A Deep Learning-Based Method for Weld and Weld Defect Detection
CN109900706B
Cited By
Audio and video signal fusion transmission method and device, equipment and medium
CN120956967A