Pipeline welding defect detection method and device, electronic equipment and storage medium
Through the brightness correction module, multi-scale transformation module and mixed loss function optimization welding defect segmentation model, the accuracy of small defect segmentation in weld ray detection is solved, and the detection accuracy and stability are improved.
Patent Information
- Application Number
- CN202510558308.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-08-05
AI Technical Summary
Existing deep learning methods are difficult to accurately segment small defects and process dynamic blurred images in weld ray detection, resulting in high false detection and miss detection rate.
The brightness correction module is used to perform random Gamma transformation, combining multi-scale transformation module and segmentation prediction network, embed multi-scale Swin Transformer blocks using an improved U-Net architecture, and design a hybrid loss function to optimize segmentation accuracy.
The detection rate of defects with smaller size or boundary blur is improved, the model's small defect feature capture ability under low-definition image conditions is enhanced, and the impact of motion blur is reduced.
Smart Images

Figure CN120431056A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of nondestructive welding testing, and in particular to a pipeline welding defect detection method, device, electronic equipment and storage medium. Background Art
[0002] Welding is a critical process in pipeline construction, ensuring the structural integrity and safety of oil, gas, and industrial transportation systems. However, defects inevitably occur during the welding process, which can severely impact safety and reliability. Timely and accurate detection of such defects is crucial for preventing failures, reducing maintenance costs, and ensuring compliance with industry safety standards. Radiographic testing, with its excellent penetration and high imaging resolution, is the primary method for nondestructive testing of welds. Traditionally, radiographic weld images are evaluated by experienced inspectors, but this manual method is highly subjective. Inspection performance depends on expertise and is susceptible to human fatigue.
[0003] Powered by high-performance hardware and big data, deep learning has developed and gained widespread application. It can automatically extract features from raw images through network training, enhancing the detection of weld defects in pipelines. This significantly reduces the workload of inspectors, improves diagnostic accuracy and efficiency, and supports defect identification. However, current deep learning methods still face the following challenges in practical applications: 1. Segmentation of small defects in radiographic images is challenging, and small defects in welds are prone to false detection or omission; 2. Existing weld radiographic inspection models perform poorly when processing dynamically blurred images, resulting in inaccurate defect boundary determination.
[0004] How to improve the detection rate of defects with small size or blurred boundaries is a technical problem that needs to be solved at present. Summary of the Invention
[0005] The present invention provides a pipeline welding defect detection method, device, electronic equipment and storage medium, which are used to solve the defects existing in the prior art.
[0006] The present invention provides a pipeline welding defect detection method, comprising the following steps: Obtain an X-ray image of the pipeline weld to be inspected; Inputting the X-ray image of the pipeline weld to be inspected into a pre-trained welding defect segmentation model and outputting a defect segmentation result; Among them, the welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module and a segmentation prediction network; the brightness correction module is used to perform random Gamma transformation on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function.
[0007] According to a pipeline welding defect detection method provided by the present invention, the training process of the welding defect segmentation model includes: Obtaining a historical X-ray image set of a pipeline weld, and dividing the historical X-ray image set into a training set, a validation set, and a test set according to a preset ratio; Performing image enhancement preprocessing on the images in the training set to obtain a target training set; Training the brightness correction module, the multi-scale transformation module, and the segmentation prediction network based on the target training set to obtain an initial welding defect segmentation model; The optimal model parameters are determined by using the validation set and the test set as the network weights of the initial welding defect segmentation model to obtain the welding defect segmentation model.
[0008] According to a pipeline welding defect detection method provided by the present invention, a historical X-ray image set of pipeline welds is obtained, and the historical X-ray image set is divided into a training set, a validation set, and a test set according to a preset ratio, including: Obtain a historical X-ray image set of pipeline welds, classify the historical X-ray image set according to defect categories, and perform pixel-level defect annotation based on the classification results to generate an annotation file; wherein the defect categories include: normal, crack, unfused, pore, and slag inclusion; The labeled files are divided into a training set, a validation set, and a test set according to a preset ratio.
[0009] According to a pipeline welding defect detection method provided by the present invention, the multi-scale transformation module adopts an improved U-Net architecture, and a multi-scale Swin Transformer block is embedded at the encoder end of the improved U-Net architecture. The multi-scale Swin Transformer block is used to process images with different receptive fields.
[0010] According to a pipeline welding defect detection method provided by the present invention, the execution process of the multi-scale Swin Transformer block includes: Obtain an input feature map, divide the input feature map into three paths, and perform pooling operations with pooling kernels of different scales on the input feature maps of the three paths; wherein the input feature map is obtained by performing a random Gamma transform on the X-ray image and then processing it through the encoder of the improved U-Net architecture; Inputting the pooled input feature map of each path into the multi-scale Swin Transformer block for global reasoning to obtain an enhanced feature map; The enhanced feature maps of the two paths with larger scale pooling kernels among the three paths are upsampled and spliced, and the spliced enhanced feature map is spliced and convolved with the enhanced feature map of the path with the smallest scale pooling kernel among the three paths to obtain a multi-scale output feature map.
[0011] According to a pipeline welding defect detection method provided by the present invention, the pre-designed hybrid loss function is a weighted combination of Dice loss, Focal loss and boundary loss.
[0012] According to a pipeline welding defect detection method provided by the present invention, obtaining an X-ray image of the pipeline weld to be detected includes: Acquire an X-ray image of the pipeline weld to be inspected through a PCIe data communication interface; Among them, the PCIe data communication interface is used to connect to the image acquisition system, and the image acquisition system includes: an X-ray source, an image intensifier and a CCD camera. The X-ray source is used to emit X-rays, the image intensifier is used to receive the X-ray signal after passing through the steel pipe and convert it into a visible light signal, and the CCD camera is used to collect the visible light signal and generate the X-ray image through a digital-to-analog converter.
[0013] The present invention also provides a pipeline welding defect detection device, comprising the following modules: An acquisition module, used for acquiring an X-ray image of the pipeline weld to be inspected; A detection module, configured to input the X-ray image of the pipeline weld to be detected into a pre-trained welding defect segmentation model and output a defect segmentation result; Among them, the welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module and a segmentation prediction network; the brightness correction module is used to perform random Gamma transformation on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function.
[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the pipeline welding defect detection method described above is implemented.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the pipeline welding defect detection method as described above is implemented.
[0016] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned pipeline welding defect detection methods.
[0017] The present invention provides a pipeline welding defect detection method, device, electronic device, and storage medium. The method involves acquiring an X-ray image of a pipeline weld to be inspected, inputting the X-ray image of the pipeline weld to be inspected into a pre-trained welding defect segmentation model, and outputting a defect segmentation result. The welding defect segmentation model comprises a brightness correction module, a multi-scale transformation module, and a segmentation prediction network. The brightness correction module performs a random gamma transform on the X-ray image, the multi-scale transformation module obtains multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes segmentation accuracy using a pre-designed hybrid loss function. The present invention designs a brightness correction module that, combined with a random gamma transform, simulates the dynamic brightness adjustment behavior of experts during image observation, guiding the network to focus on contrast enhancement in defect areas, thereby improving the model's ability to perceive small defects. In terms of network structure, the present invention introduces a multi-scale transformation module to fuse global context and local detail information, effectively enhancing the model's ability to capture small defect features in low-definition image conditions. A hybrid loss function is designed to further improve the segmentation accuracy of defect edges and effectively reduce the effects of motion blur. Compared with the existing methods, the present invention can improve the detection rate of defects with small size or blurred boundaries. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 It is a flow chart of the pipeline welding defect detection method provided by the present invention.
[0020] Figure 2 This is a system architecture diagram of the X-ray-based pipeline welding defect detection device provided by the present invention.
[0021] Figure 3 It is a structural schematic diagram of the pipeline welding defect detection device based on X-ray provided by the present invention.
[0022] Figure 4 This is a network structure diagram and module detailed diagram of the welding defect segmentation model provided by the present invention.
[0023] Figure 5It is a schematic diagram comparing the detection results of the pipeline welding defect detection method provided by the present invention and the detection results of the prior art method.
[0024] Figure 6 It is a schematic diagram of an enlarged comparison of the results of detecting small defects using the pipeline welding defect detection method provided by the present invention and the prior art method.
[0025] Figure 7 It is a structural schematic diagram of the pipeline welding defect detection device provided by the present invention.
[0026] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0027] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0028] The following combination Figures 1-8 The present invention describes a pipeline welding defect detection method, device electronic equipment and storage medium.
[0029] Figure 1 FIG. 1 is a flow chart of the pipeline welding defect detection method provided by the present invention, as shown in FIG. Figure 1 As shown, the method includes the following: Step 100: Acquire an X-ray image of the pipeline weld to be inspected.
[0030] Figure 2 This is a system architecture diagram of the X-ray based pipeline welding defect detection device provided by the present invention, such as Figure 2 As shown, the X-ray-based pipeline welding defect detection device provided in this embodiment includes: an image acquisition system, an image transmission system and an image processing system.
[0031] Step 100 acquires an X-ray image of the pipeline weld to be inspected, including: Acquire an X-ray image of the pipeline weld to be inspected through a PCIe data communication interface; Among them, the PCIe data communication interface is used to connect to the image acquisition system, and the image acquisition system includes: an X-ray source, an image intensifier and a CCD camera. The X-ray source is used to emit X-rays, the image intensifier is used to receive the X-ray signal after passing through the steel pipe and convert it into a visible light signal, and the CCD camera is used to collect the visible light signal and generate the X-ray image through a digital-to-analog converter.
[0032] Figure 3 This is a schematic diagram of the structure of the pipeline welding defect detection device based on X-ray provided by the present invention. Figure 3 , the image acquisition system, image transmission system and image processing system are explained respectively.
[0033] The image acquisition system is responsible for completing X-ray imaging, and its components include an X-ray source, an image intensifier, and a CCD camera. During the inspection process, the X-ray source is fixed inside the steel pipe, which is carried by a conveyor trolley and passes through the inspection area at a constant speed, allowing the X-rays to gradually scan the weld area along the axis of the pipe. When the X-rays penetrate the steel pipe, their transmission intensity is affected by the weld material and defects. The transmitted X-ray signal is received by the image intensifier fixed to the outside of the steel pipe and converted into a visible light image. Subsequently, the CCD camera images the converted visible light image and outputs an analog signal to ensure that subsequent image analysis can obtain a clear, well-contrast inspection image. The precise layout and synchronous control of this module ensure that the X-rays can stably and evenly cover the entire weld area, thereby improving image quality and detection reliability.
[0034] The image transmission system is responsible for converting the image signals captured by the CCD camera into digital data and efficiently transmitting them to the computer system. This module consists of a digital-to-analog converter, an image acquisition card, and a data communication interface. First, the visible light image captured by the CCD camera is output as an analog signal. The digital-to-analog converter then digitizes the analog signal and converts it into a standard digital image format. The converted digital image is then transmitted to the image acquisition card, which is responsible for caching, processing, and further transmitting the data to the computer system. During data transmission, the system uses a PCIe data communication interface to ensure low-latency, high-bandwidth data transmission, allowing digital images to be input into the computer in real time. The module's efficient transmission mechanism ensures that the detection images can be transmitted to the computer system losslessly and at high speed, providing stable data input for subsequent deep learning analysis.
[0035] The image processing system is responsible for performing efficient computation and deep learning inference on digital images transmitted to the computer to enable automatic detection and analysis of weld defects. This module relies on high-performance computing hardware, including two Intel Xeon Gold 6226R processors and two NVIDIA GeForce RTX 4090 graphics cards, to accelerate deep learning-based weld defect detection and ensure real-time and stable data processing. To optimize data access efficiency, high-speed SSD solid-state storage is used to reduce I / O bottlenecks and improve data loading and caching performance. Ultimately, the computer system outputs the detection results of the deep learning model to the monitoring interface in real time, providing intelligent analytical support for welding quality assessment. The module's high-performance computing architecture ensures the real-time, accurate, and stable nature of weld defect detection, providing strong support for intelligent quality control.
[0036] In one embodiment, a spirally welded steel pipe is first placed on a conveyor cart. As the cart advances, its rotating rollers drive the spirally welded pipe. These two combined motions create a spiral forward motion of the weld, ensuring that the weld remains directly below the image intensifier during this motion. X-rays emitted by the X-ray source penetrate the steel pipe and weld area before being received by the image intensifier's input screen. The invisible X-rays are converted into photoelectric signals, which are then converted within the image intensifier to form a visible image on the image intensifier's output screen. The image intensifier used in this embodiment is a TOSHIBA E5804SD-P6. See Table 1 for its main technical parameters.
[0037] Table 1
[0038] A degaussing coil eliminates residual magnetic fields to improve image quality, and a lead-plate collimator reduces scattered radiation, eliminating blind spots at the tube ends. A digital CCD camera captures the image on the image intensifier's output screen at 24 frames per second, performs A / D conversion to digitize the image, and transmits the image data in real time to a digital image acquisition card. Table 2 lists the technical specifications of the CCD camera. The image acquisition card then stores the data collected from the CCD camera in an industrial control computer.
[0039] Table 2
[0040] Step 200: Input the X-ray image of the pipeline weld to be inspected into a pre-trained welding defect segmentation model, and output a defect segmentation result; Among them, the welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module and a segmentation prediction network; the brightness correction module is used to perform random Gamma transformation on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function.
[0041] In this embodiment, the training process of the welding defect segmentation model is described, which specifically includes: Step 210: Obtain a historical X-ray image set of the pipeline weld, and divide the historical X-ray image set into a training set, a validation set, and a test set according to a preset ratio.
[0042] Step 210 specifically includes: Step 211: Obtain a historical X-ray image set of the pipeline weld, classify the historical X-ray image set according to defect categories, and perform pixel-level defect annotation based on the classification results to generate an annotation file; wherein the defect categories include: normal, crack, unfused, pore, and slag inclusion.
[0043] Step 212: Divide the annotated file into a training set, a validation set, and a test set according to a preset ratio.
[0044] Specifically, historical X-ray images from the pipeline weld inspection process are obtained, and the X-ray images are classified into normal, cracked, unfused, porosity, and slag inclusion defects. The corresponding digital images are annotated with pixel-level defects, and an annotation file is generated. The images and annotation files are divided into training set, validation set, and test set according to a 6:2:2 ratio.
[0045] Step 220: Perform image enhancement preprocessing on the images in the training set to obtain a target training set.
[0046] Specifically, before the weld radiographic images are input into the model training, the images need to be preprocessed with image enhancement, and traditional image processing methods are used to increase the diversity of samples to form the final weld radiographic defect training set.
[0047] In one embodiment, an X-ray-based pipeline welding defect detection device based on the above-mentioned embodiment was used to analyze defects found in the steel pipe welding production line within a pipe welding plant on a long-distance natural gas pipeline. Based on tens of thousands of defect images, those with typical defect features were selected and annotated. Under the guidance of evaluation experts, the dataset was pixel-by-pixel labeled using the Labelme platform according to the standards and acceptance criteria for the current production batch, and annotation files were generated. Ultimately, 783 pixel-by-pixel labeled defect images with a resolution of 512×512 were annotated. These included four defect types: lack of fusion, porosity, slag inclusion, and broken arc. The images and annotation files were divided into training, validation, and test sets in a 6:2:2 ratio.
[0048] To improve the model's generalization and reduce the risk of overfitting, image augmentation techniques were used to increase the diversity and size of the dataset. Data augmentation was performed using geometric transformations and intensity adjustment transformations based on the original images. The specific image processing parameters are shown in Table 3. This resulted in a dataset of 8,613 images for model training and testing.
[0049] Table 3
[0050] Step 230: Training the brightness correction module, the multi-scale transformation module, and the segmentation prediction network based on the target training set to obtain an initial welding defect segmentation model.
[0051] Step 240: Determine optimal model parameters using the validation set and the test set as network weights of the initial welding defect segmentation model to obtain the welding defect segmentation model.
[0052] Specifically, Figure 4 This is the network structure diagram and module detailed diagram of the welding defect segmentation model provided by the present invention, such as Figure 4 As shown in the figure, the welding defect segmentation model proposed in this embodiment includes a brightness correction module for simulating experts, a backbone network and a multi-scale Swin Transformer block. The backbone structure of the network is an encoding-decoding structure. The multi-scale Swin Transformer block is embedded between the encoder and decoder to capture global context information and improve the segmentation accuracy of small defects, bringing higher accuracy and reliability to weld X-ray image analysis.
[0053] During training, the model first applies a random gamma transformation (ranging from 0.5 to 2.0) to the input image through a brightness correction module to simulate the dynamic brightness adjustment that experts make when observing X-ray images. This enhancement strategy aims to replicate the human ability to adapt to different lighting conditions during diagnosis, thereby guiding the model to learn a feature extraction method that is closer to the expert judgment process. By diversifying the image brightness, the model is exposed to a wider range of lighting conditions during training, thereby enhancing its robustness and generalization capabilities to lighting changes. In addition, because the network has been fully trained on images with different brightness distributions, its parameters can better adapt to the imaging characteristics of the current inspection environment, thereby learning how to highlight small defects.
[0054] Convolutional layers, instance normalization, leaky ReLU activation functions, and max pooling layers are repeated during the encoding and decoding process. Using leaky ReLU instead of ReLU allows negative inputs to have a small positive gradient, which can avoid inactive neurons and thus improve the stability and convergence speed of model training. Using instance normalization instead of batch normalization can provide the model with a normalization method that is more independent of batch size, which is especially beneficial when processing small batches of data or emphasizing the specificity of each data sample. Skip connections are used to directly connect the feature maps of shallower layers (encoder) with the feature maps of deeper layers (decoder). This design allows the network to directly utilize the rich information of the original features when reconstructing high-resolution details, thereby enhancing the model's feature transfer capabilities.
[0055] A multi-scale Swin Transformer block is introduced at the end of the encoder path. It can be used to process images with different receptive fields to improve the segmentation accuracy of blurred edges and small defects. Information from different scales is then fused into the decoder to improve accuracy while flexibly balancing the model's computational workload and robustness. Specifically, the input is first divided into three different paths. Each path undergoes a convolution operation with a kernel size of 3×3. Then, pooling operations with kernel sizes of 2×2, 3×3, and 5×5 are performed, respectively. The input is then fed into a multi-scale Swin Transformer block for global inference, which encodes weld information at different scales into global features. The feature maps of the two paths with the larger pooling kernel are upsampled using bilinear interpolation, concatenated, and then concatenated with the feature map of the minimum pooling kernel. Finally, the concatenated feature map is processed by the output convolution layer to generate the final output as the decoder input. The process is shown in the following formula: Among them, x represents the input data, Represents information of different scales, TR represents the Swin Transformer module, and Output is the output result of the module.
[0056] Based on the two standard Transformer modules, W-MSA and SW-MSA are used to replace the original MSA block. In W-MSA, the input features will be divided into non-overlapping windows, and each window contains M×M patches (set to 7 by default). W-MSA is only calculated in the local window. This method allows the model to focus more on processing information within a small range, which is particularly beneficial for tasks that require high-precision detail recognition (such as the detection of small defects in weld images). Using SW-MSA after W-MSA enables the model to capture information between windows by offsetting the position of windows between different layers, thereby improving the interaction between windows. By cyclically shifting to the upper left corner, information from multiple non-adjacent sub-windows in the feature map can be processed to integrate information from different windows. When calculating self-attention, W-MSA and SW-MSA take into account the relative position relationship between pixels in the local window, which can help the model better understand the spatial structure within the image. The mathematical formula of the multi-scale SwinTransformer block is as follows: in, and where represents the input and output of the Swin Transformer module, respectively. LN is used to normalize the internal features of samples in a batch. MLP represents a fully connected feedforward network that maps the normalized input to a new space.
[0057] This example replaces the loss function with a combination of Dice loss and Focal loss. Dice loss is a set-based metric that focuses on the global consistency between the predicted mask and the true mask, optimizing model performance by maximizing the overlap between the two. Focal loss is specifically designed to address the problem of class imbalance. It introduces a coefficient factor to the standard cross-entropy loss, increasing the relative weight of difficult-to-classify samples while reducing the weight of easy-to-classify samples, allowing the model to focus more on those difficult-to-identify minority classes. The formulas for Dice loss and Focal loss are as follows: Where pi is the predicted probability, qi is the true label, and N is the total number of pixels. This is achieved by adjusting the values of α and γ in the focal loss. α balances the weights of positive and negative samples, while γ reduces the loss of simple samples to address the large loss of negative samples after summing.
[0058] Boundary Loss is further introduced to improve edge recognition accuracy for defects such as small pores, slag inclusions, and long cracks. This loss function focuses on narrowing the gap between the predicted boundary and the true boundary, effectively improving the model's ability to recognize image edges. Its formula is as follows: Among them, Gi is the element of the Euclidean distance map of the labeled mask, which represents the Euclidean distance from the point on the mask to the nearest foreground pixel.
[0059] Introducing weight coefficients into different hybrid loss functions controls their contribution to the total loss, thereby utilizing the advantages of each loss and achieving a comprehensive balance of different optimization objectives through appropriate weight adjustment. The final improved weld segmentation joint loss function is shown below: in, , and They represent the weights of different loss functions.
[0060] During training, the initial learning rate was set to 0.01, and stochastic gradient descent was performed using Nesterov momentum gradient descent with u=0.99. Training was performed for 500 epochs, each consisting of 250 iterations. The best-performing model weights in the validation set were selected as the trained model weights, and this trained model was used to implement pipeline weld defect detection.
[0061] The above is a description of the steps of the pipeline welding defect detection method provided by the present invention. From the description of the above steps, it can be seen that according to the pipeline welding defect detection method provided by the present invention, an X-ray image of the pipeline weld to be inspected is obtained; the X-ray image of the pipeline weld to be inspected is input into a pre-trained welding defect segmentation model, and a defect segmentation result is output. The welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module, and a segmentation prediction network; the brightness correction module is used to perform a random gamma transform on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function. As can be seen, the present invention designs a brightness correction module, combined with a random gamma transformation to simulate the dynamic adjustment behavior of the expert on brightness during image observation, guiding the network to focus on contrast enhancement of the defect area, thereby improving the model's perception of small defects; in terms of network structure, the present invention introduces a multi-scale transformation module to fuse global context and local detail information, effectively enhancing the model's ability to capture small defect features under low-definition image conditions; to further improve the segmentation accuracy of defect edges and effectively reduce the impact of motion blur, a hybrid loss function is designed. Compared with the existing methods, the present invention can improve the detection rate of defects with small size or blurred boundaries.
[0062] Based on the above embodiments, in this embodiment, the detection effect of the pipeline welding defect detection method provided by the present invention is described.
[0063] Figure 5 FIG. 1 is a schematic diagram comparing the detection results of the pipeline welding defect detection method provided by the present invention and the detection results of the prior art method, as shown in FIG. Figure 5 As shown, the actual segmentation results of different methods are shown. The pipeline welding defect detection method provided by the present invention achieves relatively complete segmentation results for the influence of cross-scale, small defects and contextual relationship complexity, and shows significant advantages in identifying subtle features and maintaining segmentation continuity. For example, in the detection of slender, low-contrast structures, the method provided by the present invention can maintain a high degree of consistency with the true label, especially in the edge part of the image, the welding defect segmentation model provided by the present invention shows better edge accuracy and reduces the misclassification phenomenon. In terms of specific indicator comparisons, such as accuracy, recall rate, Dice coefficient and IoU, the method provided by the present invention surpasses all other models. This shows that the model of the present invention has excellent performance in segmentation accuracy, labeling completeness and overlap between the predicted area and the real area. The excellent Dice coefficient and IoU further demonstrate the segmentation quality of the method of the present invention, emphasizing its advantages in prediction accuracy and reliability.
[0064] In order to further evaluate the effectiveness of the welding defect segmentation model provided by the present invention in identifying small defects and reducing missed detection of small defects, the detection results were magnified and displayed. Figure 6 This is a schematic diagram showing the comparison of the pipeline welding defect detection method provided by the present invention and the results of detecting small defects using the existing technology. Figure 6 It can be seen that there is a slag inclusion defect at the bottom of the image. The detection results of each model are magnified and analyzed: only the welding defect segmentation model provided by the present invention detects this defect, while the other models miss it. This proves that the welding defect segmentation model provided by the present invention can still identify other small defects when there are other larger defects and is not affected by category imbalance.
[0065] The pipeline welding defect detection method provided by an embodiment of the present invention introduces a trainable brightness correction module before the segmentation network. By performing a random Gamma transform on the input image, it simulates the diagnostic process of human experts and learns how to highlight the features of small defects, which can effectively improve the detection rate of small defects with inconspicuous low contrast. A multi-scale transformation module is proposed to obtain multi-scale global attention features, and a multi-scale Swin Transformer block is used as a feature extractor to enhance the model's feature extraction capability, thereby improving the recognition accuracy of small defects. A hybrid loss function is introduced, which merges the focal loss and boundary (BD) loss into the existing binary cross entropy (BCE) and dice loss, improving the segmentation accuracy of weld edges under severe class imbalance and effectively reducing the influence of motion blur.
[0066] The pipeline welding defect detection device provided by the present invention is described below. The pipeline welding defect detection device described below and the pipeline welding defect detection method described above can be referenced to each other.
[0067] Figure 7 This is a schematic diagram of the structure of the pipeline welding defect detection device provided by the present invention. Figure 7 As shown, the pipeline welding defect detection device provided by the present invention includes: An acquisition module 701 is used to acquire an X-ray image of the pipeline weld to be inspected; The detection module 702 is configured to input the X-ray image of the pipeline weld to be detected into a pre-trained welding defect segmentation model and output a defect segmentation result; Among them, the welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module and a segmentation prediction network; the brightness correction module is used to perform random Gamma transformation on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function.
[0068] The pipeline welding defect detection device provided by the present invention obtains an X-ray image of the pipeline weld to be inspected, inputs the X-ray image of the pipeline weld to be inspected into a pretrained welding defect segmentation model, and outputs a defect segmentation result. The welding defect segmentation model includes a brightness correction module, a multi-scale transformation module, and a segmentation prediction network. The brightness correction module performs a random gamma transform on the X-ray image, the multi-scale transformation module obtains multi-scale global attention features from the X-ray image, and the segmentation prediction network optimizes segmentation accuracy using a pre-designed hybrid loss function. The brightness correction module, combined with the random gamma transform, simulates the dynamic brightness adjustment behavior of experts during image observation, guiding the network to focus on contrast enhancement in defect areas, thereby improving the model's ability to perceive small defects. In terms of network structure, the present invention introduces a multi-scale transformation module to fuse global context and local detail information, effectively enhancing the model's ability to capture small defect features in low-resolution images. A hybrid loss function is designed to further improve the segmentation accuracy of defect edges and effectively reduce the effects of motion blur. Compared with existing methods, the present invention can improve the detection rate of small defects or those with blurred boundaries.
[0069] Based on the above embodiment, in this embodiment, the device further includes a training module, which is specifically configured to: Obtaining a historical X-ray image set of a pipeline weld, and dividing the historical X-ray image set into a training set, a validation set, and a test set according to a preset ratio; Performing image enhancement preprocessing on the images in the training set to obtain a target training set; Training the brightness correction module, the multi-scale transformation module, and the segmentation prediction network based on the target training set to obtain an initial welding defect segmentation model; The optimal model parameters are determined by using the validation set and the test set as the network weights of the initial welding defect segmentation model to obtain the welding defect segmentation model.
[0070] Based on the above embodiment, in this embodiment, the device further includes a division module, which is specifically configured to: Obtain a historical X-ray image set of pipeline welds, classify the historical X-ray image set according to defect categories, and perform pixel-level defect annotation based on the classification results to generate an annotation file; wherein the defect categories include: normal, crack, unfused, pore, and slag inclusion; The labeled files are divided into a training set, a validation set, and a test set according to a preset ratio.
[0071] Based on the above embodiment, in this embodiment, the multi-scale transformation module adopts an improved U-Net architecture, and embeds a multi-scale Swin Transformer block at the encoder end of the improved U-Net architecture, and the multi-scale Swin Transformer block is used to process images with different receptive fields.
[0072] Based on the above embodiment, in this embodiment, the execution process of the multi-scale Swin Transformer block includes: Obtain an input feature map, divide the input feature map into three paths, and perform pooling operations with pooling kernels of different scales on the input feature maps of the three paths; wherein the input feature map is obtained by performing a random Gamma transform on the X-ray image and then processing it through the encoder of the improved U-Net architecture; Inputting the pooled input feature map of each path into the multi-scale Swin Transformer block for global reasoning to obtain an enhanced feature map; The enhanced feature maps of the two paths with larger scale pooling kernels among the three paths are upsampled and spliced, and the spliced enhanced feature map is spliced and convolved with the enhanced feature map of the path with the smallest scale pooling kernel among the three paths to obtain a multi-scale output feature map.
[0073] Based on the above embodiment, in this embodiment, the pre-designed hybrid loss function is a weighted combination of Dice loss, Focal loss and boundary loss.
[0074] Based on the above embodiment, in this embodiment, the acquisition module 701 is specifically configured to: Acquire an X-ray image of the pipeline weld to be inspected through a PCIe data communication interface; Among them, the PCIe data communication interface is used to connect to the image acquisition system, and the image acquisition system includes: an X-ray source, an image intensifier and a CCD camera. The X-ray source is used to emit X-rays, the image intensifier is used to receive the X-ray signal after passing through the steel pipe and convert it into a visible light signal, and the CCD camera is used to collect the visible light signal and generate the X-ray image through a digital-to-analog converter.
[0075] Figure 8 An example of a physical structure diagram of an electronic device is shown below. Figure 8As shown, the electronic device may be a robot or other electronic device, and may include: a processor 810, a communications interface 820, a memory 830, and a communication bus 840. The processor 810, the communications interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 may call logic instructions in the memory 830 to execute a pipeline welding defect detection method, including: Obtain an X-ray image of the pipeline weld to be inspected; Inputting the X-ray image of the pipeline weld to be inspected into a pre-trained welding defect segmentation model and outputting a defect segmentation result; Among them, the welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module and a segmentation prediction network; the brightness correction module is used to perform random Gamma transformation on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function.
[0076] Furthermore, the logic instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.
[0077] On the other hand, the present invention further provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the pipeline welding defect detection method provided by the above methods, including: Obtain an X-ray image of the pipeline weld to be inspected; Inputting the X-ray image of the pipeline weld to be inspected into a pre-trained welding defect segmentation model and outputting a defect segmentation result; Among them, the welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module and a segmentation prediction network; the brightness correction module is used to perform random Gamma transformation on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function.
[0078] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the pipeline welding defect detection method provided by the above methods, including: Obtain an X-ray image of the pipeline weld to be inspected; Inputting the X-ray image of the pipeline weld to be inspected into a pre-trained welding defect segmentation model and outputting a defect segmentation result; Among them, the welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module and a segmentation prediction network; the brightness correction module is used to perform random Gamma transformation on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function.
[0079] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0080] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.
[0081] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A pipeline welding defect detection method, characterized in that: include: Obtain an X-ray image of the pipeline weld to be inspected; Inputting the X-ray image of the pipeline weld to be inspected into a pre-trained welding defect segmentation model and outputting a defect segmentation result; Among them, the welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module and a segmentation prediction network; the brightness correction module is used to perform random Gamma transformation on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function.
2. The pipeline welding defect detection method according to claim 1, characterized in that: The training process of the welding defect segmentation model includes: Obtaining a historical X-ray image set of a pipeline weld, and dividing the historical X-ray image set into a training set, a validation set, and a test set according to a preset ratio; Performing image enhancement preprocessing on the images in the training set to obtain a target training set; Training the brightness correction module, the multi-scale transformation module, and the segmentation prediction network based on the target training set to obtain an initial welding defect segmentation model; The optimal model parameters are determined by using the validation set and the test set as the network weights of the initial welding defect segmentation model to obtain the welding defect segmentation model.
3. The pipeline welding defect detection method according to claim 2, characterized in that: The method of obtaining a historical X-ray image set of a pipeline weld and dividing the historical X-ray image set into a training set, a validation set, and a test set according to a preset ratio includes: Obtain a historical X-ray image set of pipeline welds, classify the historical X-ray image set according to defect categories, and perform pixel-level defect annotation based on the classification results to generate an annotation file; wherein the defect categories include: normal, crack, unfused, pore, and slag inclusion; The labeled files are divided into a training set, a validation set, and a test set according to a preset ratio.
4. The pipeline welding defect detection method according to claim 1, characterized in that: The multi-scale transformation module adopts an improved U-Net architecture, and embeds a multi-scale Swin Transformer block at the encoder end of the improved U-Net architecture. The multi-scale Swin Transformer block is used to process images with different receptive fields.
5. The pipeline welding defect detection method according to claim 4, characterized in that: The execution process of the multi-scale SwinTransformer block includes: Obtain an input feature map, divide the input feature map into three paths, and perform pooling operations with pooling kernels of different scales on the input feature maps of the three paths; wherein the input feature map is obtained by performing a random Gamma transform on the X-ray image and then processing it through the encoder of the improved U-Net architecture; Inputting the pooled input feature map of each path into the multi-scale Swin Transformer block for global reasoning to obtain an enhanced feature map; The enhanced feature maps of the two paths with larger scale pooling kernels among the three paths are upsampled and spliced, and the spliced enhanced feature map is spliced and convolved with the enhanced feature map of the path with the smallest scale pooling kernel among the three paths to obtain a multi-scale output feature map.
6. The pipeline welding defect detection method according to claim 1, characterized in that: The pre-designed hybrid loss function is a weighted combination of Dice loss, Focal loss and boundary loss.
7. The pipeline welding defect detection method according to claim 1, characterized in that: The method of obtaining an X-ray image of the pipeline weld to be inspected includes: Acquire an X-ray image of the pipeline weld to be inspected through a PCIe data communication interface; Among them, the PCIe data communication interface is used to connect to the image acquisition system, and the image acquisition system includes: an X-ray source, an image intensifier and a CCD camera. The X-ray source is used to emit X-rays, the image intensifier is used to receive the X-ray signal after passing through the steel pipe and convert it into a visible light signal, and the CCD camera is used to collect the visible light signal and generate the X-ray image through a digital-to-analog converter.
8. A pipeline welding defect detection device, characterized in that: include: An acquisition module, used for acquiring an X-ray image of the pipeline weld to be inspected; A detection module, configured to input the X-ray image of the pipeline weld to be detected into a pre-trained welding defect segmentation model and output a defect segmentation result; Among them, the welding defect segmentation model includes: a brightness correction module, a multi-scale transformation module and a segmentation prediction network; the brightness correction module is used to perform random Gamma transformation on the X-ray image, the multi-scale transformation module is used to obtain the multi-scale global attention features of the X-ray image, and the segmentation prediction network optimizes the segmentation accuracy through a pre-designed hybrid loss function.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the pipeline welding defect detection method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the pipeline welding defect detection method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Weld joint detection method and device based on deep learning
CN120598949A