A terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network

By improving the MASK-R-CNN network and CBAM module, and combining them with the natural exponential loss function, the problem of background noise interference in the defect detection of polyethylene pipe hot-melt joints was solved, achieving high-precision defect identification and detection, and improving detection efficiency and accuracy.

CN120894313BActive Publication Date: 2026-04-14JIAXING SPECIAL EQUIP TESTING INST
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JIAXING SPECIAL EQUIP TESTING INST
Filing Date
2025-07-23
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In the detection of defects in polyethylene pipe hot-melt joints, existing technologies are inadequate because traditional methods struggle to adaptively select feature ranges, manual analysis is inefficient, and complex background noise can easily mask defect features, leading to inaccurate and inefficient detection.

Method used

An improved MASK-R-CNN network is adopted, which combines a CBAM module and a loss function in the form of natural exponential form to enhance the feature representation capability. Through the synergistic effect of the dual attention mechanism and the loss function, accurate detection of defects in the hot-melt joints of polyethylene pipes is achieved.

Benefits of technology

This method improves the accuracy and robustness of defect detection in polyethylene pipelines, overcomes interference from complex background noise, and provides an efficient and reliable detection method to ensure the safe operation of pipelines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120894313B_ABST
    Figure CN120894313B_ABST
Patent Text Reader

Abstract

The application discloses a terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network, and comprises the following steps: step 1, a terahertz tomography method is used to automatically acquire a detection image, the image is divided into a training set, a verification set and a test set according to a ratio of 5:2:3, and a data set is converted into a standard COCO format through Label-Image and LabelMe tools; and step 2, the tomographic image is input into the improved MASK-R-CNN network for training.The terahertz polyethylene pipeline defect detection method based on the improved MASK-R-CNN network has the beneficial effect that an improved MASK-R-CNN polyethylene pipeline defect identification model based on CBAM is constructed, and accurate detection and identification of PE pipeline hot-melt joint defects are realized under complex background noise interference.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of industrial vision, specifically relating to a terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network. Background Technology

[0002] In recent years, polyethylene (PE) pipes have been widely used in urban gas systems, water supply pipelines, and other infrastructure due to their corrosion resistance and flexibility. However, their hot-melt welded joints are prone to defects such as voids, incomplete fusion, and inclusions due to impurities in raw materials, equipment wear, environmental factors, and improper human operation. These defects can lead to a decline in the mechanical properties of the pipeline and even cause safety accidents such as rupture and gas leaks, which may endanger public safety and the integrity of infrastructure, especially in densely populated areas. Therefore, high-precision defect detection of PE pipe hot-melt joints is a crucial step in ensuring their safe operation.

[0003] Except for steel-reinforced plastic composite pipes, non-metallic pipes lack electrical conductivity and magnetism, significantly distinguishing them from metallic pressure equipment. This unique characteristic limits the applicability of non-destructive testing (NDT) methods. Among traditional NDT techniques, ultrasonic testing, X-ray testing, and penetrant testing are the only feasible options for evaluating non-metallic pipes; however, their applicability is limited. In X-ray testing, the inherently low X-ray attenuation of non-metallic materials necessitates the use of low exposure energy to enhance contrast and improve defect detection sensitivity. However, this low-energy method reduces image clarity. For ultrasonic testing, while the nonlinear ultrasonic guided wave delay method can identify the location of structural damage within non-metallic pipes, it falls short in accurately describing the geometric features of the damage. The penetration capability of microwave testing methods is closely related to material properties; PE pipes, being high dielectric constant materials, exhibit strong absorption and scattering of microwaves.

[0004] Terahertz waves are electromagnetic waves with frequencies between 0.1 and 10 terahertz. They have strong penetrating power through non-polar materials and offer advantages such as non-contact operation, short wavelength, and high safety. Terahertz time-of-flight tomography (TOF) is a quasi-optical non-destructive testing method that has attracted widespread attention in a range of imaging applications, particularly in defect detection. Combining terahertz time-domain spectroscopy with TOF can acquire tomographic images with sub-millimeter resolution, clearly revealing the location and structure of defects in polyethylene pipes.

