Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 7, No. 3, 2023 34 Research on Geometric Parameter Prediction Algorithm for Oil and Gas Pipeline Defects Yijun Liu, Wei Wu, Xiaolin Ren, Le Qin, Yukun Wang School of Mechanical Engineering, Xi'an Shiyou University, Shaanxi Xi’an 710065, China Abstract: Aiming at the problem of insufficient feature extraction of magnetic leakage signals by traditional neural networks, this paper proposes an attention depth convolutional neural network model (ECA-VGG16), which adds an attention mechanism combined with convolutional neural network on the basis of deep convolutional neural network VGG16, so that the neural network can focus on the key information of the input data, further improve the ability of the grid to extract image data features, and realize the accurate expression of defect features. 1. Introduction Oil and gas is a very important national energy, pipelines in oil and gas transportation has the advantages of long transportation distance, high efficiency, low cost and safety and reliability, and transportation pipelines are often underground, after a period of use, the pipeline will appear deformation and defects, easy to cause leakage accidents[1]. In response to these problems, the pipe must be inspected and the specific size of the defect must be predicted. At present, the detection of oil and gas pipeline defects mainly adopts magnetic leakage detection technology. The identification of pipeline defect size mainly relies on manual interpretation, because the staff diagnoses the defect by observing the collected pipeline leakage signal. The method of manual interpretation has certain limitations, and the subjective consciousness is too strong[2]. With the deepening of the research of pipeline magnetic leakage detection technology, image recognition technology based on deep learning has gradually matured in the field of oil and gas pipeline defect recognition. In this paper, a recursive graph method is proposed to convert the one-dimensional magnetic leakage signal into a two-dimensional image, and then use the Laplace pyramid to regression prediction of the image to improve the prediction accuracy of pipeline defect size. 2. Finite Element Analysis of Magnetic Flux Leakage Detection Technology for Pipeline Defects 2.1. Formation of leakage magnetic field for pipe defects The pipeline defect flux leakage detection device is composed of an excitation source, a pipeline to be measured and a sensor, and its working principle is shown in Figure 1. The specific detection process is: the excitation source first locally magnetizes the pipe wall to a saturated state[3]. If there is no defect on the surface of the pipe to be measured, the magnetic induction lines in the pipe are confined inside the pipe wall, as shown in Figure 1 (a). If the test pipeline has a defect, the magnetic permeability of the air at the defect is smaller than that of the pipeline, and the magnetic induction line at the defect will be refracted upwards at the defect, and then form the leakage magnetic field of the defect, as shown in Figure 1 (b). (a) is free of defects (b) defective Figure 1. Working principle of pipeline defect magnetic leakage detector 2.2. Establishment of the ANSYS Maxwell finite element model of the leakage magnetic field of pipeline defects The finite element model of ANSYS Maxwell constructs magnetic flux leakage detection for pipeline defects, as shown in Figure 2, and the designed model consists of iron cores, energized coils, defective pipes, etc. ANSYS Maxwell was used to build a 3D pipeline defect leakage detection model to capture the axial and radial components of the flux leakage signal. Figure 2. ANSYS model diagram of magnetic leakage detection for pipeline defects According to the design of the magnetic flux leakage simulation model, the magnetic flux leakage signal can be divided into two types: radial component and axial component. As shown in Figure 3, the radial magnetic leakage component and axial magnetic leakage component with a depth of 3mm, a length of 4mm and a width of 1~9mm are depicted. It can be seen from the figure that the radial leakage curve has a distinct peak signal and a distinct valley signal[4]. The axial flux leakage curve has two distinct peak signals and 35 two valley signals, and a local valley signal between the two peaks. It can be seen from the figure that when the depth and length of the defect remain unchanged, the larger the width of the defect, the larger the spacing between positive and negative extremums, and the larger the peak spacing and valley spacing. (a) Radial component of defect width change (b) Axial component of defect width change Figure 3. Field leakage curve of defect width change As shown in Figure 4, the radial leakage component and axial leakage component with a depth of 4mm, a width of 4mm, and a depth of 1~9mm are depicted. It can be seen from the figure that when the length and width of the defect remain unchanged, the deeper the defect depth, the larger the signal peak. (a) Radial component of defect depth change (b) Axial component of defect depth change Figure 4. Field leakage curve of defect depth change 2.3. ECA-VGG16 neural network structure research VGG16 neural network structure The deep learning network model designed for intelligent diagnosis of pipeline magnetic flux leakage detection defects is based on VGG16 and composed of Laplace pyramid[5]. The overall structure of the improved VGG16 is shown in Figure 5. 7*7*512 1*1*4096 1*1*1000 14*14*512 28*28*512 56*56*256 112*112*128 224*224*64224*224*3224*224*3 Figure 5. Overall structure diagram of VGG16 VGG16 is a convolutional neural network model proposed by Simonyan and Zisserman in the Visual Geometry Group group, which is exclusive to the convolutional layer in the VGG16 network13 layers, the remaining 3 layers are fully connected layers, the model according to the convolution kernel size and the number of convolutional layers, VGG can be divided into 6 seed models, respectivelyA, A-LRN, B, C, D, E, the models we often see and use are basicallyD and E models. The image with the original input size of the network is 2 24*224 first through two times of 64 convolution kernels of the same size for convolution operation, and one pooling operation. The resulting feature map is 1/2 of the original map; After two convolution operations of 1 28 sizes and one pooling operation, the feature map obtained is 1/4 of the original figure; After three times of 256 convolution operations of the same size, and one pooling operation, the obtained feature map is 1/8 of the original; After three more 512 convolution operations of the same size and one pooling 36 operation, the feature map obtained is 1/32 of the original; Finally, after three fully connected layer operations, the obtained results are predicted by the Soft-Max prediction layer[6]. The block diagram is shown in Figure 6. Figure 6. Block diagram of VGG16 system 2.3.1. Convolutional layers The convolutional layer of VGG16 is the core part of the network and is responsible for extracting the features of the input image. VGG16 has a total of 13 convolutional layers, each of which uses a 3x3 convolution kernel for feature extraction and a nonlinear transformation using the ReLU activation function. The feature map output by the final convolutional layer will be classified as input to the fully connected layer[7]. By stacking small-sized convolutional kernels and pooling layers multiple times, VGG16 can effectively increase the depth of the network and improve the accuracy of image recognition. 2.3.2. Pooling layer The pooling layer in VGG16 uses a 2x2 sliding window by using the maximum value within the window as the pooled value. Doing so reduces the size of the feature map while keeping the spatial position of the feature unchanged. The pooling operation can effectively reduce the dimension of the feature map and extract more abstract and important features. The pooling layer in VGG16 is usually immediately followed by the convolutional layer and is used to gradually reduce the size of the feature map[8]. This design allows the network to learn more abstract and complex features at a higher level, thereby improving the performance of the network[9]. The role of pooling layers is to reduce the computational complexity of subsequent layers by reducing the size of the feature map, and it helps to extract more robust features. In VGG16, each pooling layer uses a 2x2 pooling window in steps of 2, so that the size of the pooled feature map is reduced by half. At the same time, the Max Pooling operation is used to retain the maximum value in each pooling window to ensure that important characteristic information is retained. By stacking convolutional layers and pooling layers multiple times, the VGG16 network can gradually reduce the size of the feature map and extract higher-level abstract features at the same time, so that the network has better receptive fields and stronger expression ability. This structural design enables VGG16 to achieve good performance in computer vision tasks such as image classification. 2.3.3. Normalization Instead of an explicit normalization layer, the VGG16 model uses a local response normalization method called "Local Response Normalization" (LRN). In the design of VGG16, LRN operations are used to enhance the generalization ability and adversarial performance of the model. Specifically, the LRN operation is applied after the convolutional layer, which normalizes the output of each convolution kernel[10]. The purpose of LRN manipulation is to enhance local response patterns and inhibit neurons with larger responses, thereby improving the robustness of the model. The LRN operation is calculated as follows: 𝑏 𝑖, 𝑗, 𝑘 𝑎 𝑖, 𝑗, 𝑘 / 𝑘 𝑎 ∗ 𝑎 𝑖,, 𝑗,, 𝑘, Among them, is the 𝑏 𝑖, 𝑗, 𝑘 normalized output, is the 𝑎 𝑖, 𝑗, 𝑘 original value of the convolutional layer output, is a hyperparameter for controlling the 𝑘 bias term, is a hyperparameter for controlling the degree of 𝛼normalization, 𝑖、𝑗、𝑘respectively represents the position coordinates of the feature map[11]. It is important to note that LRN operations are less used in modern deep learning models. Compared to LRN, batch normalization has become a more common and effective normalization method. In subsequent network architectures, such as ResNet and Inception, Batch Normalization is often used for normalization. 2.3.4. Fully connected layer The last three layers of the VGG16 model are fully connected layers, which are used to transform the feature map extracted by the convolutional layer into the final classification result. In VGG16, the fully connected layer is composed of two hidden layers with 4096 neurons and an output layer with 1000 neurons[12]. These fully connected layers receive flattened features from the convolutional layer as input, perform linear transformations and nonlinear activation, and finally output a 1000-dimensional vector representing probability distributions of different classes. The function of the fully connected layer is to map the high-level feature map extracted by the convolutional layer onto the classification label. Through the nonlinear transformation of multiple hidden layers, the fully connected layer can learn more abstract and complex feature representations, thereby improving the classification accuracy[13]. It should be noted that the final fully connected layer of the VGG16 model outputs the probability of 1000 classes, which is suitable for classification tasks on the ImageNet dataset. If you want to classify on other datasets, you need to adjust accordingly. The obtained results are dimensionally predicted using thesoft- max prediction layer. 3. Attention Mechanism The attention mechanism refers to reading data, focusing only on important data and ignoring unimportant data. In the field of image recognition, if the key data is confused with the non-key data in the process of image feature extraction, it will increase the workload, lead to waste of resources, and also affect the experimental effect of the model. Therefore, it was chosen to improve the neural network by introducing a channel attention mechanism to guide the optimization settings of the network[14]. Aiming at the goal of attention weight attention, this paper uses four attention mechanisms 37 and integrates them into the VGG16 neural network, and finally selects the attention mechanism with the best prediction effect of pipe defect size as the final neural network mechanism through ablation experiment comparison. 3.1. SE attention mechanism The SE attention module is a commonly used channel attention mechanism for weighting input in natural language processing tasks. SE stands for "Selective Interpolation" and this module does this by learning two different distribution of attention weights. Specifically, the SE attention module performs two linear transformations of the input features and then activates them separately through activation functions[15]. Next, the softmax function is used to convert the two transformed vectors into attention weight distributions. Finally, the input features are multiplied and added to the attention weights to obtain the weighted feature representation. The SE attention module adaptively selects different features for weighting, thereby improving the expressive ability of the model when processing the input sequence. The advantage of the S E attention module is that it does not change the dimensions of input and output, and can be easily combined with other networks. The algorithm flow diagram of the S E module is shown in Figure 7 X H  W  C trF U H W C (*) sqF (*, ) ex WF (*,*) scaleF X� H W C Figure 7. Flow chart of SE attention mechanism 3.2. STN attention mechanism STN (Spatial Transformer Network) is a spatial attention module used to learn to perform geometric transformations on input data in neural networks. It can rotate, translate, scale and other operations on the input data through the learned transformation parameters, so that the network can better adapt to the input of different scales, angles, and positions. STN modules can be embedded anywhere in a deep learning network and are often used to improve the transformation invariance of the network's input data. It consists of three main components: a localization network, a grid generator, and a sampler) [16]. The localized coordinate regression network is responsible for learning from the input data the transformation parameters, which describe the geometric transformations required to map the input data to the output space. The grid builder uses these parameters to generate a sampling grid that defines how the input data is sampled. Finally, the sampler samples the input data using a sampling mesh to produce a geometrically transformed output[17]. By introducing the STN module, the neural network can automatically learn how to perform geometric transformations on the input data, thereby improving the robustness and generalization ability of the network to the input data. STN modules are widely used in many computer vision tasks, such as image classification, object detection, and image generation. The flowchart of the attention mechanism of TN is shown in Figure 8  ( )GT  U V Local network mesh  generator SAMPLER Figure 8. Flow chart of STN attention mechanism 3.3. CBAM attention mechanism CBAM (Convolutional Block Attention Module) is a hybrid attention mechanism commonly used in image recognition tasks. It aims to improve the feature representation capabilities of convolutional neural networks (CNNs), allowing them to better capture important information in images. The CBAM module consists of two sub-modules: the Channel Attention Module and the Spatial Attention Module). The Channel Attention module adaptively weighted averages the channel dimensions by learning the importance weights of each channel. This allows the network to focus on the most relevant features based on different channel contributions, resulting in a more representative feature. The spatial attention module adaptively weights the spatial dimension of the feature map by learning the importance weight of each spatial location. This directs the network to focus on different areas in the image, allowing it to better understand the spatial structure of the target object or scene[17]. By combining channel attention and spatial attention, the CBAM module is able to capture important information in images more comprehensively and improve the performance of convolutional neural networks in various image recognition tasks. The flowchart of the attention mechanism of CBAM is shown in Figure 9 38   Input feature  mapF Optimized  feature map F  F  C W H C W H Maximum  pooling layer Average  pooling layer multilayer  perceptron Channel Attention  Module Channel  Attention ( ) c FM   Maximum  pooling layer Average  pooling layer convo lution Spatial attention  module Spatial attention s ( )FM Figure 9. Flow chart of CBAM attention mechanism 3.4. ECA attention mechanism The ECA attention mechanism is an attention mechanism based on convolutional neural networks, which is used in image recognition tasks. ECA stands for "efficient channel attention," which improves the performance of feature representation by modeling associations between different channels. Traditional self-attention mechanisms, such as SENet and CBAM, typically compute attention weights based on spatial dimensions, while ECA attention mechanisms focus on channel dimensions. It models dependencies between individual channels by introducing one-dimensional convolution operations[18]. By introducing the ECA attention mechanism, the performance of convolutional neural networks in tasks such as image classification and object detection can be improved, and it has the advantages of high computational efficiency and low number of parameters[19]. The flowchart of the attention mechanism of CBAM is shown in Figure 10 Figure 10. Flow chart of ECA attention mechanism In this paper, the VGG16 network structure was used as the main stem to perform ablation experiments on four attention mechanisms[20]. While extracting deep-level features, the V GG16 network accesses different attention modules in each convolutional layer, so as to compare which module has the best performance for the network. Based on different attention mechanisms, four attention mechanisms are designed for comparison, namely the V GG16 network (S E-VGG16) combined with the channel attention mechanism, and the VGG16 network combined with the spatial attention mechanism ( STN-VGG16), V GG16 network combined with mixed attention mechanism (CBAM-VGG16), attention mechanism combined with convolutional neural network ( ECA-VGG16). Experimental environment introduction: Windows10 64- bit operating device, ANSYS Maxwell 2021 R2, python 10.0; Hardware: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz, 8GB of running memory. The model performance evaluation is shown in Table 2-1, where "√" indicates that the module is added for the VGG16 network, and no "√" indicates that the module is not added. Table 1. Attention modules were added one by one for ablation analysis experiments Grid name SE STN CBAM It'sLIKE Accuracy IN GG16 90.33% SE- VGG16 √ 94.67% STN- VGG16 √ 93.72% CBAM- VGG16 √ 96.44% ECA- VGG16 √ 98.93% Note: The text in bold in the table represents the optimal network As shown in the table, the ECA-vgg 6 network has the highest accuracy in this paper, with the same accuracy as V GG16, S E-VGG16, S TN-VGG16, C BAM-VGG16 Compared with other networks, the E CA-VGG16 neural network model combined with the attention mechanism of convolutional neural networks proposed in this paper is better. In this paper, an attention mechanism combining convolutional neural networks is proposed to improve the VGG16 neural network to obtain the ECA-VGG16 neural network. The basic components of the ECA-VGG16 neural network introduced in this paper introduce the convolutional layer, pooling layer, normalization, fully connected layer, activation function and loss function. The basic components of the attention mechanism are briefly described, and the structure and operation process of the four attention mechanisms are introduced from four aspects: channel attention mechanism, spatial attention mechanism, mixed attention mechanism, and attention mechanism combined with convolutional neural network. Combined with the concentration mechanism, the V GG16 neural network was optimized, and the S E-VGG16 network, S TN-VGG16 network, C BAM-VGG16 network and ECA-VGG16 were formed network, then perform ablation experiments on the pipe flux leakage data. The results show that compared with V GG16, S E-VGG16, S TN-VGG16, CBAM-VGG16 and other networks, the proposed E is proposed to add the attention mechanism combined with convolutional neural networksThe accuracy of the CA-VGG16 neural network model is higher than that of other networks. ECA-VGG16 has the most obvious performance improvement, and the accuracy of pipe defect size prediction is higher. 39 4. Concluding Remarks Aiming at the low efficiency of manual determination of pipeline defects and the low accuracy of shallow network prediction of pipeline defect size, an E CA-VGG16 neural network model combined with the attention mechanism of convolutional neural network is proposed. Compared with traditional convolutional neural networks, the ECA-VGG16 method has more accurate pipeline defect prediction ability and training efficiency, and its accuracy rate can reach 98.93%. The results show that the proposed method proposes a better idea and method for predicting the defects of magnetic flux leakage detection in oil and gas pipelines. References [1] GENG Hao, XIA Hao, WANG Guoqing. Research on Locating Defects of Inner and Outer Wall of Pipelines during High- speed Magnetic Leakage Detection[J]. Chinese Journal of Scientific Instrument, 2022, 43(04): 70-78. [2] LI Yunhui. Research on contour reconstruction technology of magnetic leakage detection of pipeline defects[D]. Northeast Petroleum University, 2021. [3] SU Lin, CHENG Wenfeng, XU Zhijun, et al. Finite element simulation of magnetic leakage detection of oil and gas pipeline defects[J]. Welded Pipe, 2020, 43(04): 8-13+22. [4] YANG Yang. Magnetic flux leakage detection of long-distance natural gas pipeline defects[D]. Xihua University, 2020. [5] CHEN Junjie. Segmentation identification method of defect area of magnetic leakage detection in oil and gas pipeline[J]. China Test, 2017, 43(11): 1-7. [6] Chen Junjie, Huang Songling, Zhao Wei. Research on data compression algorithm for magnetic leakage detection of oil and gas pipeline defects[J].Electrical measurement and instrumentation, 2014, 51(15): 100-104. [7] Min Zhang, Yanbao Guo, Qiuju Xie, Yuansheng Zhang, et al. Defect identification for oil and gas pipeline safety based on autonomous deep learning network[J]. Computer Communications, 2022, 195: 14-26. [8] A. Carvalhoa, J.M.A. Rebelloa, L.V.S.Sagrilob, et al. MFL signals and artificial neural networks applied to detection and classification of pipe weld defects[J]. NDT$E Internationa1, 2006, 39: 661-667. [9] ZHENG Biaohua, HE Wen, ZHOU Songqiang, ZHANG Chunlei, GAO Zhong. 3D finite element simulation analysis of magnetic leakage detection of pipeline defects[J]. China Safety Science Journal, 2013, 23(12): 35-41. [10] DING Zhanwu, HE Renyang, LIU Zhong. Simulation analysis and quantification model of pipeline magnetic leakage detection defect signal[J]. Nondestructive Testing, 2013, 35(03): 30-33. [11] WU Zhenning, WANG Lixing, LIU Jinhai. Reconstruction Method for Complex Defects of Magnetic Field Leakage Detection Based on Spatial Mapping for Uniform Speed Sampling [J]. Chinese Journal of Scientific Instrument, 2018, 039(007): 164-172. [12] JIAO Jingpin, CHANG Yu, LI Guanghai, HE Cunfu, WU Bin. Research on low-frequency magnetic leakage detection technology for internal and external surface cracks of ferromagnetic components[J]. Chinese Journal of Scientific Instrument, 2016, 37(08): 1808-1817. [13] GUO Zijian, RAN Lin. Defect identification method for magnetic flux leakage detection of ANSYS urban natural gas pipelines[J]. Neijiang Science and Technology, 2011, 32(03): 115+37. [14] Anitha, R, Renuka, S, Abudhahir, A. Multi sensor data fusion algorithms for target tracking using multiple measurements[C]//IEEE International Conference on Computational Intelligence & Computing Research. IEEE, 2017: 978-1-4799-1597-2. [15] Baskaran N S M. Analysis of Finite Element Modeling of Magnetic Flux Leakage Technique in Plates with Defect[J]. international journal of engineering sciences & research technology, 2014, 3 (2): 997-1000. [16] Amineh R K, Ravan M, Sadeghi S H H, et al. Using AC field measurement data at an arbitrary liftoff distance to size long surface-breaking cracks in ferrous metals[J]. NDT&E International, 2008, 41(3): 169-177. [17] YANG Lijian, YU Wenlai, GAO Songwei, et al. Defect identification technology of pipeline magnetic flux leakage detection[J]. Journal of Shenyang University of Technology, 2010, 32(01): 65- 69. [18] YANG Lijian, BI Dawei, GAO Songwei. Research on defect quantification technology for magnetic leakage detection of oil and gas pipelines[J]. Computer Measurement and Control, 2009, 17(08): 1489-1491. [19] Mehdi Pourahmadi, Mesbah Saybani. Reliability analysis with corrosion defects in submarine pipeline case study: Oil pipeline in Ab-khark island[J]. Ocean Engineering, 2022, 249: 110-885. [20] Shuai Hao, Pengpeng Shi, Sanqing Su,et al. Evaluation of defect depth in ferromagnetic materials via magnetic flux leakage method with a double Hall sensor[J]. Journal of Magnetism and Magnetic Materials, 2022, 555: 169-341.