Pipeline magnetic flux leakage defect detection method based on anchor-free frame
By proposing a pipeline magnetic flux leakage defect detection method based on an anchorless frame, and using the PP-LCNet model and ARFAFF module for feature extraction and fusion, combined with the detection head network model, the problem of difficulty in balancing detection accuracy and speed in existing technologies is solved, achieving high-precision and high-speed detection results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- LIAONING UNIVERSITY OF PETROLEUM AND CHEMICAL TECHNOLOGY
- Filing Date
- 2022-08-09
- Publication Date
- 2026-05-29
Smart Images

Figure CN115311234B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pipeline magnetic flux leakage detection, and in particular to a method for detecting pipeline magnetic flux leakage defects based on a frameless anchor. Background Technology
[0002] Pipelines have long been the primary carriers of energy resources such as oil and natural gas due to their advantages of large capacity and low cost. However, prolonged operation can easily lead to damage from corrosion, human-caused disruption, and other factors. Pipeline leaks can endanger the economy, the environment, and the safety of people's lives and property. Therefore, regular pipeline inspection is crucial, and magnetic flux leakage (MFL) testing, unaffected by environmental factors and media, is currently the most commonly used pipeline inspection method.
[0003] In recent years, many scholars have applied target detection algorithms in the field of magnetic flux leakage defect detection and achieved remarkable results. Two-stage target detection algorithms, also known as region proposal-based target detection algorithms, generate region proposals in the first stage and classify and regress the content within the regions of interest in the second stage. However, while this approach achieves high detection accuracy, it reduces detection speed. One-stage target detection algorithms, also known as regression-based target detection algorithms, do not directly generate regions of interest but treat the target detection task as a regression task of the entire image. While this type of algorithm improves detection speed, it reduces detection accuracy. To enable the practical application of deep learning algorithms in the field of magnetic flux leakage detection, there is an urgent need to propose a method for detecting pipeline magnetic flux leakage images that can simultaneously achieve low latency and high accuracy. Summary of the Invention
[0004] In view of the above-mentioned shortcomings and deficiencies of the prior art, the present invention provides a pipeline magnetic flux leakage defect detection method based on an anchor frame-free method. By acquiring magnetic flux leakage defect images, artificial intelligence methods are used to detect the defects, thereby realizing the detection of pipeline defects.
[0005] To achieve the above objectives, the main technical solutions adopted by the present invention include:
[0006] This invention provides a method for detecting magnetic flux leakage defects in pipelines without anchor frames, comprising the following steps:
[0007] S1, acquire a pipeline magnetic flux leakage defect image with a size of 512×512;
[0008] S2, the magnetic flux leakage defect image obtained in S1 is fed into the PP-LCNet model for feature extraction, resulting in a first feature map of 1280×16×16, and then the first feature map is transformed into a second feature map of 1280×128×128 through three layers of transposed convolution.
[0009] S3, the second feature map obtained in S2 is fed into the detection head network model for detection.
[0010] Furthermore, the PP-LCNet model in S2 is a lightweight network model, and the ARFAFF module is introduced into the PP-LCNet model.
[0011] Furthermore, the PP-LCNet model includes one convolutional layer, thirteen depthwise separable convolutional layers, and three transposed convolutional layers. An attention module SimAM is placed after the last two depthwise separable convolutional layers, and an activation function H-swish is placed after the last SimAM layer.
[0012] Furthermore, the ARFAFF module is an adaptive receptive field and attention feature fusion method, consisting of an RFB module and a SimAM module.
[0013] Furthermore, the RFB module is a network model that simulates human vision. It consists of three branches connected in parallel. Each branch is composed of a convolutional layer and a dilated convolutional layer connected in series. The convolutional kernels of the three convolutional layers are 1, 3, and 5 from smallest to largest. The convolutional kernels of the three convolutional layers represent different receptive fields of a person. The dilation rates of the three dilated convolutional layers are 1, 3, and 5, respectively. The dilation rate of the dilated convolutional layers represents the eccentricity of the human retina.
[0014] Furthermore, the SimAM module is an attention mechanism based on 3D attention weights, and the method by which the attention mechanism generates attention weights is by defining an energy function.
[0015] Furthermore, the detection head network model in S3 includes three parts: calculation of the target center point, prediction of the length and width of the detection box, and prediction of the offset center point.
[0016] The beneficial effects of this invention are: This invention provides a method for detecting magnetic flux leakage defects in pipelines based on a frameless anchor, which can ensure both high detection accuracy and high detection speed, meeting the needs of practical applications. Attached Figure Description
[0017] Figure 1 This is a flowchart of a pipe magnetic flux leakage defect detection method based on an anchorless frame according to the present invention.
[0018] Figure 2 An ARFAFF structure diagram provided by the present invention;
[0019] Figure 3 The diagram shows the structure of a pipe magnetic flux leakage defect detection method based on an anchorless frame provided by the present invention.
[0020] Figure 4 This invention provides a magnetic flux leakage defect detection result;
[0021] Figure 5 This invention provides a parameter table for a PP-LCNet network model. Detailed Implementation
[0022] To better explain and facilitate understanding of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0023] Example 1:
[0024] like Figure 1 As shown, this embodiment provides a method for detecting magnetic flux leakage defects in pipelines based on a frameless anchor. The method includes the following steps:
[0025] S1. Using Matlab, the magnetic flux leakage data of an oil company is converted into a magnetic flux leakage image. A magnetic flux leakage defect image is selected from the magnetic flux leakage image, and the size of the selected magnetic flux leakage defect image is set to 512×512.
[0026] In step S2, the 512×512 magnetic flux leakage defect image from step S1 is fed into the PP-LCNet model for feature extraction, resulting in a 1280×16×16 first feature map. This first feature map is then transformed into a 1280×128×128 second feature map through three layers of transposed convolution. An adaptive receptive field and attention feature fusion method, ARFAFF, is introduced into the PP-LCNet model to obtain more location information of the target and improve detection accuracy.
[0027] S3, the second feature map obtained in S2 is fed into the detection head network model for detection.
[0028] like Figure 5 As shown, the PP-LCNet model provided in this embodiment is a lightweight network model, which includes one convolutional layer, thirteen depthwise separable convolutional layers, and three transposed convolutional layers. An attention module (SimAM) is placed after the last two depthwise separable convolutional layers, and an activation function (H-swish) is placed after the last SimAM layer.
[0029] The 512×512×3 magnetic flux leakage image selected in step S1 is input into the PP-LCNet model. After passing through the first convolutional layer (with a kernel of 3 and a stride of 2), 32 256×256 feature maps are output.
[0030] The 32 256×256 feature maps are processed through two depthwise separable convolutions with a kernel size of 3 and a stride of 2 in the second layer, resulting in 128 128×128 feature maps.
[0031] Then, the 128 128×128 feature maps are passed through four layers of depthwise separable convolutions with the same parameters to output 512 32×32 feature maps.
[0032] The 512 32×32 feature maps are extracted by five layers of deep separable convolution with a kernel of 5 and a stride of 1. Then, they are extracted by two layers of deep separable convolution with a kernel of 5 and a stride of 2 in the first layer. The result is 1280 16×16 feature maps, which are then output to obtain the first feature map of 1280×16×16.
[0033] Placing SimAM at the end of the depthwise separable convolutional layer effectively improves the accuracy of the PP-LCNet model. Since mixing convolutional kernels of different sizes within the same layer reduces inference speed, the PP-LCNet model attempts to use only one type of convolutional kernel in the same layer, employing a 5×5 kernel at the end of the depthwise separable convolutional layer. This allows the PP-LCNet model to improve inference speed while maintaining high accuracy.
[0034] This invention selects the H-Swish activation function, which significantly improves performance without changing the inference speed. Its expression is:
[0035]
[0036] Finally, a three-layer transposed convolution is used to enlarge the first feature map, resulting in a high-resolution second feature map of 1280×128×128, which helps improve the accuracy and speed of detection.
[0037] like Figure 2 As shown, an embodiment of the present invention provides an ARFAFF module, which mainly consists of an RFB and a SimAM.
[0038] RFB can be used to extract high-level features. A 1×1 convolution is added to the two branches with kernels of 3 and 5 mainly to reduce the amount of computation. After the features of the three branches are fused, a 1×1 convolution is used to change the number of channels so that the number of channels of the fused feature is the same as the number of channels of the original feature, and then added to the original feature to form a residual block.
[0039] The structure of RFB-s mainly adds a branch to RFB, and replaces 3×3 with 1×3 and 3×1 convolution kernels, and replaces 5×5 convolution kernels with two 3×3 convolution kernels. This module is mainly used to extract shallow features.
[0040] SimAM is an attention mechanism based on 3D attention weights, applicable to any convolutional neural network. The method of generating attention weights is a crucial factor in attention mechanisms. Previous work primarily involved introducing artificially designed subnetworks to generate attention weights, requiring extensive engineering experiments. However, SimAM argues that the design of attention mechanisms should be guided by a principle in neuroscience; therefore, its method for generating attention weights is to define an energy function. In neuroscience, activating neurons often inhibits surrounding neurons, a phenomenon known as spatial inhibition. Neurons exhibiting spatial inhibition should be assigned greater importance. The method for identifying such neurons is to measure the linear separability between neurons. Therefore, the expression for the energy function is as follows:
[0041]
[0042] It is t and x i A linear transformation, where t and x i Input features The target neuron and other neurons in the single channel. This refers to the overall neurons in this channel. It is an index in the spatial dimension. , These represent the weights and biases of a specific neuron's transformation. To simplify... and Use binary tags (i.e.) and Add a regularizer. The final energy function is defined as: (2)
[0043] in, This represents the number of energy functions per single channel. , Let M be the height and width of the image, respectively. Theoretically, each channel has M energy functions, where... and The following analysis is provided:
[0044] (3)
[0045] (4)
[0046] in, Let represent the mean and variance of the neurons in this channel excluding t, respectively. Therefore, the expression for the minimum energy is as follows:
[0047] (5)
[0048] in, and , , are the mean and variance of all neurons within the channel, respectively. The above formula implies that the lower the energy, the greater the difference between neuron t and surrounding neurons, and the higher its importance. Therefore, the importance of a neuron can be expressed as:
[0049] (6)
[0050] Based on the definition of attention, it can be written as an expression:
[0051] (7)
[0052] To improve the detection accuracy of the model, this invention introduces an adaptive receptive field and attention feature fusion method, ARFAFF module. In the prior art, feature fusion usually involves directly performing a concat operation on the features, but the inconsistency between features at different scales makes the fusion effect unsatisfactory. Therefore, this invention introduces SimAm and RFB to realize an adaptive feature fusion method.
[0053] Because SimAm does not require additional parameters to derive 3D attention weights from feature maps, and RFB is a lightweight network, ARFAFF not only solves the inconsistencies between features at different scales but also avoids introducing excessive computation. For features at three different levels... Where C is the number of channels, H and W are the height and width, respectively. The interpolate function provided by PyTorch is used to convert them into features of the same size. The shallow features are converted to RFB-s, and the medium and high-level features are converted to 1280 channels using the RFB module. Then the weight parameters are trained. The number of channels of the three features is converted to 8 using a 1×1 convolution, and a concat operation is performed to make the number of channels of the fused features 24. After the 1×1 convolution operation, the number of channels is converted to 3. The fused features are then passed to formula (6), and the expression is as follows:
[0054] (8)
[0055] Obtain their shared weights, and then use the Softmax function to calculate the weight parameters. ,and Its expression is:
[0056] (9)
[0057] Finally, the three features are multiplied by their respective weight parameters and summed to obtain the final feature Y, whose expression is shown below:
[0058] (10)
[0059] LV3 selects the feature map after the first convolutional layer, with an image size of 64×256×256. First, the original image is downsampled using PyTorch's `interpolate` function with `bicubic` mode, downsampling the image to 64×16×16. Finally, the BRF-s module converts the number of channels to 1280, resulting in an output feature size of 1280×16×16.
[0060] LV2 selects a mid-layer feature with a size of 256×64×64, and downsamples the feature map to 1280×16×16 by passing through an RFB module with a stride of 2 and a max pooling layer.
[0061] LV1 selects the high-level feature, with dimensions of 1280×16×16.
[0062] like Figure 3 As shown, this embodiment provides a method for detecting magnetic flux leakage defects in pipelines based on an anchorless frame. First, the magnetic flux leakage image is feature extracted, and then it is fed into the detection head network model for detection.
[0063] The detection head network model is mainly divided into three parts: calculating the target center point, predicting the length and width of the detection box, and predicting the offset center point. After downsampling the original image, a 128×128 heatmap is generated. First, the coordinates of the actual box center point are mapped onto the heatmap. Then, a regression task is performed using two depthwise separable convolutional layers with kernels of 5, resulting in a feature map of size [W, H, C], where W and H are both 128, and C represents the predicted category 3. Next, the width and height are predicted for the detected category, again using two depthwise separable convolutional layers with kernels of 5, resulting in a feature map of size [W, H, 2], where 2 represents the length and width of the predicted box. Finally, the target offset center point is predicted, first using two convolutional layers to obtain a feature map of size [W, H, 2], where 2 represents the coordinates of the predicted center point. Because the pixel values of points in the feature map are highly similar to those of surrounding points, the network struggles to develop a strong response to the center point during learning. Therefore, a circle with center r can be drawn at the center point of the actual bounding box; any point within this range can serve as a center point. A Gaussian circle is introduced into the feature map, and its radius r is calculated. Since the value at the center point of a Gaussian distribution is 1, the value at each Gaussian distribution point gradually decreases as the radius r increases. The setting of the loss function is equally important in the head detection network model, as it improves the network's ability to locate targets.
[0064] The loss function consists of three parts, namely the center point loss function of the heatmap. Target center point offset loss function Target width and height loss function The overall loss function is:
[0065] (11)
[0066] in, .
[0067] The loss function for the center point of the heatmap is:
[0068] (12)
[0069] This function is a modification of Focal loss, and the function contains... , The hyperparameters of Focal loss are used to balance the difficulty of samples. For the real key points, To predict key points, N is the number of key points.
[0070] The target center point offset loss function is:
[0071] (13)
[0072] in, This is the offset value predicted by the network. These are the coordinates of the image center point. The scaling factor is 4. These are the integer coordinates of the approximate center point of the scaled image, where N is the number of keypoints.
[0073] The target's aspect ratio loss function is then used directly. The expression is:
[0074] (14)
[0075] in, Indicates the actual size of the target. This represents the predicted size, where N is the number of keypoints.
[0076] like Figure 4 The image shown is a graph of the magnetic flux leakage defect detection results obtained using this algorithm.
[0077] By adopting the above method, the present invention has the following advantages over the prior art: the present invention uses a target detection algorithm based on an anchorless frame to detect magnetic flux leakage defects. Compared with other target detection algorithms, this algorithm can shorten the detection time while maintaining high accuracy. After detection using actual magnetic flux leakage data, it can meet the actual industrial needs.
[0078] The above are preferred embodiments of the present invention and do not limit the present invention. For those skilled in the art, modifications can be made without departing from the technical scope of the present invention, and these modifications are also within the protection scope of the present invention.
Claims
1. A method for detecting magnetic flux leakage defects in pipelines based on frameless anchors, characterized in that: Includes the following steps: S1, acquire a pipeline magnetic flux leakage defect image with a size of 512×512; S2, the magnetic flux leakage defect image obtained in S1 is fed into the PP-LCNet model for feature extraction, resulting in a first feature map of 1280×16×16, and then the first feature map is transformed into a second feature map of 1280×128×128 through three layers of transposed convolution. S3, the second feature map obtained in S2 is fed into the detection head network model for detection; The PP-LCNet model in S2 is a lightweight network model, and the ARFAFF module is introduced into the PP-LCNet model; The PP-LCNet model includes one convolutional layer, thirteen depthwise separable convolutional layers, and three transposed convolutional layers. An attention module SimAM is placed after the last two depthwise separable convolutional layers, and an activation function H-swish is placed after the last SimAM layer. The ARFAFF module employs an adaptive receptive field and attention feature fusion method, and consists of an RFB module and a SimAM module. The RFB module is a network model that simulates human vision. It consists of three branches connected in parallel. Each branch is composed of a convolutional layer and a dilated convolutional layer connected in series. The convolutional kernels of the three convolutional layers are 1, 3, and 5 from small to large. The convolutional kernels of the three convolutional layers represent different receptive fields of a human. The dilation rates of the three dilated convolutional layers are 1, 3, and 5, respectively. The dilation rate of the dilated convolutional layers represents the eccentricity of the human retina. The detection head network model in S3 consists of three parts: the calculation of the target center point, the prediction of the length and width of the detection box, and the prediction of the offset center point. First, after downsampling the original image, a heatmap of size 128×128 is generated. The coordinates of the center point of the actual bounding box are mapped onto the heatmap. Then, a regression task is performed through two depthwise separable convolutional layers with a kernel of 5 to obtain a feature map with size [W,H,C], where W is 128, H is 128, and C represents the predicted category as 3. Then, the width and height are predicted for the detected category. Two depthwise separable convolutional layers with a kernel of 5 are used to obtain a feature map with a size of [W,H,2], where 2 represents the length and width of the predicted box. Finally, the target offset center point is predicted. First, a feature map with size [W,H,2] is obtained using two convolutional layers, where 2 is the coordinate of the predicted center point.
2. The method for detecting magnetic flux leakage defects in pipelines based on a frameless anchor system according to claim 1, characterized in that, The SimAM module employs an attention mechanism based on 3D attention weights, which generates attention weights by defining an energy function.