[0005] The patent, with publication number CN110084812A, entitled "An Invention Patent on a Method, Apparatus, System, and Storage Medium for Terahertz Image Defect Detection," and IPC classification number G06T 7 / 00, discloses the following technical solution: "Establishing a terahertz image defect detection model; acquiring a terahertz image to be detected; using the terahertz image defect detection model to extract visual features from the terahertz image to be detected, obtaining overall visual features and local salient map features; analyzing the overall visual features and local salient map features based on an attention mechanism to obtain weighted features; and performing identification analysis on the weighted features to obtain the defect category corresponding to the terahertz image to be detected."

[0006] Therefore, the above-mentioned invention patents have disclosed one technical solution for terahertz image defect detection. However, the technical solution disclosed in the above invention patents focuses on applying local saliency map features to the overall visual features through an attention mechanism. The resulting weighted features not only include the overall visual features of the terahertz image to be detected, but also strengthen the important local features of the terahertz image to be detected, thereby improving the accuracy of defect identification. However, it does not further consider that the geometry of PE pipes may introduce complex background noise, and the defect features in the terahertz signal are easily masked by noise. Therefore, manually evaluating defects in the detected image is often inaccurate and inefficient. With the development of computer technology, traditional image processing methods have been widely used in the field of defect detection. However, the location and depth of defects in polyethylene pipes are variable, and traditional algorithms are difficult to adaptively select feature intervals. Manual analysis is inefficient and relies on experience, requiring further improvement. Summary of the Invention

[0007] In view of the current situation of the prior art and to overcome the above-mentioned defects, the present invention provides a terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network.

[0008] The terahertz polyethylene pipe defect detection method disclosed in this invention, based on an improved MASK-R-CNN network, aims to automatically acquire detection images using terahertz tomography; embed CBAM into each residual block of the ResNet50 backbone network to enhance the feature representation capability of the target region and strengthen the network's attention to the input data; and employs... Loss function replaces traditional The loss function addresses the gradient instability issue during optimization, ensuring stable model convergence. Following these steps, high-precision detection and identification of defects at the hot-melt joints of polyethylene pipes can be achieved.

[0009] This invention discloses a terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network. Another objective is to achieve accurate detection and identification of PE pipeline thermofusion joint defects under complex background noise interference by constructing an improved MASK-R-CNN polyethylene pipeline defect recognition model based on CBAM, providing a reliable technical solution for terahertz defect detection in PE pipelines. Based on terahertz time-of-flight tomography (TFT), one-dimensional terahertz time-domain signals are converted into two-dimensional images, and key features containing defect depth information are extracted as model input. A CBAM module is introduced to enhance the channel and spatial representation capabilities of defect features, and a natural exponential form is designed. The loss function optimizes gradient stability; through the synergistic effect of the dual attention mechanism and the loss function, the problem that defect features are easily submerged by noise in complex backgrounds is solved, avoiding the limitations of traditional methods that rely on manual feature design, and improving the robustness and detection accuracy of the model in noisy scenarios.

[0010] This invention employs the following technical solution: a terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network, comprising the following steps:

[0011] Step 1: Automatically acquire detection images using terahertz tomography and divide the images into training, validation, and test sets in a 5:2:3 ratio. Convert the dataset into standard COCO format using Label-Image and LabelMe tools.

[0012] Step 2: Input the tomographic images into the improved MASK-R-CNN network for training;

[0013] Step 3: Introduce the natural index form Loss function substitution The loss function is used to obtain the trained model;

[0014] Step 4: Apply the test set from Step 1 to the trained model and test the model.

[0015] Step 5: Obtain the defect detection results of polyethylene pipes based on the model that has passed the model test.

[0016] As the preferred technical solution above, step 1 specifically includes:

[0017] Step 1.1: Obtain three-dimensional terahertz time-domain spectral data by scanning the sample point by point. The three dimensions are the image length M, width N, and time of flight T.

[0018] Step 1.2: Take out a pixel in space, with time of flight as the horizontal axis and amplitude of the time-domain waveform as the vertical axis, to obtain the terahertz time-domain waveform corresponding to a single pixel of the sample.

[0019] Step 1.3: At a certain moment, acquire all pixels of the sample and map them according to their spatial locations to obtain an image of a certain cross-section of the sample. That is, it is represented as ;

[0020] in, For flight time, and It is the time it takes for terahertz reflections from the upper and lower surfaces of the test sample to reach the detector. "It is an amplitude function, Represents terahertz signals; Image As a result of reflected pulse terahertz tomography;

