Oil and gas pipeline magnetic flux leakage detection method based on improved transformer network
By using an improved transformer network, combined with convolutional modules, encoding modules, and fully connected networks, the problem of capturing local and global features in magnetic flux leakage detection of oil and gas pipelines is solved, achieving high-precision pipeline defect detection.
Patent Information
- Application Number
- CN202310346566.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-03
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2043-04-03
AI Technical Summary
Existing magnetic flux leakage detection methods for oil and gas pipelines struggle to simultaneously capture both local and global features of the magnetic flux leakage image, resulting in insufficient detection accuracy.
An improved transformer network is adopted, which combines convolutional modules, encoding modules and fully connected networks. The complementary use of local and global features is achieved through multi-head attention modules and residual modules, and the network parameters are optimized using the focal loss function.
It enables end-to-end prediction of pipeline defects from raw oil and gas pipeline magnetic flux leakage curve images, improving detection accuracy and generalization ability.
Smart Images

Figure CN116245873B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application discloses an oil and gas pipeline magnetic flux leakage detection method based on an improved transformer network and belongs to the technical field of pipeline maintenance. BACKGROUND
[0002] Oil and gas pipelines are the main arteries of energy transportation in China and are important components of modern energy systems and modern comprehensive transportation systems. At present, China's oil and gas pipelines have entered a large-scale use period, and according to statistics, nearly 100,000 kilometers of oil and gas pipelines in China have appeared in varying degrees of aging. Regular detection and maintenance of oil and gas pipelines can effectively prevent pipeline leakage accidents caused by aging, corrosion, mechanical damage and the like. Pipeline magnetic flux leakage internal detection technology is one of the most widely used detection methods in the field of online detection of long-distance oil and gas pipelines. The detection equipment used by the pipeline magnetic flux leakage internal detection technology is relatively light, has strong online detection capability, is high in automation degree, and does not affect pipeline transportation during operation, so that the pipeline magnetic flux leakage internal detection method is favored by the industry. The pipeline magnetic flux leakage internal detection technology can effectively identify corrosion grooving, corrosion pits, metal loss and hole defects and the like by collecting the change of the magnetic flux leakage field signal of the pipeline defect through a magnetic sensitive probe, so as to timely predict defects such as thinning, perforation or rupture of the oil and gas pipeline and make corresponding treatment measures.
[0003] Traditional pipeline magnetic flux leakage signal recognition methods mainly include a template matching method and a manual feature extraction prediction method. The template matching method is to establish a defect sample database, extract a feature database of pipeline defect signals from a large amount of data, compare the feature extracted from an actual defect signal with the sample feature database, and determine the defect type according to a template matching algorithm. The defect sample database needs a large number of defect samples, so the method is time-consuming and low in efficiency. The manual feature extraction prediction method is to use a feature extraction algorithm to predict the defect type and some characteristic parameters. Since the defect shape described by the feature extraction is relatively simple, the method can only be applied to some standard defects. The defect shape of an actual oil and gas pipeline is complex, so it is difficult to extract complete and effective features. On the other hand, a defect detection method for pipeline magnetic flux leakage curve images through image recognition is also a commonly used method. However, the traditional image recognition method has limited feature extraction capability and is difficult to process large-scale and various feature types of magnetic flux leakage curve images. In recent years, with the development of deep learning in the field of image recognition, more and more deep learning methods have been applied to intelligent recognition of pipeline magnetic flux leakage signals, and the accuracy of pipeline defect recognition has been further improved. However, the existing oil and gas pipeline defect recognition method is difficult to capture local features and global features of the magnetic flux leakage image at the same time, so the precision of oil and gas pipeline magnetic flux leakage detection using the oil and gas pipeline magnetic flux leakage curve image still has room for improvement. SUMMARY
[0004] To solve the above problems, the application provides an oil and gas pipeline magnetic flux leakage detection method based on an improved transformer network, which can adaptively realize the complementarity of local features and global features, thereby improving the oil and gas pipeline magnetic flux leakage detection effect.
[0005] To achieve the above application purposes, the application adopts the following technical solutions:
[0006] The oil and gas pipeline magnetic flux leakage detection method based on the improved transformer network has the following characteristics:
[0007] Step 1, collecting pipeline magnetic flux leakage curve images through a magnetic flux leakage detector, and constructing a pipeline magnetic flux leakage image dataset D={D i |i=1,2,3,...,I}, wherein D i is the i-th image sample, and D i =(X i ,y i ), represents the i-th oil and gas pipeline magnetic flux leakage image, y i indicates the one-hot encoding of the oil and gas pipeline defect category corresponding to X i , wherein L and W are the image length and width, respectively;
[0008] Step 2, building an improved transformer network, including a convolution module, an encoding module, and a fully connected network prediction module; wherein the encoding module includes a multi-head attention module and a residual module;
[0009] Step 2.1, inputting the i-th oil and gas pipeline magnetic flux leakage image X i into the improved transformer network for processing, and correspondingly outputting a prediction vector of the oil and gas pipeline defect category at the z-th iteration
[0010] Step 2.1.1, defining the current iteration number as z, and initializing z=1;
[0011] Step 2.1.2, inputting the oil and gas pipeline magnetic flux leakage image X i into the convolution module to extract image local features, and obtaining a single-channel depth feature matrix F i (z) ;
[0012] Step 2.1.3, cutting the single-channel depth feature matrix F i (z) into several image blocks, and flattening each image block into a one-dimensional vector;
[0013] T i(z)m = embedding[F i (z)m ] (5)
[0014] In formula (5), F i (z)m is the m-th tile of the i-th single-channel depth feature matrix F i (z) , T i (z)m is a one-dimensional vector obtained after flattening F i (z)m , and embedding represents a flattening operation.
[0015] Step 2.1.4, after splicing each tile by using formula (6), adding a classification token and tile position information, a splicing matrix with position information in the z-th iteration is obtained
[0016]
[0017] In formula (6), is a 0-dimensional vector of F , representing a classification token of the oil and gas pipeline magnetic flux leakage image, is a position information matrix of each tile in the z-th iteration, P is the side length of the tile, and E is a weight parameter;
[0018] Step 2.1.5, the splicing matrix is input into the encoding module for processing, so as to obtain the n-th encoding result F i (n)(z) in the z-th iteration;
[0019] Step 2.1.6, the fully connected network prediction module calculates the prediction vector i of the oil and gas pipeline defect category of the i-th oil and gas pipeline magnetic flux leakage image X
[0020]
[0021] In formula (11), is the 0-dimensional vector of the final encoded depth feature F , W' (z) is a linear transformation matrix of the fully connected network prediction module in the z-th iteration, and b' (z) is a bias of the fully connected network prediction module in the z-th iteration;
[0022] Step 2.2, a focal loss loss function FL (z):
[0023]
[0024] In equation (12), δ is the adjustment factor;
[0025] Step 2.3: Based on the sample set D of magnetic flux leakage curve images of oil and gas pipelines, with the objective of minimizing the focal loss function, the parameters in the improved transformer network are optimized and updated using the time backpropagation algorithm and the adaptive moment estimation optimization algorithm until the number of training iterations exceeds the maximum number of iterations Z, and the training ends, thereby obtaining the trained improved transformer network model, which is used to predict the defects of oil and gas pipelines.
[0026] The oil and gas pipeline magnetic flux leakage detection method based on the improved transformer network described in this invention is also characterized in that step 2.1.2 includes the following steps:
[0027] Step 2.1.2.1, the convolution module uses equation (1) to process the magnetic flux leakage image X of the oil and gas pipeline. i Perform a convolution operation to obtain the i-th multi-channel depth feature matrix in the z-th iteration.
[0028]
[0029] In equation (1), k (z) Let b be the convolution kernel at the z-th iteration. (z) It is the bias at the z-th iteration. This represents the convolution operation, and T represents the matrix transpose. Let K represent the hyperbolic tangent activation function, and K, J, and C represent the length, width, and number of channels of the feature map after convolution, respectively.
[0030] Step 2.1.2.2, the convolution module uses equation (2) to process the i-th multi-channel depth feature in the z-th iteration. Perform global max pooling to obtain the i-th multi-channel deep feature map in the z-th iteration.
[0031]
[0032] In equation (2), GMP represents the global max pooling operation, and max represents the maximum value operation. Representing multi-channel depth features The feature matrix of the α-th channel;
[0033] Step 2.1.2.3 is the multi-channel depth feature mapping. Weights are assigned and multiplied with the original multi-channel feature matrix to obtain the weighted multi-channel depth feature matrix using equation (3).
[0034]
[0035] In equation (3), W (z) Let b be the linear transformation matrix at the z-th iteration. (z) This is the bias at the z-th iteration;
[0036] Step 2.1.2.4, use equation (4) to weight the multi-channel depth feature matrix The corresponding positions of each channel are added and merged to obtain the single-channel depth feature matrix F. i (z) :
[0037]
[0038] In equation (4), Represents a weighted multi-channel deep feature matrix The feature matrix of the θ-th channel; C represents the total number of channels.
[0039] Step 2.1.5 includes the following steps:
[0040] Step 2.1.5.1: Define the current encoding count as n, and initialize n = 1;
[0041] Step 2.1.5.2, for the splicing matrix containing positional information in the z-th iteration Perform the nth layer normalization process to obtain the result of the nth layer normalization in the zth iteration.
[0042] Step 2.1.5.3: The multi-head attention module normalizes the matrix after the nth layer. Projecting onto H different attention heads, we obtain the nth projection result of the H attention heads in the z-th iteration. Therefore, Equation (7) is used to calculate the attention weight for the nth iteration corresponding to the h-th attention head in the z-th iteration.
[0043]
[0044] In equation (7), and Let represent the query matrix and key matrix corresponding to the h-th attention head in the z-th iteration, respectively, where h∈{1,2,...,H}, H represents the total number of attention heads, Softmax represents the activation function, and L is the dimension of the query matrix and key matrix. This represents the nth projection result of the h-th attention head in the z-th iteration;
[0045] Step 2.1.5.4: The multi-head attention module uses equation (8) to calculate the nth initial fusion feature matrix corresponding to the hth attention head in the zth iteration.
[0046]
[0047] In equation (8), This represents the nth value matrix corresponding to the h-th attention head in the z-th iteration;
[0048] Step 2.1.5.5: The multi-head attention module calculates the nth fusion feature matrix of the zth iteration using equation (9).
[0049]
[0050] In equation (9), ";" indicates a splicing operation;
[0051] Step 2.1.5.6, the residual module uses equation (10) to process the fused feature matrix. Perform residual processing to obtain the nth residual result under the zth iteration.
[0052]
[0053] Step 2.1.5.7: After assigning n+1 to n, return to step 2.1.4.2 and execute sequentially until n>N, thus obtaining the final encoded deep features of the z-th iteration.
[0054] The present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store a program that supports the processor in executing any of the oil and gas pipeline magnetic flux leakage detection methods, and the processor is configured to execute the program stored in the memory.
[0055] The present invention discloses a computer-readable storage medium on which a computer program is stored, wherein the computer program, when executed by a processor, performs any of the steps of the oil and gas pipeline magnetic flux leakage detection method.
[0056] Compared with existing technologies, the beneficial effects of this invention are reflected in:
[0057] 1. This invention discloses a magnetic flux leakage detection method for oil and gas pipelines based on an improved transformer network. This method overcomes the shortcomings of complex data processing and feature extraction in existing methods. It achieves end-to-end prediction of pipeline defects from the original magnetic flux leakage curve image data of oil and gas pipelines without the need for prior knowledge of the system. It has the advantages of simple operation and strong generalization.
[0058] 2. This invention utilizes a convolutional module to fully mine the local features of magnetic flux leakage images of oil and gas pipelines, while using an encoding module to capture global features and automatically assign different importance weights to features in different spatial areas of magnetic flux leakage in oil and gas pipelines. This allows local and global features to adaptively complement each other in the network, thereby improving the performance of magnetic flux leakage detection for oil and gas pipelines. Attached Figure Description
[0059] Figure 1 This is a schematic flowchart of the method of the present invention;
[0060] Figure 2 This is a structural diagram of the improved transformer network of the present invention;
[0061] Figure 3 This is a model framework diagram of the convolution module of the present invention;
[0062] Figure 4 This is a model framework diagram of the coding and fully connected network prediction module of this invention;
[0063] Figure 5 This is a structural diagram of the multi-head attention encoding module of the present invention. Detailed Implementation
[0064] In this embodiment, as Figure 1 As shown, the process of a magnetic flux leakage detection method for oil and gas pipelines based on an improved transformer network includes the following steps:
[0065] Step 1: Acquire pipeline magnetic flux leakage curve images using a magnetic flux leakage detector, and construct a pipeline magnetic flux leakage image dataset D = {D} i |i=1,2,3,...,I}, where D i Let D be the i-th image sample, and D i =(X i ,y i ), y represents the magnetic flux leakage image of the i-th oil and gas pipeline. i X represents i The unique thermal encoding corresponding to the defect category of oil and gas pipeline, where L and W are the image length and width, respectively;
[0066] Step 2, as follows Figure 2As shown, an improved transformer network is constructed, including: a convolutional module, an encoding module, and a fully connected network prediction module; wherein, the encoding module includes: a multi-head attention module and a residual module;
[0067] Specifically, the convolution module first uses convolution operations to obtain the local defect feature matrix of the oil and gas pipeline through multiple channels. Then, it uses global max pooling to obtain the multi-channel depth feature vector. Next, it uses linear transformation to assign weights to the multi-channel depth feature vector and multiplies it with the corresponding local defect depth feature matrix of the multi-channel pipeline to obtain the multi-channel local defect feature matrix containing weight information. Finally, the multi-channel local defect feature matrices containing weight information are added and merged into a single-channel local defect feature matrix, thereby extracting rich feature information. The single-channel local defect feature matrix extracted by the convolution module is fed into the encoding module after adding position information. The encoding module inputs the depth feature data after layer normalization into the multi-head attention module. By projecting the oil and gas pipeline defects onto different attention heads, it can adaptively fuse the depth features at each location. At the same time, it uses a residual network to ensure that the global features of the oil and gas pipeline defects are not lost during network transmission. The fully connected network prediction module outputs the final oil and gas pipeline magnetic flux leakage detection result through a single-layer artificial neural network.
[0068] Step 2.1, extract the magnetic flux leakage image X of the i-th oil and gas pipeline. i The input is processed in an improved transformer network, and the corresponding output is the predicted vector of the oil and gas pipeline defect category at the z-th iteration.
[0069] Step 2.1.1: Define the current iteration number as z, and initialize z = 1;
[0070] Step 2.1.2, X-ray the magnetic flux leakage image of the oil and gas pipeline. i Input convolution module, such as Figure 3 As shown, local image features are extracted.
[0071] Step 2.1.2.1, the convolution module uses equation (1) to process the magnetic flux leakage image X of the oil and gas pipeline. i Perform a convolution operation to obtain the i-th multi-channel depth feature matrix in the z-th iteration.
[0072]
[0073] In equation (1), k (z) Let b be the convolution kernel at the z-th iteration. (z) It is the bias at the z-th iteration. This represents the convolution operation, and T represents the matrix transpose. Let K represent the hyperbolic tangent activation function, and K, J, and C represent the length, width, and number of channels of the feature map after convolution, respectively.
[0074] Step 2.1.2.2, the convolution module uses equation (2) to process the i-th multi-channel depth feature in the z-th iteration. Perform global max pooling to obtain the i-th multi-channel deep feature map in the z-th iteration.
[0075]
[0076] In equation (2), GMP represents the global flat max pooling operation, and max represents the maximum value operation. Representing multi-channel depth features The feature matrix of the α-th channel;
[0077] Step 2.1.2.3, use equation (3) for multi-channel depth feature mapping. Weights are assigned and multiplied with the original multi-channel feature matrix to obtain a weighted multi-channel depth feature matrix.
[0078]
[0079] In equation (3), W (z) Let b be the linear transformation matrix at the z-th iteration. (z) This is the bias at the z-th iteration;
[0080] Step 2.1.2.4: Using equation (4), add and merge the corresponding positions of each channel in the weighted multi-channel depth feature matrix to obtain the single-channel depth feature matrix F. i (z) :
[0081]
[0082] In equation (4), Represents a weighted multi-channel deep feature matrix The feature matrix of the θ-th channel; C represents the total number of channels;
[0083] Step 2.1.3, use equation (5) to analyze the single-channel depth feature matrix F i (z) The image is divided into several tiles, and each tile is flattened into a one-dimensional vector.
[0084] T i (z)m =embedding[F i (z)m (5)
[0085] In equation (5), F i (z)m F is the depth feature matrix of the i-th single channel. i (z) The m-th tile, T i (z)m For the m-th tile F i (z)m The one-dimensional vector obtained after flattening, where embedding represents the flattening operation;
[0086] Step 2.1.4: After stitching together the various tiles using equation (6), add the classification token and tile position information to obtain the stitching matrix containing position information for the z-th iteration.
[0087]
[0088] In equation (6), for The 0th dimension vector represents the classification token of the magnetic flux leakage image of the oil and gas pipeline. Let P be the position information matrix of each tile in the z-th iteration, where P is the side length of the tile and E is the weight parameter.
[0089] Step 2.1.5, Concatenate the matrix In the input encoding module, such as Figure 4 As shown, the process is performed to obtain the nth encoding result F of the zth iteration. i (n)(z) ;
[0090] Step 2.1.5.1: Define the current encoding count as n, and initialize n = 1;
[0091] Step 2.1.5.2, for the splicing matrix containing positional information in the z-th iteration Perform the nth layer normalization process to obtain the result of the nth layer normalization in the zth iteration.
[0092] Step 2.1.5.3, Multi-head Attention Module, such as Figure 5 As shown, the matrix after layer normalization Projecting onto H different attention heads, we obtain the nth projection result of the H attention heads in the z-th iteration. Therefore, Equation (7) is used to calculate the attention weight for the nth iteration corresponding to the h-th attention head in the z-th iteration.
[0093]
[0094] In equation (7), and Let represent the query matrix and key matrix corresponding to the h-th attention head in the z-th iteration, respectively, where h∈{1,2,…,H}, H represents the total number of attention heads, Softmax represents the activation function, and L is the dimension of the query matrix and key matrix. This represents the nth projection result of the h-th attention head in the z-th iteration;
[0095] Step 2.1.5.4: The multi-head attention module uses equation (8) to calculate the initial fusion feature matrix corresponding to the h-th attention head in the z-th iteration.
[0096]
[0097] In equation (8), This represents the nth value matrix corresponding to the h-th attention head in the z-th iteration;
[0098] Step 2.1.5.5: The multi-head attention module uses equation (9) to calculate the fusion feature matrix for the nth iteration in the zth iteration.
[0099]
[0100] In equation (9), ";" indicates a splicing operation;
[0101] Step 2.1.5.6, the residual module uses equation (10) to process the fused feature matrix. Perform residual processing to obtain the nth residual result under the zth iteration.
[0102]
[0103] Step 2.1.5.7: After assigning n+1 to n, return to step 2.1.4.2 and execute sequentially until n>N, thus obtaining the final encoded deep features of the z-th iteration.
[0104] Step 2.1.6: The fully connected network prediction module uses equation (11) to calculate the magnetic flux leakage image X of the i-th oil and gas pipeline at the z-th iteration. i Prediction vector of oil and gas pipeline defect categories
[0105]
[0106] In equation (11), For the final encoded deep features The zeroth dimension vector, W' (z) Let b' be the linear transformation matrix of the fully connected network prediction module at the z-th iteration.(z) This represents the bias of the fully connected network prediction module at the z-th iteration;
[0107] Step 2.2, construct the focal loss function FL for the z-th iteration using equation (12). (z) :
[0108]
[0109] In equation (12), δ is the adjustment factor;
[0110] Step 2.3: Based on the sample set D of magnetic flux leakage curve images of oil and gas pipelines, with the objective of minimizing the focal loss function, the parameters in the improved transformer network are optimized and updated using the time backpropagation algorithm and the adaptive moment estimation optimization algorithm until the number of training iterations exceeds the maximum number of iterations Z, thus ending the training and obtaining the trained improved transformer network model, which is used to predict the defects of oil and gas pipelines.
[0111] In this embodiment, an electronic device includes a memory and a processor. The memory stores a program that supports the processor in executing the above-described method, and the processor is configured to execute the program stored in the memory.
[0112] In this embodiment, a computer-readable storage medium stores a computer program, which is executed by a processor to perform the steps of the above method.
Claims
1. A method for detecting magnetic flux leakage in oil and gas pipelines based on an improved transformer network, characterized in that, Includes the following steps: Step 1: Acquire pipeline magnetic flux leakage curve images using a magnetic flux leakage detector, and construct a pipeline magnetic flux leakage image dataset D = {D} i |i=1,2,3,...,I}, where D i Let D be the i-th image sample, and D i =(X i ,y i ), y represents the magnetic flux leakage image of the i-th oil and gas pipeline. i X represents i The unique thermal encoding corresponding to the defect category of oil and gas pipeline, where L and W are the image length and width, respectively; Step 2: Construct an improved transformer network, including a convolutional module, an encoding module, and a fully connected network prediction module; wherein the encoding module includes a multi-head attention module and a residual module; Step 2.1, extract the magnetic flux leakage image X of the i-th oil and gas pipeline. i The input is processed in the improved transformer network, and the predicted vector of the oil and gas pipeline defect category at the z-th iteration is output accordingly. Step 2.1.1: Define the current iteration number as z, and initialize z = 1; Step 2.1.2, X-ray the magnetic flux leakage image of the oil and gas pipeline. i The input is used to extract local image features in the convolution module, resulting in a single-channel depth feature matrix F. i (z) ; Step 2.1.3, use equation (5) to process the single-channel depth feature matrix F i (z) The image is divided into several tiles, and each tile is flattened into a one-dimensional vector. T i (z)m =embedding[F i (z)m ] (5) In equation (5), F i (z)m F is the depth feature matrix of the i-th single channel. i (z) The m-th tile, T i (z)m For the m-th tile F i (z)m The one-dimensional vector obtained after flattening, where embedding represents the flattening operation; Step 2.1.4: After stitching together the various tiles using equation (6), add the classification token and tile position information to obtain the stitching matrix containing position information for the z-th iteration. In equation (6), for The 0th dimension vector represents the classification token of the magnetic flux leakage image of the oil and gas pipeline. Let P be the position information matrix of each tile in the z-th iteration, where P is the side length of the tile and E is the weight parameter. Step 2.1.5, the splicing matrix The input is processed in the encoding module to obtain the encoding result F of the nth iteration of the zth iteration. i (n)(z) ; Step 2.1.6, the fully connected network prediction module uses equation (11) to calculate the magnetic flux leakage image X of the i-th oil and gas pipeline at the z-th iteration. i Prediction vector of oil and gas pipeline defect categories In equation (11), For the final encoded deep features The zeroth dimension vector, W' (z) Let b' be the linear transformation matrix of the fully connected network prediction module at the z-th iteration. (z) This represents the bias of the fully connected network prediction module at the z-th iteration; Step 2.2, construct the focal loss function FL for the z-th iteration using equation (12). (z) : In equation (12), δ is the adjustment factor; Step 2.3: Based on the sample set D of magnetic flux leakage curve images of oil and gas pipelines, with the objective of minimizing the focal loss function, the parameters in the improved transformer network are optimized and updated using the time backpropagation algorithm and the adaptive moment estimation optimization algorithm until the number of training iterations exceeds the maximum number of iterations Z, and the training ends, thereby obtaining the trained improved transformer network model, which is used to predict the defects of oil and gas pipelines.
2. The oil and gas pipeline magnetic flux leakage detection method based on an improved transformer network according to claim 1, characterized in that, Step 2.1.2 includes the following steps: Step 2.1.2.1, the convolution module uses equation (1) to process the magnetic flux leakage image X of the oil and gas pipeline. i Perform a convolution operation to obtain the i-th multi-channel depth feature matrix in the z-th iteration. In equation (1), k (z) Let b be the convolution kernel at the z-th iteration. (z) It is the bias at the z-th iteration. This represents the convolution operation, and T represents the matrix transpose. Let K represent the hyperbolic tangent activation function, and K, J, and C represent the length, width, and number of channels of the feature map after convolution, respectively. Step 2.1.2.2, the convolution module uses equation (2) to process the i-th multi-channel depth feature in the z-th iteration. Perform global max pooling to obtain the i-th multi-channel deep feature map in the z-th iteration. In equation (2), GMP represents the global max pooling operation, and max represents the maximum value operation. Representing multi-channel depth features The feature matrix of the α-th channel; Step 2.1.2.3 is the multi-channel depth feature mapping. Weights are assigned and multiplied with the original multi-channel feature matrix to obtain the weighted multi-channel depth feature matrix using equation (3). In equation (3), W (z) Let b be the linear transformation matrix at the z-th iteration. (z) This is the bias at the z-th iteration; Step 2.1.2.4, use equation (4) to weight the multi-channel depth feature matrix The corresponding positions of each channel are added and merged to obtain the single-channel depth feature matrix F. i (z) : In equation (4), Represents a weighted multi-channel deep feature matrix The feature matrix of the θ-th channel; C represents the total number of channels.
3. The oil and gas pipeline magnetic flux leakage detection method based on an improved transformer network according to claim 2, characterized in that, Step 2.1.5 includes the following steps: Step 2.1.5.1: Define the current encoding count as n, and initialize n = 1; Step 2.1.5.2, for the splicing matrix containing positional information in the z-th iteration Perform the nth layer normalization process to obtain the result of the nth layer normalization in the zth iteration. Step 2.1.5.3: The multi-head attention module normalizes the matrix after the nth layer. Projecting onto H different attention heads, we obtain the nth projection result of the H attention heads in the z-th iteration. Therefore, Equation (7) is used to calculate the attention weight for the nth iteration corresponding to the h-th attention head in the z-th iteration. In equation (7), and Let represent the query matrix and key matrix corresponding to the h-th attention head in the z-th iteration, respectively, where h∈{1,2,…,H}, H represents the total number of attention heads, Softmax represents the activation function, and L is the dimension of the query matrix and key matrix. This represents the nth projection result of the h-th attention head in the z-th iteration; Step 2.1.5.4: The multi-head attention module uses equation (8) to calculate the nth initial fusion feature matrix corresponding to the hth attention head in the zth iteration. In equation (8), This represents the nth value matrix corresponding to the h-th attention head in the z-th iteration; Step 2.1.5.5: The multi-head attention module calculates the nth fusion feature matrix of the zth iteration using equation (9). In equation (9), ";" indicates a splicing operation; Step 2.1.5.6, the residual module uses equation (10) to process the fused feature matrix. Perform residual processing to obtain the nth residual result under the zth iteration. Step 2.1.5.7: After assigning n+1 to n, return to step 2.1.4.2 and execute sequentially until n>N, thus obtaining the final encoded deep features of the z-th iteration.
4. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store a program that supports the processor in executing the oil and gas pipeline magnetic flux leakage detection method according to any one of claims 1-3, and the processor is configured to execute the program stored in the memory.
5. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is run by the processor, it performs the steps of the oil and gas pipeline magnetic flux leakage detection method according to any one of claims 1-3.
Citation Information
Patent Citations
Vision Transform network-based weak supervision instance segmentation method and system, and medium
CN115359254A
Vision Transformer Apparatus for Small Dataset and Method of Operation
KR102479817B1