Oil and gas pipeline leakage detection method and system based on improved DTBM architecture
By designing a DTBM architecture that integrates Transformer and CNN hybrid deep model, the sensitivity and accuracy issues of oil and gas pipeline leak detection were solved, achieving efficient and stable leak identification and location.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NORTHEAST GASOLINEEUM UNIV
- Filing Date
- 2026-01-23
- Publication Date
- 2026-04-10
AI Technical Summary
Existing methods for detecting leaks in oil and gas pipelines suffer from low sensitivity, inaccurate localization, and high false alarm rates. Directly applying the Transformer model from the field of natural language processing results in high computational complexity, insufficient local feature capture, and unstable training when processing long sequences.
We design a hybrid deep architecture that integrates the global modeling capabilities of Transformer with the local feature extraction advantages of convolutional neural networks. By combining mixed-precision training and gradient clipping and other stable training strategies, we construct a multi-level DTBM model and perform feature extraction and classification through adaptive convolutional layers and learnable query vectors.
It achieves accurate, real-time, and robust identification of pipeline leaks, with high detection accuracy and low false alarm rate, and is suitable for detecting oil and gas pipeline leaks under complex operating conditions.
Smart Images

Figure CN121834709A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of industrial Internet of Things and artificial intelligence cross-application technology, and relates to the field of oil and gas pipeline safety monitoring technology based on deep learning, specifically to an oil and gas pipeline leakage detection method and system based on an improved DTBM architecture. Background Technology
[0002] Oil and gas pipelines are vital to the national economy, and their safe operation is of paramount importance. Pipeline leaks can lead to enormous economic losses, environmental disasters, and even casualties. Existing leak detection methods, such as traditional methods based on mass balance, pressure point analysis, and negative pressure waves, generally suffer from low sensitivity, inaccurate location, and high false alarm rates.
[0003] In recent years, to improve the sensitivity and accuracy of oil and gas pipeline leak detection, existing technologies have provided several solutions for oil and gas pipeline leak detection. For example, document CN112857699B discloses a method for detecting and locating leaks in long-distance oil pipelines using acoustic vector sensors. This method establishes a database of leak sounds in long-distance oil and gas pipelines, uses an array of acoustic vector sensors to sense leak sounds, collects data, performs eigenvalue decomposition of the autocorrelation matrix of the entire array receiving data, and obtains the estimated value of the array steering vector matrix based on subspace theory and the least squares method, further obtaining the estimated values of azimuth and elevation angles. Combined with the sound intensity measured by a sound pressure scalar sensor and compared with the data in the database, it provides overall information on the distance to the pipeline leak point, pipeline damage, and leak status, which is then sent to the information receiving center. This method utilizes artificial intelligence technology to establish a pipeline leak sound database, separating pipeline leak sounds from other noises, effectively preventing missed and false alarms. The use of acoustic vector sensors improves the location accuracy of pipeline leak points, compensating for the shortcomings of existing detection and location methods. The prior art, document number CN120448793A, discloses a SCADA-based method for monitoring oil and gas pipeline leaks. The method includes the following steps: establishing a SCADA data preprocessing model; establishing a leak feature extraction model; identifying the leak status using a leak detection classification model; locating the leak point; calculating the leak rate; assessing the risk level based on a leak risk assessment model; providing real-time early warning and dynamically adjusting the warning level; and developing an emergency response plan. This oil and gas pipeline leak monitoring method, by establishing multiple models, can effectively remove the influence of environmental noise and operational disturbances, ensuring the accuracy of leak feature extraction and achieving high precision and dynamic adaptability in leak location and rate estimation. Compared to traditional methods, it significantly improves the sensitivity and accuracy of leak detection and can dynamically adjust monitoring parameters in complex environments.
[0004] Recently, deep learning-based acoustic detection methods have attracted attention due to their high sensitivity. These methods identify leaks by analyzing acoustic signals collected by sensors on pipes. However, directly applying the Transformer model from natural language processing to one-dimensional time-series signals presents several challenges: First, the computational complexity of its self-attention mechanism increases quadratically with the sequence length, making it difficult to handle long sequences; second, it is insufficient in capturing subtle local features, while leak signals are often hidden in local waveform changes; and finally, the training process is unstable and susceptible to abnormal gradients.
[0005] Therefore, there is an urgent need for a dedicated model architecture that can balance global context awareness and local feature extraction, and is stable in training and computationally efficient. Summary of the Invention
[0006] The technical problem to be solved by this invention is:
[0007] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method and system for detecting oil and gas pipeline leaks based on an improved DTBM architecture. This method designs a hybrid deep architecture that integrates the global modeling capabilities of Transformer and the advantages of local feature extraction of convolutional neural networks, and introduces stable training strategies such as hybrid precision training and gradient pruning to achieve accurate, real-time and robust identification of pipeline leak status.
[0008] The technical solution adopted by the present invention to solve the above-mentioned technical problems is as follows:
[0009] A method for detecting leaks in oil and gas pipelines based on an improved DTBM architecture includes the following steps:
[0010] Step 1, Signal Acquisition and Standardized Storage: Acoustic wave signals from the pipeline are acquired by acoustic wave sensors deployed at key nodes of the oil and gas pipeline, and transmitted to the detection system in real time for standardized storage.
[0011] Step 2, Data Preprocessing and Sample Construction: Standardize and preprocess the collected time-series signals, and construct training and test samples with temporal correlation using the sliding window method;
[0012] Step 3: Build a multi-layered DTBM detection model, which includes:
[0013] An initial embedding layer and a positional encoding layer are used for feature space mapping and positional information injection;
[0014] N cascaded multi-branch convolutional modules (downsampling modules), N≥3, each multi-branch convolutional module contains two parallel paths:
[0015] Transformer encoder path, used to process global temporal features;
[0016] The adaptive convolution path includes an adaptive type convolutional layer 1 and an adaptive type convolutional layer 2. The adaptive type convolutional layer 1 includes an adaptive type one-dimensional convolutional layer, a batch normalization layer, a GELU activation function, and a max pooling layer used to halve the sequence length. The adaptive type convolutional layer 2 includes an adaptive type one-dimensional convolutional layer, a batch normalization layer, and a GELU activation function.
[0017] The data fusion layer fuses the dual-path output features. The fusion mechanism of the data fusion layer fuses the features of the Transformer encoder path output and the adaptive convolution path output.
[0018] The feature aggregation decoder layer uses learnable query vectors to generate sample-level feature representations.
[0019] The classification layer is used to output the probability distribution of leakage states;
[0020] Step 4, Model Training and Optimization: Train the model using the cross-entropy loss function and NAdam optimizer, implement a mixed precision training and gradient pruning strategy, and use a dynamic learning rate adjustment mechanism to accelerate convergence;
[0021] Step 5, Leakage Identification and Result Visualization: The trained model is used to identify the leakage status of real-time pipeline signals, and multi-dimensional evaluation indicators are output, including accuracy, F1 score, and precision; the training process is visualized, including the loss descent curve and the accuracy convergence curve; the results are also visualized, including the confusion matrix and T-Sne dimensionality reduction visualization.
[0022] S1 represents the process of signal acquisition and standardized storage:
[0023] Vibration signals from the pipeline wall are continuously collected by an array of acoustic sensors pre-deployed at key nodes of oil and gas pipelines (such as valve chambers, pumping stations, and sections prone to geological disasters). The collected raw time-series signals are transmitted to edge computing nodes or cloud servers, where amplitude normalization is performed to eliminate the influence of dimensions, and finally time-series alignment and standardized storage are performed.
[0024] S2 represents the data preprocessing and sample construction process:
[0025] The standardized time-series signal is segmented using a fixed-length sliding window method, with an overlap length, to construct training and testing sample sets with temporal correlation. The training and testing sets are strictly divided according to time order to ensure the causal validity of the model evaluation.
[0026] S3 describes the process of building a multi-level DTBM detection model:
[0027] As shown in the attached diagram.Figure 2 The multi-layered DTBM model shown is the core of this invention. First, the original one-dimensional signal is mapped to a high-dimensional feature space through an initial embedding layer and a positional encoding layer, injecting absolute positional information. Then, feature extraction and fusion are performed through N cascaded downsampling modules (N≥3). Each module captures global temporal dependencies through the Transformer encoder path and extracts local features using a convolutional downsampling path, which includes a combination of adaptive typed convolutional layers, batch normalization layers, and the GELU activation function, and halves the sequence length through max pooling. The output features of the two paths are channel-adjusted and then fused through additive concatenation to achieve complementarity between global and local information. Finally, the global context information is aggregated through the Transformer decoder layer, and the classification head layer outputs the classification probability distribution of the leaked state.
[0028] S4 represents the model training and optimization process:
[0029] The model is trained using the cross-entropy loss function and the NAdam optimizer. A mixed-precision training strategy is employed: FP16 precision is used during forward propagation to reduce memory usage and accelerate computation, while FP32 precision is maintained during backpropagation to preserve gradient update stability. A dual gradient pruning strategy is also implemented, including controlling the overall gradient norm to prevent gradient explosion and limiting the value of each gradient element to avoid interference from outlier gradient values. A dynamic learning rate adjustment mechanism is used, adaptively adjusting the learning rate based on the validation set loss performance.
[0030] S5 is the process of leak identification and result analysis:
[0031] The trained model is used to perform forward propagation on real-time pipeline signals, outputting the classification results of the leakage status. The system simultaneously outputs multi-dimensional evaluation metrics, including key performance indicators such as accuracy, F1 score, precision, global recall, and false alarm rate, and generates a heatmap of the normalized confusion matrix for visual analysis, as shown in the attached figure. Figure 4 As shown.
[0032] Furthermore, the signal acquisition and standardized storage described in step 1 are specifically implemented as follows:
[0033] (1) The raw signal acquired by the sensor is first subjected to anti-aliasing filtering, and its frequency band range is limited as follows:
[0034]
[0035] in The sampling frequency;
[0036] (2) The filtered signal is normalized in dimensions and stored in segments, with the storage format satisfying:
[0037]
[0038] in and The mean and standard deviation are for each channel.
[0039] Furthermore, the data preprocessing and sample construction (standardization preprocessing and sample construction) described in step 2 are specifically implemented as follows:
[0040] (1) Z-score normalization of the stored signal:
[0041]
[0042] in It is a numerically stable term;
[0043] (2) The sliding window sample generation rule satisfies:
[0044]
[0045] Where L is the window length, Δ is the sliding step size, and each sample is associated with its corresponding pipeline condition label y∈{0,1,2}, where 0 represents normal, 1 represents a small leak, and 2 represents a large leak.
[0046] Furthermore, the adaptive data type one-dimensional convolutional layer described in step 3 employs the following data type adaptation mechanism: before performing convolution calculations, the data type of the convolution kernel weights and biases is automatically adjusted to be consistent with the input tensor; it supports both zero-padding and non-zero-padding modes, and its calculation process satisfies:
[0047] (1)
[0048] The kernel weights and biases are converted to ensure they are consistent with the input. The input is the input tensor. pad() is the padding operation function. When non-zero padding is enabled, P zero points are added to both ends of the temporal dimension of the input tensor. conv1d() is the one-dimensional convolution operation function.
[0049] Furthermore, the multi-branch convolutional module (downsampling module) in step 3 adopts a dual-path fusion architecture, simultaneously constructing the Transformer encoder path and the convolutional downsampling path; the feature fusion formula is used to achieve additive connection: Output = F_encoder + F_conv, where F_encoder is the output feature of the Transformer encoder and F_conv is the output feature of the convolutional path; a channel adjustment layer is used to ensure the feature dimension matching of the two paths; and a max pooling layer is used to halve the sequence length and extract features.
[0050] Furthermore, the feature aggregation decoder layer described in step 3 includes: learnable query vector parameters, which expand the matching batch dimension through repetition; a multi-layer Transformer structure, each layer including: a multi-head self-attention mechanism (number of heads ≥ 2), a feedforward neural network (dimensional expansion coefficient ≥ 4), additive connections and layer normalization; a feature compression layer that converts the sequence dimension output into a sample-level feature vector; the multi-layer DTBM detection model parameters described in step 3 are configured as follows: number of basic channels: 4-16 channels; number of downsampling modules: 3-5 levels; number of Transformer heads: 2-4 heads; number of classification categories: 3 categories, including normal, small leakage, and large leakage.
[0051] Furthermore, the training process in step 4 includes: employing a mixed-precision training mechanism, implementing half-precision computation through an autocast context manager, and managing loss scaling through GradScaler; implementing a dual gradient clipping strategy: gradient norm clipping (clip_grad_norm) with a threshold of 0.5-1.0, and gradient value clipping (clip_grad_value) with a limit of 0.5; applying dynamic learning rate adjustment using the ReduceLROnPlateau scheduler with the following parameters: monitoring metrics: validation set loss, decay factor: 0.1-0.5, patience: 3-10 epochs; and implementing gradient statistics monitoring, calculating and recording the gradient mean and L2 norm in real time.
[0052] Furthermore, the evaluation metrics described in step 5 include: global recall rate. Where: TP is the number of correctly predicted cases across all categories, FN is the sum of the number of false negatives across all categories; false positive rate ,in: The number of normal samples misclassified as faulty The number of correctly identified normal samples is calculated; a normalized confusion matrix is generated and visualized using a heatmap.
[0053] An oil and gas pipeline leak detection system based on an improved DTBM architecture is provided. The system has program modules corresponding to the steps of the method, and executes the steps of the oil and gas pipeline leak detection method based on the improved DTBM architecture when running.
[0054] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the oil and gas pipeline leak detection method based on the improved DTBM architecture.
[0055] An oil and gas pipeline leak detection device, the oil and gas pipeline leak detection device comprising:
[0056] An array of acoustic sensors deployed at nodes of sudden pressure changes in pipelines, at least one processor, and a memory communicatively connected to the at least one processor; the acoustic sensor array sends monitored oil and gas pipeline leakage data to the processor.
[0057] The memory stores instructions that can be executed by the at least one processor. When the at least one processor executes the instructions, it enables the at least one processor to perform the oil and gas pipeline leakage detection method based on an improved DTBM architecture, thereby realizing signal preprocessing and sample construction, DTBM detection model building, model training, real-time analysis, and output of pipeline status classification results and confidence maps.
[0058] The main technical features of this invention are:
[0059] A. Adaptive Type Convolutional Layer: As described in claim 2, this custom convolutional layer automatically converts the data types of the weights and biases to be consistent with the input tensor before performing calculations, effectively solving the problem of calculation errors or precision loss that may be caused by data type mismatch in mixed precision training.
[0060] B. Dual-branch downsampling architecture: As described in claim 4, each downsampling module adopts a dual-path design and fuses the outputs of the two paths by addition, which is the core of achieving high performance.
[0061] C. Learnable query vectors: Learnable parameters in the decoder, through training and optimization, learn how to most effectively query information from encoder features to complete the classification task.
[0062] D. Comprehensive training stabilization strategy: The combined use of mixed precision, gradient pruning (norm and value pruning), and dynamic learning rate adjustment ensures that deep and complex models can converge stably and efficiently.
[0063] The present invention has the following beneficial technical effects:
[0064] This invention presents a method for detecting leaks in oil and gas pipelines based on a Deep Two-Branch Model (DTBM) architecture. This method innovatively integrates multi-branch fusion and a self-attention mechanism. Multi-branch fusion alleviates the gradient vanishing problem in deep network training, improving information transmission efficiency. Simultaneously, the self-attention mechanism models long-distance dependencies in pipeline state signals, significantly enhancing the extraction and identification of leak features. Key technical points of this invention include: collecting pipeline state data through acoustic sensors deployed on the oil and gas pipeline, inputting the data into the detection system in real time, and storing it; standardizing and preprocessing the collected data, and using a sliding window method to construct training and testing samples; constructing a DTBM-based deep classification model, using the cross-entropy loss function, and introducing the NAdam optimizer to adaptively adjust the learning rate, effectively accelerating model convergence and enhancing training stability; training the model using the training samples to identify leak states, and verifying the model's leak detection performance using testing samples. Experimental results show that this method can maintain excellent detection performance under complex working conditions, with a leakage event identification accuracy of over 99.94%, while also having a low false alarm rate and good engineering applicability.
[0065] This invention utilizes an improved Transformer architecture (DTBM) for feature extraction and pattern recognition of pipeline acoustic vibration signals, thereby achieving a high-precision and high-efficiency method and system for pipeline leak detection. It can be widely applied in oil and gas pipeline leak detection projects. Compared with existing technologies, this invention has the following significant advantages:
[0066] 1. High detection accuracy: The DTBM architecture combines the global modeling capability of Transformer with the local feature extraction advantage of CNN, enabling high-precision identification of both weak and obvious leakage signals.
[0067] 2. Strong model robustness: The application of adaptive type convolutional layers and a series of training stabilization techniques makes the model less sensitive to noise and outliers in the data, resulting in a smoother training process and stronger generalization ability.
[0068] 3. Good engineering practicality: The model has a regular structure and flexible parameter configuration (the scale can be adjusted through base_channels, num_modules, etc.), making it easy to deploy in existing pipeline monitoring systems and meet real-time requirements.
[0069] 4. Superior interpretability: By outputting visualizations such as confusion matrices and gradient change curves, it helps engineers understand the model's decision-making process and analyze misjudgment cases. Attached Figure Description
[0070] Figure 1The overall workflow diagram of the oil and gas pipeline leakage detection system according to the present invention (oil and gas pipeline leakage detection method based on DTBM).
[0071] Figure 2 The schematic diagram of the core architecture of the multi-level DTBM model described in this invention focuses on the internal dual-path structure and information flow of the cascaded downsampling module.
[0072] Figure 3 : A graph showing the changes in the loss function (training loss, validation loss) and the evaluation metric (accuracy) during the training process.
[0073] Figure 4 The normalized confusion matrix heatmap of the model on the independent test set (displayed as a percentage) visually shows the recognition status and misclassification distribution of each category (normal, small leakage, large leakage).
[0074] Figure 5 The t-SNE dimensionality reduction visualization analysis diagram is used to further verify the feature learning ability and domain adaptation performance of the DTBM model proposed in this paper under pipeline leakage conditions. The high-dimensional features learned by the network are visualized and analyzed using t-SNE (t-distributedStochastic Neighbor Embedding) technology. Detailed Implementation
[0075] Combined with appendix Figure 1-5 The implementation of the oil and gas pipeline leakage detection method based on the improved DTBM architecture described in this invention is explained as follows:
[0076] A method for detecting leaks in oil and gas pipelines based on an improved DTBM architecture, characterized by the following steps:
[0077] Step 1: Acoustic wave signals from the pipeline are collected by acoustic wave sensors deployed at key nodes of the oil and gas pipeline, and transmitted to the detection system in real time for standardized storage.
[0078] Step 2: Standardize and preprocess the collected time-series signals, and construct training and test samples with temporal correlation using the sliding window method;
[0079] Step 3: Build a multi-layered DTBM detection model, which includes:
[0080] An initial embedding layer and a positional encoding layer are used for feature space mapping and positional information injection;
[0081] N cascaded downsampling modules (N≥3), each module containing: Transformer encoder path processing global temporal features, dual-path convolutional structure (including mixed precision convolutional layer, batch normalization layer and GELU activation function), max pooling layer to halve sequence length, channel adjustment layer to fuse dual-path output features, and fusion mechanism to fuse encoder output with convolutional path features;
[0082] The feature aggregation decoder layer uses learnable query vectors to generate sample-level feature representations; the classification head layer outputs the probability distribution of the leakage state.
[0083] Step 4: Train the model using the cross-entropy loss function and NAdam optimizer, implement a mixed precision training and gradient pruning strategy, and use a dynamic learning rate adjustment mechanism to accelerate convergence;
[0084] Step 5: Use the trained model to identify the leakage status of real-time pipeline signals, and output multi-dimensional evaluation indicators and confusion matrix visualization results. The multi-dimensional evaluation indicators include accuracy, F1 score and precision.
[0085] It includes visualization of the training process, generating gradient change curves, loss descent curves, and confusion matrix heatmaps.
[0086] The data acquisition and standardized storage described in step 1 are specifically implemented as follows:
[0087] (1) The raw signal acquired by the sensor is first subjected to anti-aliasing filtering, and its frequency band range is limited as follows:
[0088]
[0089] in The sampling frequency;
[0090] (2) The filtered signal is normalized in dimensions and stored in segments, with the storage format satisfying:
[0091]
[0092] in and The mean and standard deviation are for each channel.
[0093] The standardization preprocessing and sample construction described in step 2 are specifically implemented as follows:
[0094] (1) Z-score normalization of the stored signal:
[0095]
[0096] in It is a numerically stable term;
[0097] (2) The sliding window sample generation rule satisfies:
[0098]
[0099] Where L is the window length, Δ is the sliding step size, and each sample is associated with its corresponding pipeline condition label y∈{0,1,2}, where 0 represents normal, 1 represents a small leak, and 2 represents a large leak.
[0100] Step 3 includes a data type adaptive mechanism, specifically implemented as follows: before performing convolution calculations, the data types of the convolution kernel weights and biases are automatically adjusted to be consistent with the input tensor; both zero-padding and non-zero-padding modes are supported, and the calculation process satisfies:
[0101] (1)
[0103] The kernel weights and biases are converted to ensure they are consistent with the input. The input is the input tensor. pad() is the padding operation function. When non-zero padding is enabled, P zero points are added to both ends of the temporal dimension of the input tensor. conv1d() is the one-dimensional convolution operation function.
[0104] The downsampling module in step 3 adopts a dual-path fusion architecture, simultaneously constructing a Transformer encoder path and a convolutional downsampling path; the feature fusion formula is used to achieve additive connection: Output = F_encoder + F_conv, where F_encoder is the output feature of the Transformer encoder and F_conv is the output feature of the convolutional path; a channel adjustment layer is used to ensure that the feature dimensions of the two paths match; and a max pooling layer is used to halve the sequence length and extract features.
[0105] The feature aggregation decoder described in step 3 includes: learnable query vector parameters that expand the matching batch dimension through repetition; a multi-layer Transformer structure, each layer including: a multi-head self-attention mechanism (number of heads ≥ 2), a feedforward neural network (dimension expansion coefficient ≥ 4), additive connections and layer normalization; and a feature compression layer that converts the sequence dimension output into a sample-level feature vector.
[0106] The multi-level DTBM model parameters in step 3 are configured as follows: number of basic channels: 4-16 channels; number of downsampling modules: 3-5 levels; number of Transformer heads: 2-4 heads; number of classification categories: 3 categories, including normal, small leakage, and large leakage.
[0107] The training process for the model described in step 4 includes: employing a mixed-precision training mechanism, implementing half-precision computation through an autocast context manager, and managing loss scaling through GradScaler; implementing a dual gradient clipping strategy: gradient norm clipping (clip_grad_norm) with a threshold of 0.5-1.0, and gradient value clipping (clip_grad_value) with a limit of 0.5; applying dynamic learning rate adjustment using the ReduceLROnPlateau scheduler with the following parameters: monitoring metrics: validation set loss, decay factor: 0.1-0.5, patience: 3-10 epochs; and implementing gradient statistics monitoring, calculating and recording the gradient mean and L2 norm in real time.
[0108] The evaluation metrics mentioned in step 5 include: global recall rate. Where: TP is the number of correctly predicted cases across all categories, FN is the sum of the number of false negatives across all categories; false positive rate ,in: The number of normal samples misclassified as faulty The number of correctly identified normal samples is calculated; a normalized confusion matrix is generated and visualized using a heatmap.
[0109] Example:
[0110] The following is in conjunction with the appendix Figure 1-5 The present invention will be specifically described in conjunction with the embodiments.
[0111] Hardware and environment configuration:
[0112] Use servers or edge computing devices equipped with NVIDIA GPUs for model training and inference. Install deep learning frameworks and dependencies such as PyTorch 1.9+ and CUDA 11+.
[0113] Data preparation:
[0114] Acoustic vibration signal data were collected from multiple pipeline monitoring points. Standardization, filtering, and sliding window segmentation were performed (e.g., window length 1024, step size 100). Finally, 3000 samples were divided into a training set (1800), a validation set (600), and a test set (600) in a 6:2:2 ratio.
[0115] Model training:
[0116] Initialize the DTBM model with the following parameters: num_modules=5, input_dim=1, base_channels=4, nhead=2, num_classes=3. Use the NAdam optimizer (lr =0.001, betas=(0.85, 0.99)) and cross-entropy loss function. Enable mixed-precision training and set the gradient clipping parameters. In the training loop, evaluate the performance on the validation set after each epoch and dynamically adjust the learning rate based on the validation loss. After approximately 100 epochs of training, save the model parameters that yield the best validation performance.
[0117] Model Deployment and Inference:
[0118] The trained model is integrated into the data analysis module of the pipeline monitoring system. The system reads sensor data in real-time or near real-time, preprocesses it, and then inputs it into the model for inference. It outputs leak classification results and model confidence scores. When a leak is detected, it triggers an alarm system and records event details (time, location, leak level, etc.).
[0119] Effect verification:
[0120] The model was finally evaluated on the reserved test set, and various performance metrics were calculated. This method achieved an accuracy of 99.94% and an F1 score of 99.94% on the test set, with both precision and recall at 99.94% and a false positive rate as low as 0.04%. Its overall performance significantly outperformed traditional detection methods and standard deep learning models. (Appendix) Figure 3 , 4 Figure 5 shows the visualization results of the training process and the final performance, demonstrating the effectiveness and stability of the method.
[0121] Verification has shown that the method proposed in this invention solves the technical problem raised in this invention. Simulation experiments and practical applications have verified the technical effects and practicality claimed in this invention.
[0122] The oil and gas pipeline leakage detection method (algorithm) based on the improved DTBM architecture proposed in this invention is the underlying technical core of this invention, and various products can be derived based on the algorithm.
[0123] Based on the method proposed in this invention, an oil and gas pipeline leakage detection system based on an improved DTBM architecture is developed using a programming language. This system has program modules corresponding to the steps of the above-mentioned technical solution, and executes the steps in the above-mentioned oil and gas pipeline leakage detection method based on the improved DTBM architecture when running.
[0124] The developed system (software) computer program is stored on a computer-readable storage medium, and the computer program is configured to implement the steps of the above-described oil and gas pipeline leak detection method based on the improved DTBM architecture when called by a processor. In other words, the invention is materialized on a carrier, becoming a computer program product.
[0125] Various implementations of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, application-specific integrated circuits (ASICs), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include: implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0126] The computational programs (also referred to as programs, software, software applications, or code) of this invention include machine instructions of a programmable processor and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or apparatus (e.g., disk, optical disk, memory, programmable logic device PLD) for providing machine instructions and / or data to a programmable processor, including machine-readable media that receive machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0127] While the present invention has been disclosed above, its scope of protection is not limited thereto. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention, and all such changes and modifications will fall within the scope of protection of the present invention.
Claims
1. A method for oil and gas pipeline leak detection based on improved DTBM architecture, characterized in that, The method comprises the following steps: Step 1, signal acquisition and standardized storage: collecting pipeline acoustic signals through acoustic sensors arranged at key nodes of the oil and gas pipeline, transmitting the signals into a detection system in real time, and performing standardized storage; Step 2, data preprocessing and sample construction: performing standardized preprocessing on the collected time series signals, and constructing training samples and test samples with time series correlation through a sliding window method; Step 3, building a multi-level DTBM detection model, which comprises: An initial embedding layer and a position encoding layer for feature space mapping and position information injection; N cascaded multi-branch convolution modules, N ≥ 3, each multi-branch convolution module comprising two parallel paths: A Transformer encoder path for processing global time series features; An adaptive convolution path comprising an adaptive type convolution layer 1 and an adaptive type convolution layer 2, the adaptive type convolution layer 1 comprising an adaptive type one-dimensional convolution layer, a batch normalization layer, a GELU activation function, and a maximum pooling layer for realizing sequence length reduction by half; the adaptive type convolution layer 2 comprising an adaptive type one-dimensional convolution layer, a batch normalization layer, and a GELU activation function; A data fusion layer that fuses the output features of the two paths, the fusion mechanism of the data fusion layer fusing the features output by the Transformer encoder path and the adaptive convolution path; A feature aggregation decoder layer that generates sample-level feature representations using a learnable query vector; A classification layer for outputting a leakage state probability distribution; Step 4, model training and optimization: training the model using a cross-entropy loss function and an NAdam optimizer, implementing mixed precision training and gradient clipping strategies, and adopting a dynamic learning rate adjustment mechanism to accelerate convergence; Step 5, leakage identification and result visualization: using the trained model to identify the leakage state of real-time pipeline signals, outputting multi-dimensional evaluation indicators including accuracy, F1 score, and precision; providing training process visualization, including loss reduction curve and accuracy convergence curve; and providing result visualization, including confusion matrix and T-Sne dimension reduction visualization.
2. The method of claim 1, wherein: The signal acquisition and standardized storage in step 1 are specifically implemented as follows: (1) The original signals collected by the sensors are first subjected to anti-aliasing filtering, with the frequency band range limited to: wherein is the sampling frequency; (2) The filtered signals are subjected to dimension normalization and segmented storage, with the storage format satisfying: wherein and are the channel level mean and standard deviation.
3. The method of claim 1 or 2, wherein: The data preprocessing and sample construction in step 2 are specifically implemented as follows: (1) The stored signals are subjected to Z-score standardization: wherein is a numerical stability term; (2) The sliding window sample generation rule satisfies: Where L is the window length, Δ is the sliding step, and each sample is associated with its corresponding pipeline operating condition label y ∈ {0, 1, 2}, 0 representing normal, 1 representing small leakage, and 2 representing large leakage.
4. The method of claim 3, wherein: The data type self-adapting mechanism adopted by the adaptive type one-dimensional convolution layer described in step 3 is as follows: before performing the convolution calculation, the data type of the convolution kernel weight and the bias is automatically adjusted to be consistent with the input tensor; two modes of zero padding and non-zero padding are supported, and the padding mode is determined according to the input tensor size and the kernel size (1) Where the convolution kernel weight weight and the bias bias are subjected to data type conversion to ensure consistency with the input, the input is an input tensor, the pad() is a padding operation function, when non-zero padding is enabled, P zero value points are added at both ends of the input tensor time series dimension, and the conv1d() is a one-dimensional convolution operation function.
5. The method of claim 1 or 4, wherein: The multi-branch convolution module in step 3 adopts a dual-path fusion architecture, simultaneously constructing a Transformer encoder path and a convolution downsampling path; the addition connection is realized through a feature fusion formula: Output = F_encoder + F_conv, where F_encoder is the Transformer encoder output feature, and F_conv is the convolution path output feature; a channel adjustment layer is used to ensure that the feature dimensions of the dual paths match; the sequence length is halved and the features are extracted through a max-pooling layer.
6. The method of detecting a leak in an oil and gas pipeline of claim 5, wherein: The feature aggregation decoder layer in step 3 includes: a learnable query vector parameter that matches the batch dimension by repeated expansion; a multi-layer Transformer structure, each layer including: a multi-head self-attention mechanism with a head number ≥ 2, a feedforward neural network with a dimension expansion coefficient ≥ 4, an addition connection, and layer normalization; a feature compression layer that converts the sequence dimension output into a sample-level feature vector; the multi-level DTBM detection model parameter configuration in step 3 is: the basic channel number: 4-16 channels; the number of downsampling modules: 3-5 levels; the number of Transformer heads: 2-4 heads; the number of classification categories: 3, including normal, small leakage, and large leakage.
7. The method of detecting a leak in an oil and gas pipeline of claim 6, wherein: The training process in step 4 includes: using a mixed precision training mechanism, implementing half-precision calculation through an autocast context manager, and loss scaling management through GradScaler; implementing a dual gradient clipping strategy: gradient norm clipping clip_grad_norm, threshold set to 0.5-1.0, gradient value clipping clip_grad_value, clipping value set to 0.5; applying dynamic learning rate adjustment, using ReduceLROnPlateau scheduler, with parameters set to: monitoring indicator: validation set loss, decay factor: 0.1-0.5, patience: 3-10 epochs; implementing gradient statistical monitoring, real-time calculation and recording of gradient mean and L2 norm.
8. The method of claim 1 or 7, wherein: The evaluation indicators described in step 5 include: global recall rate Wherein: TP is the number of correct predictions of all categories, FN is the sum of missed detections of all categories; false positive rate Wherein: is the number of misjudgments of normal samples as failures, is the number of correctly identified normal samples; generate a normalized confusion matrix and visualize it with a heat map.
9. A leak detection system for oil and gas pipelines based on an improved DTBM architecture, characterized by: The system has program modules corresponding to the steps of the method of any one of claims 1-8, and when running, executes the steps of the oil and gas pipeline leakage detection method based on the improved DTBM architecture.
10. An oil and gas pipeline leak detection apparatus characterized by: The oil and gas pipeline leakage detection device includes: an acoustic sensor array arranged at a pipeline pressure mutation node, at least one processor, and a memory in communication connection with the at least one processor, the acoustic sensor array sending monitored oil and gas pipeline leakage data to the processor; The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the oil and gas pipeline leakage detection method based on the improved DTBM architecture of any one of claims 1-8, thereby realizing signal preprocessing and sample construction, DTBM detection model building, model training, real-time analysis and output of pipeline state classification results and confidence atlas.
Citation Information
Patent Citations
A method for leak detection and location in long-distance oil and gas pipelines using acoustic vector sensors
CN112857699B
Oil and gas pipeline leakage monitoring method based on SCADA
CN120448793A