[0021] Step 1.4: Based on the relationship between sample depth and flight time: To obtain tomographic imaging results at different depths of the pipeline;

[0022] in, Let be the sample depth, c be the speed of light, and n be the sample refractive index.

[0023] As a preferred technical solution to the above technical solutions, the improved MASK-R-CNN network in step 2 includes a residual network module, an attention mechanism module, a feature pyramid network module, a region proposal network module, a region of interest alignment module, and a fully connected layer.

[0024] As the preferred technical solution above, step 2 specifically involves:

[0025] Step 2.1: The residual network module extracts hierarchical features from the input tomographic images at different depths, where low-level features capture fine-grained textures and high-level features encode semantic defect contexts.

[0026] Step 2.2: The attention mechanism module consists of a channel attention mechanism and a spatial attention mechanism. The channel attention mechanism is represented as follows: Spatial attention mechanism is represented as: ;

[0027] in, This represents the features output by the two convolutional layers. and These represent global max pooling and global average pooling, respectively. MLP stands for Multilayer Perceptron. and These are the weights of the MLP, and they share the input. and These represent the features after global average pooling and global max pooling, respectively. The activation function is Sigmoid. ,in, For function variables;

[0028] in, The output features of the channel attention module, Indicates the filter size is The convolution operation; the feature representation of the final attention mechanism module is as follows: ;

[0029] Step 2.3: Integrate the attention mechanism and spatial attention mechanism (dual-channel attention mechanism) from Step 2.2 into each ResNet50 residual block to obtain refined features. This enhances the defect characteristics of polyethylene pipes;

[0030] Features in steps 2.4 and 2.3 By using dual-channel downsampling and upsampling in the multi-scale feature enhancement module, feature fusion from the bottom layer to the top layer is achieved, and a feature pyramid is constructed to handle the scale variation of defects.

[0031] Step 2.5: The region proposal network module utilizes the feature pyramid to generate high-quality proposals by prioritizing defective regions enhanced by the attention mechanism module, thereby reducing false alarms caused by background artifacts.

[0032] Step 2.6: The Region of Interest Alignment module uses bilinear interpolation to precisely align features, preserving spatial details crucial to the boundaries of irregular defects;

[0033] Step 2.7: The two convolutional layers use discriminative features refined by the attention mechanism module and multi-scale fusion to classify defects and regress bounding boxes.

[0034] As the preferred technical solution to the above technical solutions, step 3 specifically includes:

[0035] Step 3.1: The composite loss function integrates the specific task objectives used for region proposal generation, defect classification, and bounding box regression. The total loss is defined as: ,in, Used to control the training of RPN, and Mask-R-CNN network head used for final defect detection;

[0036] Step 3.2 It combines classification loss and regression loss to distinguish between defects and background regions and optimizes anchor boxes. ;

[0037] in, This is a balancing factor, set to 10, used to balance the ratio between classification loss and regression loss. It is an anchor It is the predicted probability of the defect, and These are truth labels; 0 indicates a defect, and 1 indicates background. and These represent the predicted bounding box transformation and the target bounding box transformation, respectively. These represent the predicted x-direction offset, the predicted y-direction offset, the predicted width scaling factor, and the predicted height scaling factor, respectively. and These refer to the number of anchor frames and the number of valid anchor frame positions, respectively. It is a binary cross-entropy loss used to evaluate whether the anchor frame contains defects, and its expression is: ,in It uses the Smooth L1 loss, which optimizes the offset between the anchor point and the true bounding box. Its expression is: , and The first part represents the predicted and target bounding boxes. The anchor of the first Predicted values ​​of the components. The function is defined as ;

[0038] Step 3.3 It consists of two sub-losses used for defect classification and bounding box optimization: ;

[0039] in, This is a multi-class cross-entropy composite loss function used for defect classification, and its expression is: ;in It is the number of defect categories. This refers to the number of anchor frames in the region of interest. It is a defect category Middle Anchor binary index, It is a defect category Middle Anchor Predict the probability; and yes Loss, used to adjust the proposal box to match the actual defect: ,in, and These represent the predicted bounding box offset and the target bounding box offset, respectively, for the region of interest (ROI).

[0040] Step 3.4, Design Improvement Functions are used for optimization The composite loss function may encounter sudden or unstable gradients, and its functional expression is as follows: The gradient function expression is: .

[0041] The terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network disclosed in this invention has the following advantages:

[0042] I. This paper presents an accurate and efficient method for detecting defects in polyethylene pipes, forming a complete detection system from terahertz imaging to deep learning model construction.

[0043] Second, a CBAM module was established, which uses spatial attention mechanism to locate the target region, obtain weights for adjustment, and optimizes the resource allocation between convolutional channels through channel attention mechanism to improve the feature representation capability of the target region and enhance the network's attention to the input data, thereby enhancing the features of polyethylene pipe defect detection.

[0044] III. Improvements The loss function can avoid sudden or unstable gradients that may occur during the optimization process, thereby avoiding instability or convergence difficulties during training.

[0045] Fourth, this invention can effectively overcome the interference of complex background noise, improve the accuracy and reliability of polyethylene pipeline defect detection, and is of great significance for ensuring the safe operation of polyethylene pipelines in urban gas systems and other fields. Attached Figure Description

[0046] Figure 1 This is a flowchart of the process of the present invention.

[0047] Figure 2 This is a sample image of a defective polyethylene pipe.

[0048] Figure 3 This is a waveform diagram of a terahertz signal from a defect in a polyethylene pipe.

[0049] Figure 4 This is a terahertz tomography image.

[0050] Figure 5 This is a diagram of the MASK-R-CNN network framework.

[0051] Figure 6 This is a CBAM module framework diagram.

[0052] Figure 7 This is a diagram of the improved MASK-R-CNN network framework.

[0053] Figure 8 This is a defect identification diagram for polyethylene pipes. Detailed Implementation

[0054] This invention discloses a terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network. The following describes a preferred embodiment (Example 1), with reference to the accompanying drawings. Figures 1 to 8 The specific embodiments of the present invention will be further described below.

[0055] Example 1.

[0056] Preferably, the terahertz polyethylene pipeline defect detection method based on the improved MASK-R-CNN network includes the following steps:

[0057] Step 1: Automatically acquire detection images using terahertz tomography and divide the images into training, validation, and test sets in a 5:2:3 ratio. Convert the dataset into standard COCO format using Label-Image and LabelMe tools.

[0058] Step 2: Input the tomographic images into the improved MASK-R-CNN network for training;

[0059] Step 3: Introduce the natural index form Loss function substitution The loss function is used to obtain the trained model;

[0060] Step 4: Apply the test set from Step 1 to the trained model and test the model.

[0061] Step 5: Obtain the defect detection results of polyethylene pipes based on the model that has passed the model test.

[0062] Step 1 specifically includes:

[0063] Step 1.1: Obtain three-dimensional terahertz time-domain spectral data by scanning the sample point by point. The three dimensions are the image length M, width N, and time of flight T.

[0064] Step 1.2: Take out a pixel in space, with time of flight as the horizontal axis and amplitude of the time-domain waveform as the vertical axis, to obtain the terahertz time-domain waveform corresponding to a single pixel of the sample.

[0065] Step 1.3: At a certain moment, acquire all pixels of the sample and map them according to their spatial locations to obtain an image of a certain cross-section of the sample. That is, it is represented as ;

[0066] in, For flight time, and It is the time it takes for terahertz reflections from the upper and lower surfaces of the test sample to reach the detector. "It is an amplitude function, Represents terahertz signals; Image As a result of reflected pulse terahertz tomography;

[0067] Step 1.4: Based on the relationship between sample depth and flight time: To obtain tomographic imaging results at different depths of the pipeline;

[0068] in, Let be the sample depth, c be the speed of light, and n be the sample refractive index.

[0069] The improved MASK-R-CNN network in step 2 includes a residual network module, an attention mechanism module, a feature pyramid network module (backbone network), a region proposal network module, a region of interest alignment module, and fully connected layers.

[0070] Step 2 is as follows:

[0071] Step 2.1: The residual network module extracts hierarchical features from the input tomographic images at different depths, where low-level features capture fine-grained textures and high-level features encode semantic defect contexts.

[0072] Step 2.2: The attention mechanism module consists of a channel attention mechanism and a spatial attention mechanism. The channel attention mechanism is represented as follows: Spatial attention mechanism is represented as: ;

[0073] in, This represents the features output by the two convolutional layers. and These represent global max pooling and global average pooling, respectively. MLP stands for Multilayer Perceptron. and These are the weights of the MLP, and they share the input. and These represent the features after global average pooling and global max pooling, respectively. The activation function is Sigmoid. ,in, For function variables;

[0074] in, The output features of the channel attention module, Indicates the filter size is The convolution operation; the feature representation of the final attention mechanism module is as follows: ;

[0075] Step 2.3: Integrate the attention mechanism and spatial attention mechanism (dual-channel attention mechanism) from Step 2.2 into each ResNet50 residual block to obtain refined features. This enhances the defect characteristics of polyethylene pipes;

[0076] Features in steps 2.4 and 2.3 By using dual-channel downsampling and upsampling in the multi-scale feature enhancement module, feature fusion from the bottom layer to the top layer is achieved, and a feature pyramid is constructed to handle the scale variation of defects.

[0077] Step 2.5: The region proposal network module utilizes the feature pyramid to generate high-quality proposals by prioritizing defective regions enhanced by the attention mechanism module, thereby reducing false alarms caused by background artifacts.

[0078] Step 2.6: The Region of Interest Alignment module uses bilinear interpolation to precisely align features, preserving spatial details crucial to the boundaries of irregular defects;

[0079] Step 2.7: The two convolutional layers use discriminative features refined by the attention mechanism module and multi-scale fusion to classify defects and regress bounding boxes.

[0080] Step 3 specifically involves:

[0081] Step 3.1: The composite loss function integrates the specific task objectives used for region proposal generation, defect classification, and bounding box regression. The total loss is defined as: ,in, Used to control the training of RPN, and Mask-R-CNN network head used for final defect detection;

[0082] Step 3.2 It combines classification loss and regression loss to distinguish between defects and background regions and optimizes anchor boxes. ;

[0083] in, This is a balancing factor, set to 10, used to balance the ratio between classification loss and regression loss. It is an anchor It is the predicted probability of the defect, and These are truth labels; 0 indicates a defect, and 1 indicates background. and These represent the predicted bounding box transformation and the target bounding box transformation, respectively. This represents the predicted x-direction offset, the predicted y-direction offset, the predicted width scaling factor, and the predicted height scaling factor. and These refer to the number of anchor frames and the number of valid anchor frame positions, respectively. It is a binary cross-entropy loss used to evaluate whether the anchor frame contains defects, and its expression is: ,in It uses the Smooth L1 loss, which optimizes the offset between the anchor point and the true bounding box. Its expression is: , and The first part represents the predicted and target bounding boxes. The anchor of the first The predicted value of the component. The function is defined as ;

[0084] Step 3.3 It consists of two sub-losses used for defect classification and bounding box optimization: ;

[0085] in, This is a multi-class cross-entropy composite loss function used for defect classification, and its expression is: ;in It is the number of defect categories. This refers to the number of anchor frames in the region of interest. It is a defect category Middle Anchor binary index, It is a defect category Middle Anchor Predicting probability; binary index, It is a predicted probability; and yes Loss, used to adjust the proposal box to match the actual defect: ,in, and These represent the predicted bounding box offset and the target bounding box offset, respectively, for the region of interest (ROI).

[0086] Step 3.4, Design Improvement Functions are used for optimization The composite loss function may encounter sudden or unstable gradients, and its functional expression is as follows: The gradient function expression is: .

[0087] The following describes the working principle of the terahertz polyethylene pipeline defect detection method based on the improved MASK-R-CNN network disclosed in this embodiment.

[0088] Specifically, step 1: Based on time-of-flight tomography, the detection images are automatically acquired using terahertz tomography and divided into training, validation, and test sets in a 5:2:3 ratio. The dataset is then converted to standard COCO format using Label-Image and LabelMe tools. This includes:

[0089] By scanning the sample point by point, the sample, such as Figure 2 As shown, the obtained three-dimensional terahertz time-domain spectral data and the acquired experimental signals are as follows. Figure 3 As shown, the three dimensions are the image length M, width N, and time-of-flight T. By extracting a pixel in space and plotting the time-of-flight waveform on the horizontal axis and the amplitude of the time-domain waveform on the vertical axis, the terahertz time-domain waveform corresponding to a single pixel of the sample can be obtained. By acquiring all pixels of the sample at a certain moment and mapping them according to their spatial locations, a cross-section of the sample can be obtained. The image, that is, represented as ,in For flight time, and It is the time it takes for terahertz reflections from the upper and lower surfaces of the test sample to reach the detector. "It is an amplitude function, This image represents a terahertz signal and is the result of reflected pulse terahertz tomography. Based on the relationship between sample depth and time-of-flight: ,in Let be the sample depth, c be the speed of light, and n be the sample refractive index. Tomographic imaging results were obtained at different depths of the pipe. Some of the detected images are shown below. Figure 4 As shown, the images were divided into training, validation, and test sets in a 5:2:3 ratio, and the dataset was converted to the standard COCO format using Label-Image and LabelMe tools.

[0090] Specifically, step 2: Input the tomographic images into the improved MASK-R-CNN network for training; this includes:

[0091] like Figure 5 As shown, the improved MASK-R-CNN network includes a backbone network consisting of a Residual Network (ResNet), a Concentration Mechanism (CBAM), and a Feature Pyramid Network (FPN), a Region Proposal Network (RPN), and a Region of Interest Alignment (ROI Align) module, as well as fully connected layers.

[0092] The ResNet50 backbone network (residual network module) extracts hierarchical features from input tomographic images at different depths, where low-level features capture fine-grained textures and high-level features encode semantic defect context.

[0093] The CBAM consists of a channel attention mechanism and a spatial attention mechanism. The channel attention mechanism is represented as follows: ,in, This represents the features output by the two convolutional layers. and These represent global max pooling and global average pooling, respectively. MLP stands for Multilayer Perceptron. and These are the weights of the MLP, and they share the input. and These represent the features after global average pooling and global max pooling, respectively. The activation function is Sigmoid. ,in, Let the variable be a function; the spatial attention mechanism is represented as: ,in, The output features of the channel attention module, Indicates the filter size is The convolution operation; the final feature representation after CBAM is as follows: The CBAM module structure diagram is as follows: Figure 6 As shown;

[0094] Subsequently, a dual-channel attention mechanism was integrated into each ResNet50 residual block to obtain refined features. This enhances the defect characteristics of polyethylene pipes;

[0095] Next, the features refined by the dual-channel attention mechanism By using dual-channel downsampling and upsampling in the multi-scale feature enhancement module, feature fusion from the bottom layer to the top layer is achieved, and a feature pyramid is constructed to handle the scale variation of defects.

[0096] Then, RPN uses feature pyramids to process CBAM-enhanced defect regions to generate high-quality proposals, reducing false alarms caused by background artifacts; and then uses bilinear interpolation to precisely align features through ROI Align, preserving spatial details that are crucial to the boundaries of irregular defects.

[0097] Finally, the two convolutional layers, leveraging discriminative features refined by CBAM and multi-scale fusion, classify defects and regress bounding boxes. The structure diagram of the improved MASK-R-CNN network is shown below. Figure 7 As shown.

[0098] Specifically, step 3: Introduce the natural index form loss function to replace traditional Loss functions are used to overcome gradient stability issues under complex background noise; specifically, they include:

[0099] The proposed loss function integrates task-specific objectives for region proposal generation, defect classification, and bounding box regression, and the total loss is defined as: ,in, Used to control the training of RPN, and Mask-R-CNN network head used for final defect detection;

[0100] The aforementioned It combines classification loss and regression loss to distinguish between defects and background regions and optimizes anchor boxes. ,in, This is a balancing factor, set to 10, used to balance the ratio between classification loss and regression loss. It is an anchor It is the predicted probability of the defect, and These are truth labels; 0 indicates a defect, and 1 indicates background. and These represent the predicted bounding box transformation and the target bounding box transformation, respectively. This represents the predicted x-direction offset, the predicted y-direction offset, the predicted width scaling factor, and the predicted height scaling factor. and These refer to the number of anchor frames and the number of valid anchor frame positions, respectively. It is a binary cross-entropy loss used to evaluate whether the anchor frame contains defects, and its expression is: ,in It uses the Smooth L1 loss, which optimizes the offset between the anchor point and the true bounding box. Its expression is: , and The first part represents the predicted and target bounding boxes. The anchor of the first The predicted value of the component. The function is defined as ;

[0101] The aforementioned It consists of two sub-losses used for defect classification and bounding box optimization: ,in, This is the multi-class cross-entropy loss function used for defect classification, and its expression is: ,in It is the number of defect categories. This refers to the number of anchor frames in the region of interest. It is a defect category Middle Anchor binary index, It is a defect category Middle Anchor Predict the probability; and yes Loss, used to adjust the proposal box to match the actual defect: ,in, and These represent the predicted bounding box offset and the target bounding box offset, respectively, for the region of interest (ROI).

[0102] Design improvements Functions are used for optimization The loss function may experience sudden or unstable gradients, and its functional expression is as follows: The gradient function expression is: .

[0103] Specifically, step 4: Apply the test set from step 1 to the trained model to perform model testing. Here, testing means using the trained model to detect samples, such as... Figure 8 As shown, the test set performs well in the network with an accuracy of 93.257%.

[0104] This invention constructs an improved Mask-R-CNN model based on CBAM, and designs a natural exponential form in the model. The loss function is optimized for gradient stability under complex noise. The defect feature response intensity is used as the fitness index. CBAM is used to dynamically calibrate the channel and spatial features of terahertz tomography images. Then, a multi-scale feature pyramid network is used to fuse features from different levels to train an improved Mask-R-CNN model, ultimately resulting in a deep learning model capable of accurately detecting defects in PE pipe thermofusion joints. This invention overcomes the problems of insufficient suppression of complex background noise and inefficiency of manual feature extraction in traditional detection methods. It solves the problem of insufficient feature diversity in PE pipe defect samples due to complex geometric structures, reduces the model's dependence on high-cost, high-complexity labeled data, and improves the accuracy of defect localization and classification. It has significant engineering significance and application value for online real-time detection of safe PE pipe operation.

[0105] The following describes the overall concept of the terahertz polyethylene pipeline defect detection method based on the improved MASK-R-CNN network disclosed in this embodiment.

[0106] Specifically, noise interference in terahertz defect detection of polyethylene pipes easily leads to human misjudgment. This invention addresses this by combining the improved MASK-R-CNN defect recognition model based on CBAM, which integrates channel attention and spatial attention mechanisms in a cascaded manner and embeds them into the MASK-R-CNN network. This suppresses redundant channels and enhances discriminative channels, highlighting spatial regions containing defects. The network focuses on irregular edges or local deformations while ignoring uniform regions. Furthermore, to prevent instability or convergence difficulties during network training, an improved... The function is used to replace the original loss function, allowing the network to flexibly adjust the gradient magnitude to adapt to different situations, thereby achieving more efficient optimization.

[0107] It is worth mentioning that the specific equipment and other technical features involved in the point-to-point scanning of samples in this patent application should be regarded as prior art. The specific structure, working principle, and possible control methods and spatial arrangement of these technical features can be conventionally selected in the field and should not be regarded as the inventive point of this patent. This patent will not be further elaborated in detail.

[0108] For those skilled in the art, modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this invention should be included within the protection scope of this invention.

Claims

1. A method for detecting defects in terahertz polyethylene pipes based on an improved MASK-R-CNN network, characterized in that, Includes the following steps: Step 1: Automatically acquire detection images using terahertz tomography and divide the images into training, validation, and test sets in a 5:2:3 ratio. Convert the dataset into standard COCO format using Label-Image and LabelMe tools. Step 2: Input the tomographic image into the improved MASK-R-CNN network for training; The improved MASK-R-CNN network in Step 2 includes a residual network module, an attention mechanism module, a feature pyramid network module, a region proposal network module, and a region of interest alignment module, as well as fully connected layers; The attention mechanism module consists of channel attention mechanism and spatial attention mechanism; The attention mechanism and spatial attention mechanism are integrated into each residual block; Step 3: Introduce the natural index form Loss function substitution The loss function is used to obtain the trained model; step 3 specifically involves: Step 3.1: The composite loss function integrates the specific task objectives used for region proposal generation, defect classification, and bounding box regression. The total loss is defined as: ,in, Used to control the training of RPN, and Mask-R-CNN network head used for final defect detection; Step 3.2 It combines classification loss and regression loss to distinguish between defects and background regions and optimizes anchor boxes. ; in, This is a balancing factor, set to 10, used to balance the ratio between classification loss and regression loss. It is an anchor It is the predicted probability of the defect, and These are truth labels; 0 indicates a defect, and 1 indicates background. and These represent the predicted bounding box transformation and the target bounding box transformation, respectively. This represents the predicted x-direction offset, the predicted y-direction offset, the predicted width scaling factor, and the predicted height scaling factor. and These refer to the number of anchor frames and the number of valid anchor frame positions, respectively. It is a binary cross-entropy loss used to evaluate whether the anchor frame contains defects, and its expression is: ,in It uses the Smooth L1 loss, which optimizes the offset between the anchor point and the true bounding box. Its expression is: , and The first part represents the predicted and target bounding boxes. The anchor of the first The predicted value of the component. The function is defined as ; Step 3.3 It consists of two sub-losses used for defect classification and bounding box optimization: ; in, This is a multi-class cross-entropy composite loss function used for defect classification, and its expression is: ;in It is the number of defect categories. This refers to the number of anchor frames in the region of interest. It is a defect category Middle Anchor binary index, It is a defect category Middle Anchor Predict the probability; and yes Loss, used to adjust the proposal box to match the actual defect: ,in, and These represent the predicted bounding box offset and the target bounding box offset of the region of interest (ROI), respectively. Step 3.4, Design Improvement Functions are used for optimization The composite loss function may encounter sudden or unstable gradients, and its functional expression is as follows: The gradient function expression is: ; Step 4: Apply the test set from Step 1 to the trained model and test the model. Step 5: Obtain the defect detection results of polyethylene pipes based on the model that has passed the model test.

2. The terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network according to claim 1, characterized in that, Step 1 is as follows: Step 1.1: Obtain three-dimensional terahertz time-domain spectral data by scanning the sample point by point. The three dimensions are the image length M, width N, and time of flight T. Step 1.2: Take out a pixel in space, with time of flight as the horizontal axis and amplitude of the time-domain waveform as the vertical axis, to obtain the terahertz time-domain waveform corresponding to a single pixel of the sample. Step 1.3: At a certain moment, acquire all pixels of the sample and map them according to their spatial locations to obtain an image of a certain cross-section of the sample. That is, it is represented as ; in, For flight time, and It is the time it takes for terahertz reflections from the upper and lower surfaces of the test sample to reach the detector. "It is an amplitude function, Represents terahertz signals; Image As a result of reflected pulse terahertz tomography; Step 1.4: Based on the relationship between sample depth and flight time: To obtain tomographic imaging results at different depths of the pipeline; in, Let be the sample depth, c be the speed of light, and n be the sample refractive index.

3. The terahertz polyethylene pipeline defect detection method based on an improved MASK-R-CNN network according to claim 2, characterized in that, Step 2 is as follows: Step 2.1: The residual network module extracts hierarchical features from the input tomographic images at different depths, where low-level features capture fine-grained textures and high-level features encode semantic defect contexts. Step 2.2, the channel attention mechanism is represented as follows: Spatial attention mechanism is represented as: ; in, This represents the features output by the two convolutional layers. and These represent global max pooling and global average pooling, respectively. MLP stands for Multilayer Perceptron. and These are the weights of the MLP, and they share the input. and These represent the features after global average pooling and global max pooling, respectively. The activation function is Sigmoid. ,in, For function variables; in, The output features of the channel attention module, Indicates the filter size is The convolution operation; the feature representation of the final attention mechanism module is as follows: ; Step 2.3: Integrate the attention mechanism and spatial attention mechanism from Step 2.2 into each ResNet50 residual block to obtain refined features. This enhances the defect characteristics of polyethylene pipes; Features in steps 2.4 and 2.3 By using dual-channel downsampling and upsampling in the multi-scale feature enhancement module, feature fusion from the bottom layer to the top layer is achieved, and a feature pyramid is constructed to handle the scale variation of defects. Step 2.5: The region proposal network module utilizes the feature pyramid to generate high-quality proposals by prioritizing defective regions enhanced by the attention mechanism module, thereby reducing false alarms caused by background artifacts. Step 2.6: The Region of Interest Alignment module uses bilinear interpolation to precisely align features, preserving spatial details crucial to the boundaries of irregular defects; Step 2.7: The two convolutional layers use discriminative features refined by the attention mechanism module and multi-scale fusion to classify defects and regress bounding boxes.

Citation Information

Patent Citations

  • Terahertz image defect detection method, device and system and storage medium

    CN110084812A