Pipe network leakage detection method and device, electronic equipment and medium
Through time-domain mean smooth filtering and differential processing, combined with wavelet transformation and self-attention neural network, the problem of traditional time-domain signal processing is solved, and efficient and accurate detection of pipeline leakage is achieved.
Patent Information
- Application Number
- CN202411138108.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-13
AI Technical Summary
The existing pipeline leakage detection method is based on traditional time domain signal processing and is susceptible to interference noise, the effect is not robust enough and the operation is complicated.
Time-domain mean smoothing filtering, first-order differential and second-order differential preprocessing pressure signals, combined with wavelet transformation, the signal is converted to the time-frequency domain, and a lightweight neural network with added self-attention mechanism is used for feature extraction and abnormal classification.
Effectively reduce noise interference, highlight signal change trends, improve the accuracy and generalization ability of leakage feature recognition, and achieve accurate detection of pipeline leakage.
Smart Images

Figure CN119123333A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of fault diagnosis, and in particular to a pipeline network leakage detection method, device, electronic equipment and medium. Background Art
[0002] In order to effectively prevent pipeline accidents, pipeline leakage detection technology has developed rapidly. The methods for pipeline leakage detection based on pipeline pressure data are generally divided into two categories: detection methods based on negative pressure waves and methods for feature extraction of pressure signals. Among them, the key to the detection method based on negative pressure waves is to determine the turning point of the pressure signal and the moment when the negative pressure wave passes through the upstream and downstream measurement points; the method for feature extraction of pressure signals is mostly to analyze the data of the pressure change over time at a certain point.
[0003] However, the related technologies are all based on traditional time domain signal processing, which is easily affected by interference noise signals, is not robust enough, and is complex to operate. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a pipeline network leakage detection method, device, electronic equipment and medium. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a pipeline network leakage detection method is provided, comprising:
[0006] Obtaining the pressure signal collected by the pressure sensor on the pipeline within a preset time;
[0007] Preprocessing the collected pressure signal to obtain a preprocessed pressure signal, the preprocessing including: time domain mean smoothing filtering, first-order difference and second-order difference; the smoothing window of the smoothing filter is adapted to the difference unit;
[0008] Performing wavelet transformation on the preprocessed pressure signal to obtain a two-dimensional image in the time-frequency domain; the two-dimensional image in the time-frequency domain expresses the time-frequency domain information of the pressure signal;
[0009] Inputting the time-frequency domain two-dimensional image into a target neural network; the target neural network is a lightweight neural network with a self-attention mechanism added;
[0010] Performing feature extraction on the time-frequency domain two-dimensional image by using the target neural network;
[0011] According to the characteristics of the two-dimensional image in the time-frequency domain, the two-dimensional image in the time-frequency domain is classified as abnormal;
[0012] According to the abnormal classification of the pressure signal, it is determined whether the pipe network is leaking.
[0013] Optionally, performing wavelet transform on the preprocessed pressure signal to obtain a two-dimensional image in the time-frequency domain includes:
[0014] Selecting a preset number of frequency scales within a preset frequency range, and determining the selected frequency scales as wavelet scales for wavelet transformation;
[0015] According to the wavelet scale, using a target wavelet to perform a wavelet transform on the preprocessed pressure signal to obtain a wavelet coefficient;
[0016] Taking the absolute value of the wavelet coefficients and rendering to obtain a two-dimensional image;
[0017] The two-dimensional image is scaled to a preset scale, and the scaled two-dimensional image is determined as the time-frequency domain two-dimensional image.
[0018] Optionally, extracting features from the time-frequency domain two-dimensional image by using the target neural network includes:
[0019] Performing feature extraction of a preset scale on the time-frequency domain two-dimensional image to obtain a feature map of the preset scale;
[0020] The step of classifying the time-frequency domain two-dimensional image for abnormality according to the features of the time-frequency domain two-dimensional image comprises:
[0021] Performing a self-attention operation on the feature map to obtain a two-dimensional vector corresponding to the two-dimensional image in the time-frequency domain;
[0022] The two-dimensional vector is adjusted again to obtain a one-dimensional vector, and the one-dimensional vector is input into a fully connected layer for abnormal classification.
[0023] Optionally, performing a first-order difference and a second-order difference on the pressure signal includes:
[0024] Determine a first data point in the pressure signal; the first data point is data collected by the pressure sensor at a target time;
[0025] Determine a second data point separated from the first data point by a differential unit; the differential unit represents the time interval between the collection of the first data point and the second data point;
[0026] Subtracting the first data point from the second data point completes the first-order difference of the pressure signal; wherein the first-order difference result of the pressure signal represents the flow rate of the pressure signal;
[0027] The second-order difference result of the first-order difference of the pressure signal is performed again to obtain the pressure signal after the second-order difference; the differential unit of the second-order difference is the same as the differential unit of the first-order difference; wherein the second-order difference result of the pressure signal represents the acceleration of the pressure signal, and when there is no leakage in the pipeline network, the acceleration is zero.
[0028] Optionally, the target neural network training step includes:
[0029] Acquire a preset number of leakage pressure signals that last for a preset time, and add sample labels that characterize leakage to the leakage pressure signals;
[0030] Acquire a preset number of non-leakage pressure signals that last for a preset time, and add sample labels indicating no leakage to the leakage pressure signals;
[0031] Determine the leakage pressure signal and the no-leakage pressure signal as a sample set; divide the sample set into a training sample set and a test sample set;
[0032] Alternately inputting the leakage pressure signal and the non-leakage pressure signal in the training sample set into the initial neural network to obtain the prediction classification result of the training sample; the initial neural network is a lightweight neural network with a self-attention mechanism added, and has a signal detection function;
[0033] The loss value between the predicted classification result and the sample label is determined by a loss function, and the network parameters of the initial neural network are adjusted based on the loss value to obtain a target neural network; the loss value represents: the gap between the classification of the training sample predicted by the initial neural network and the sample label of the training sample;
[0034] After the target neural network training is completed, inputting the test sample set into the target neural network;
[0035] The loss value of the test sample set is obtained, and when the loss value is less than a preset value, it is determined that the training of the target neural network is completed.
[0036] According to a second aspect of an embodiment of the present disclosure, a pipe network leakage detection device is provided, comprising:
[0037] An acquisition module is used to acquire a pressure signal collected by a pressure sensor on the pipeline within a preset time;
[0038] A preprocessing module is used to preprocess the collected pressure signal to obtain a preprocessed pressure signal, wherein the preprocessing includes: time domain mean smoothing filtering, first-order difference and second-order difference; the smoothing window of the smoothing filter is adapted to the difference unit;
[0039] A wavelet transform module is used to perform wavelet transform on the preprocessed pressure signal to obtain a two-dimensional image in the time-frequency domain; the two-dimensional image in the time-frequency domain expresses the time-frequency domain information of the pressure signal;
[0040] An input module, used for inputting the time-frequency domain two-dimensional image into a target neural network; the target neural network is a lightweight neural network with a self-attention mechanism added;
[0041] An extraction module, used for performing feature extraction on the time-frequency domain two-dimensional image through the target neural network;
[0042] A classification module, used for classifying the time-frequency domain two-dimensional image for abnormality according to the characteristics of the time-frequency domain two-dimensional image;
[0043] The determination module is used to determine whether the pipe network is leaking according to the abnormal classification of the pressure signal.
[0044] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the pipeline leakage detection method described in the first aspect are implemented.
[0045] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the pipeline leakage detection method described in the first aspect are implemented.
[0046] The present invention can effectively reduce the influence of interference noise by processing pressure signals through time domain mean smoothing filtering, first-order difference and second-order difference; smoothing filtering can smooth high-frequency noise in the pressure signal, and differential operation can highlight the change trend of the pressure signal; wavelet transform is performed on the pre-processed pressure signal to decompose the signal into different frequency components, and the signal is represented in the time-frequency domain, which can capture the time-varying characteristics in the signal and help to identify abnormal patterns related to pipeline leakage; the time-frequency domain two-dimensional image is input into the target neural network, and the target neural network can adaptively focus on important areas in the input image without manual labeling; the target neural network extracts features and classifies abnormalities of the time-frequency domain two-dimensional image, which helps to accurately identify abnormal patterns related to pipeline leakage. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the description of the embodiments of the present disclosure will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0048] Figure 1 is a schematic diagram of the steps of a pipe network leakage detection method shown in an embodiment of the present disclosure;
[0049] Figure 2 is a flow chart of a pipe network leakage detection shown in an embodiment of the present disclosure;
[0050] Figure 3 is a block diagram of a pipe network leakage detection device shown in an embodiment of the present disclosure;
[0051] Figure 4 is a schematic diagram of an electronic device shown in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0053] The terms "first", "second", etc. in the specification and claims of the present disclosure are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of the present disclosure can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0054] Preventing pipeline production accidents is a very important task in pipeline safety management. With the rapid development of pipeline construction in countries around the world, pipeline accidents also occur frequently. Once a pipeline leakage accident occurs, it will not only cause a large amount of property losses, but the leaked toxic or flammable chemicals will also cause environmental pollution and waste of resources. What is more serious is that it can cause personal injury and death.
[0055] In order to effectively prevent pipeline accidents, related technologies have proposed pipeline leakage detection methods based on time domain signals. Some use the traditional method of pressure drop gradient threshold for detection, and some use methods based on BP neural network to count some manual features of the signal, such as maximum value, minimum value, mean value, etc., and then send them to the neural network for classification; specifically, first filter the input pressure signal within a certain period of time; then extract manual features, such as maximum value, minimum value, mean value, etc. from the filtered time domain signal; finally use BP neural network for classification.
[0056] However, the related technologies all analyze whether the pipe network is leaking based on time domain signals. In view of this, the present invention proposes a time-frequency domain pipe network leakage detection method based on the combination of wavelet transform and neural network.
[0057] Figure 1 Schematic diagram of a method for detecting leakage in a pipe network according to an embodiment of the present disclosure. Figure 1 As shown, the pipeline network leakage detection method may specifically include the following steps:
[0058] Step S11: obtaining a pressure signal collected by a pressure sensor on the pipeline within a preset time;
[0059] Set up pressure sensors on the pipeline to collect pressure data periodically or continuously. Set the time interval and duration of data collection to ensure that enough data is collected for subsequent analysis. Obtain pressure signal data from the pressure sensor in real time and store it in an appropriate storage medium.
[0060] Step S12: preprocessing the collected pressure signal to obtain a preprocessed pressure signal, wherein the preprocessing includes: time domain mean smoothing filtering, first-order difference and second-order difference; the smoothing window of the smoothing filtering is adapted to the difference unit;
[0061] Select an appropriate smoothing window size and perform time domain mean smoothing filtering on the pressure signal to remove random noise in the signal. Calculate the first-order difference of the pressure signal to highlight the changing part of the signal. Further calculate the second-order difference of the signal after the first-order difference to enhance the mutation point in the signal.
[0062] Step S13: performing wavelet transform on the preprocessed pressure signal to obtain a two-dimensional image in the time-frequency domain; the two-dimensional image in the time-frequency domain expresses the time-frequency domain information of the pressure signal;
[0063] Select appropriate wavelet basis functions and decomposition levels. Perform wavelet transform on the preprocessed pressure signal to obtain its representation in the time-frequency domain. Convert the result of wavelet transform into a two-dimensional image for subsequent processing.
[0064] Step S14: inputting the time-frequency domain two-dimensional image into a target neural network; the target neural network is a lightweight neural network with a self-attention mechanism added;
[0065] Build a lightweight neural network model with a self-attention mechanism. Input the two-dimensional image in the time-frequency domain as input data into the neural network.
[0066] Step S15: extracting features of the two-dimensional image in the time-frequency domain through the target neural network;
[0067] The convolutional layer and pooling layer of the neural network are used to extract features from the image. The self-attention mechanism helps the network pay more attention to the key features in the image.
[0068] Step S16: classifying the time-frequency domain two-dimensional image for abnormality according to the features of the time-frequency domain two-dimensional image;
[0069] Multiple categories are set in the output layer of the neural network, corresponding to different types of anomalies (including leakage). Based on the extracted features, the images are classified into corresponding anomaly categories.
[0070] Step S17: Determine whether the pipe network is leaking based on the abnormal classification of the pressure signal.
[0071] If the image is classified as a leak category, it is judged that there is a leak in the pipe network. If the image is classified as other categories (such as normal, noise, etc.), it is judged that there is no leak in the pipe network. According to the classification results, appropriate measures are taken to maintain and repair the pipe network.
[0072] By adopting the embodiments of the present disclosure, through preprocessing steps such as time domain mean smoothing filtering, first-order difference and second-order difference, the noise and interference in the pressure signal are effectively removed, the key features in the signal are highlighted, and high-quality input data is provided for subsequent wavelet transform and neural network analysis. The wavelet transform converts the preprocessed pressure signal to the time-frequency domain to generate a two-dimensional image. This conversion allows the time-frequency domain information of the signal to be fully expressed, which helps the neural network to more accurately capture and identify leakage features. The neural network can extract the common leakage features in the pressure signal through learning a large number of samples, so that the method has a certain generalization ability for different types of pipe networks and leakage situations. The introduction of the self-attention mechanism enables the neural network to focus on key features more flexibly when processing pressure signals of different lengths, further improving the generalization performance of the method.
[0073] Among them, in an optional embodiment, the wavelet transform is performed on the preprocessed pressure signal to obtain a two-dimensional image in the time-frequency domain, including: selecting a preset number of frequency scales within a preset frequency range, and determining the selected frequency scale as the wavelet scale of the wavelet transform; according to the wavelet scale, using a target wavelet to perform a wavelet transform on the preprocessed pressure signal to obtain wavelet coefficients; taking the absolute value of the wavelet coefficients and rendering to obtain a two-dimensional image; scaling the two-dimensional image to a preset scale, and determining the scaled two-dimensional image as the two-dimensional image in the time-frequency domain.
[0074] According to the characteristics of the pipeline system and monitoring requirements, determine a suitable frequency range that should be able to cover the signal characteristics that may cause leakage. Within the preset frequency range, select a certain number of frequency scales as the wavelet scale of the wavelet transform. The wavelet scale is based on the characteristics of the wavelet basis function to ensure that the characteristics of the signal at different frequencies can be fully captured. According to the signal characteristics and analysis requirements, select a suitable wavelet basis function as the target wavelet, such as MorLet wavelet. Use the selected wavelet basis function and the previously determined frequency scale to perform wavelet transform on the preprocessed pressure signal. Specifically, through multi-level decomposition, the signal is converted from the time domain to the time-frequency domain and the corresponding wavelet coefficients are generated. Take the absolute value of the wavelet coefficient to obtain the amplitude information of the signal. Map the wavelet coefficient after taking the absolute value to a two-dimensional plane, and represent the size of the coefficient by the change of color or grayscale, so as to generate a two-dimensional image in the time-frequency domain. Determine a preset image scale according to the display or analysis requirements. Scale the generated two-dimensional image to a preset scale to ensure the consistency and readability of the image in different environments.
[0075] For example, the MorLet wavelet is used to perform wavelet transform on the pressure signal after the second-order difference. 200 wavelet scales are selected from 0 to 1000 Hz. The absolute value of the wavelet transform coefficient (dimension is 200*20000) is taken, and then rendered into a two-dimensional image. The image size is uniformly scaled to 224*1024*3.
[0076] By using the embodiments of the present disclosure, the pressure signal can be converted from a single time domain to a time-frequency domain through wavelet transform, so that the characteristics of the signal at different times and frequencies can be clearly displayed on a two-dimensional image. This high-resolution analysis helps to identify leakage signals more accurately. The wavelet transform itself also has a certain noise suppression capability, which can significantly improve the signal-to-noise ratio and make the leakage signal more prominent. The generated two-dimensional image in the time-frequency domain displays the characteristics of the signal in an intuitive way, which is convenient for subsequent feature extraction and anomaly classification. By selecting different wavelet basis functions and frequency scales, the method can flexibly adapt to different types of pipeline systems and monitoring needs.
[0077] Among them, in an optional embodiment, the feature extraction of the time-frequency domain two-dimensional image through the target neural network includes: performing feature extraction of a preset scale on the time-frequency domain two-dimensional image to obtain a feature map of a preset scale; the abnormality classification of the time-frequency domain two-dimensional image according to the features of the time-frequency domain two-dimensional image includes: performing a self-attention operation on the feature map to obtain a two-dimensional vector corresponding to the time-frequency domain two-dimensional image; adjusting the two-dimensional vector again to obtain a one-dimensional vector, and inputting the one-dimensional vector into a fully connected layer for abnormality classification.
[0078] The two-dimensional image in the time-frequency domain is input into the target neural network, and through multiple layers of convolution and pooling operations, the resolution of the image is gradually reduced and multi-scale features are extracted. Multiple convolution layers are applied to extract feature maps at different levels to capture local features of different sizes. Each layer of convolution kernel learns features in the image, such as edges, textures, or shapes. Through pooling layers, such as maximum pooling or average pooling, the feature map is downsampled to reduce the spatial dimension of the image while retaining the main features. In different convolution layers or multi-scale processing, feature maps of different scales are extracted, which reflect the information of the pressure signal at different scales.
[0079] The importance of each feature position is calculated using the self-attention mechanism. By calculating the attention weight of the feature map, the dependencies between different positions in the feature map can be captured, thereby improving the ability of feature representation. The self-attention mechanism can adjust the information in the feature map according to the attention weight, thereby highlighting important features and suppressing irrelevant parts. The adjusted feature map is converted into a two-dimensional vector, which contains the dependencies between the global features and local features of the image.
[0080] Adjust the two-dimensional vector to a one-dimensional vector. Input the one-dimensional vector to the fully connected layer for processing. The fully connected layer maps the one-dimensional vector to the classification space and generates the final output for classification. After the fully connected layer, the final classification probability distribution is obtained.
[0081] Specifically, 224*1024*3 is sent to the lightweight mobilenetv3 network, the feature F after strie=32 is taken to be 7*32*512, and then a selfAttention operation is performed on F (7*32*512 is reshaped into 224*512, that is, selfAttention is performed on 224 512 features) to obtain the feature F1 (a two-dimensional vector with a dimension of 224*512), and then F1 is reshaped again to be converted into a one-dimensional vector, and then an MLP fully connected layer is added for leakage prediction.
[0082] Using the embodiments of the present disclosure, through convolutional layers and pooling layers, the model can learn fine-grained time-frequency features from two-dimensional images in the time-frequency domain. The self-attention mechanism can dynamically adjust the information in the feature map, enhance the focus on important features, and improve classification performance. Through the fully connected layer and appropriate activation function, the model can map complex feature vectors to specific anomaly categories, achieving efficient and accurate anomaly detection.
[0083] In one optional embodiment, the pressure signal is subjected to first-order differential and second-order differential, including: determining a first data point in the pressure signal; the first data point is the data collected by the pressure sensor at the target time; determining a second data point separated from the first data point by a differential unit; the differential unit represents the time interval between the collection of the first data point and the second data point; the second data point is subtracted from the first data point to complete the first-order differential of the pressure signal; wherein the first-order differential result of the pressure signal represents the flow rate of the pressure signal; the second-order differential result of the pressure signal is subjected to the second-order differential again to obtain the pressure signal after the second-order differential; the differential unit of the second-order differential is the same as the differential unit of the first-order differential; wherein the second-order differential result of the pressure signal represents the acceleration of the pressure signal, and when there is no leakage in the pipeline network, the acceleration is zero.
[0084] In the pressure signal sequence, the target time is clearly defined, and the data collected by the pressure sensor at this time point is determined as the first data point. This data point represents the pressure value at a certain moment. The differential unit refers to the time interval between the collection of the first data point and the second data point. This time interval can be fixed (such as per second, per minute, etc.) or dynamically adjusted, depending on the analysis requirements and the frequency of data collection. According to the differential unit, the second data point with a corresponding time interval with the first data point is found in the pressure signal sequence. This data point represents the pressure value after a certain time interval.
[0085] The pressure value of the second data point is subtracted from the pressure value of the first data point, and the result obtained is the result of the first-order difference. This result characterizes the flow rate of the pressure signal during this period of time, that is, the rate of pressure change.
[0086] The result of the first-order difference is used as a new data sequence, and the above steps of the first-order difference are repeated, that is, the second-order difference is performed. Determine the difference unit in the new data sequence, find the next data point with a corresponding time interval from the current data point, and perform a subtraction operation. The difference unit of the second-order difference should be the same as that of the first-order difference to maintain the consistency of the analysis. The result is the pressure signal after the second-order difference, which characterizes the acceleration of the pressure signal, that is, the rate of pressure change rate.
[0087] When there is no abnormality such as leakage in the pipeline network, the acceleration of the pressure signal (i.e., the second-order difference result) should theoretically be zero or close to zero. Therefore, the second-order difference result can be used to detect abnormal changes in the pipeline network, such as leakage.
[0088] Specifically, the original pressure signal is obtained. The original pressure signal has a time of 20s, a sampling rate of 1k, and 20,000 data points. The original pressure signal is subjected to time domain mean smoothing filtering, and the smoothing window is set to 1s. Then, the smoothed signal is subjected to first-order and second-order differentials with a unit time of 1s. The second-order differential is another differential operation on the first-order differential signal. For example, the data after 1s is subtracted from the current data for each sample as the differential result, such as the value of the 1001th point minus the data of the 1st point as the differential result of the 1001th point. The function of the first-order differential and the second-order differential is to amplify the leakage signal. Among them, both smoothing and differential operations use tiling to ensure that the data length remains unchanged.
[0089] Using the embodiments of the present disclosure, the first-order difference can reveal the changing trend of the pressure signal over time, which helps to discover the fluctuations and mutation points of the pressure signal. The first-order difference can smooth the random noise in the signal, making the changing trend of the signal more obvious. The second-order difference can further reveal the acceleration of the pressure signal change, which helps to more accurately analyze the dynamic characteristics of the pressure signal. The process of performing first-order and second-order differences on the pressure signal can deeply reveal the changing trend and dynamic characteristics of the pressure signal, providing strong support for pipeline network monitoring, fault diagnosis, etc.
[0090] Wherein, in an optional embodiment, the training step of the target neural network includes: obtaining a preset number of leakage pressure signals that last for a preset time, and adding a sample label representing leakage to the leakage pressure signal; obtaining a preset number of non-leakage pressure signals that last for a preset time, and adding a sample label representing non-leakage to the leakage pressure signal; determining the leakage pressure signal and the non-leakage pressure signal as a sample set; dividing the sample set into a training sample set and a test sample set; alternately inputting the leakage pressure signal and the non-leakage pressure signal in the training sample set into the initial neural network to obtain the predicted classification result of the training sample; the initial neural network is a lightweight neural network with a self-attention mechanism added, and has a signal detection function; determining the loss value between the predicted classification result and the sample label through a loss function, and adjusting the network parameters of the initial neural network based on the loss value to obtain the target neural network; the loss value represents: the gap between the classification of the training sample predicted by the initial neural network and the sample label of the training sample; after the training of the target neural network is completed, inputting the test sample set into the target neural network; obtaining the loss value of the test sample set, and determining that the training of the target neural network is completed when the loss value is less than a preset value.
[0091] A sufficient number of leakage pressure signals and no-leakage pressure signals are obtained, the leakage pressure signals and the no-leakage pressure signals have the same preset duration, and the collected data are preprocessed to improve data quality and model training efficiency.
[0092] A sample label representing leakage is added to each leakage pressure signal, such as "1", and a sample label representing no leakage is added to each non-leakage pressure signal, such as "0". All labeled pressure signal samples are divided into a training sample set and a test sample set. The training sample set is used to train the model, while the test sample set is used to evaluate the performance of the model. The division ratio can be adjusted according to specific needs.
[0093] Design a lightweight neural network with a self-attention mechanism as the initial model. The self-attention mechanism helps the model better capture the key features in the signal, while the lightweight design can improve the computational efficiency and deployability of the model. Ensure that the neural network has the function of signal detection, that is, it can receive pressure signal input and output the corresponding classification results, such as leakage or no leakage.
[0094] The leakage pressure signal and the non-leakage pressure signal in the training sample set are alternately input into the initial neural network for training. The alternating input method helps the model to learn the characteristics of the two types of signals in a balanced manner.
[0095] In each training cycle, the loss value between the classification result predicted by the model and the sample label is calculated. The loss function is used to quantify this gap and guide the optimization direction of the model. Based on the loss value, the parameters of the neural network are adjusted to reduce the loss value and improve the classification accuracy of the model.
[0096] During the training process, the performance of the model is evaluated regularly using the test sample set, which can be achieved by calculating the loss value of the test sample set. If the loss value of the test sample set is less than the preset value, it means that the model performance has reached the expected level, and the training of the target neural network is determined to be completed. Otherwise, it may be necessary to continue training the model or adjust the network structure, parameters, etc. to improve performance.
[0097] By adopting the embodiments of the present disclosure, through the self-attention mechanism and lightweight network design, the model can more accurately capture the key features in the pressure signal, thereby improving the classification accuracy of leakage signals and non-leakage signals. Using an independent test sample set to evaluate the performance of the model helps to ensure that the model can maintain good classification results on unseen data, that is, enhance the generalization ability of the model. Through the loss function, the model can automatically learn and adjust the network parameters to adapt to the changes in the feature distribution in the training data, improving the adaptability and robustness of the model.
[0098] Figure 2This is a flow chart of a pipe network leakage detection method shown in an embodiment of the present disclosure. Figure 2 As shown, the data collected by the pressure sensor within a certain period of time is obtained to obtain the original pressure signal; the original pressure signal is preprocessed, and the preprocessing includes noise filtering, first-order difference and second-order difference; the preprocessed pressure signal is input into the improved 2dCNN network for leakage prediction; and the model is trained using the Sigmoid loss function.
[0099] Figure 3 is a block diagram of a pipe network leakage detection device shown in an embodiment of the present disclosure. Figure 3 As shown, the pipe network leakage detection device comprises:
[0100] An acquisition module 310 is used to acquire a pressure signal collected by a pressure sensor on the pipeline within a preset time;
[0101] The preprocessing module 320 is used to preprocess the collected pressure signal to obtain a preprocessed pressure signal, wherein the preprocessing includes: time domain mean smoothing filtering, first-order difference and second-order difference; the smoothing window of the smoothing filtering is adapted to the difference unit;
[0102] The wavelet transform module 330 is used to perform wavelet transform on the preprocessed pressure signal to obtain a two-dimensional image in the time-frequency domain; the two-dimensional image in the time-frequency domain expresses the time-frequency domain information of the pressure signal;
[0103] An input module 340 is used to input the time-frequency domain two-dimensional image into a target neural network; the target neural network is a lightweight neural network with a self-attention mechanism added;
[0104] An extraction module 350, configured to extract features of the time-frequency domain two-dimensional image through the target neural network;
[0105] A classification module 360, configured to classify the time-frequency domain two-dimensional image for abnormality according to the features of the time-frequency domain two-dimensional image;
[0106] The determination module 370 is used to determine whether the pipe network is leaking according to the abnormal classification of the pressure signal.
[0107] Optionally, the wavelet transform module is specifically used to perform:
[0108] Selecting a preset number of frequency scales within a preset frequency range, and determining the selected frequency scales as wavelet scales for wavelet transformation;
[0109] According to the wavelet scale, using a target wavelet to perform a wavelet transform on the preprocessed pressure signal to obtain a wavelet coefficient;
[0110] Taking the absolute value of the wavelet coefficients and rendering to obtain a two-dimensional image;
[0111] The two-dimensional image is scaled to a preset scale, and the scaled two-dimensional image is determined as the time-frequency domain two-dimensional image.
[0112] Optionally, the extraction module is specifically used to execute:
[0113] Performing feature extraction of a preset scale on the time-frequency domain two-dimensional image to obtain a feature map of the preset scale;
[0114] The classification module is specifically used to perform:
[0115] Performing a self-attention operation on the feature map to obtain a two-dimensional vector corresponding to the two-dimensional image in the time-frequency domain;
[0116] The two-dimensional vector is adjusted again to obtain a one-dimensional vector, and the one-dimensional vector is input into a fully connected layer for abnormal classification.
[0117] Optionally, the preprocessing module is specifically used to perform:
[0118] Determine a first data point in the pressure signal; the first data point is data collected by the pressure sensor at a target time;
[0119] Determine a second data point separated from the first data point by a differential unit; the differential unit represents the time interval between the collection of the first data point and the second data point;
[0120] Subtracting the first data point from the second data point completes the first-order difference of the pressure signal; wherein the first-order difference result of the pressure signal represents the flow rate of the pressure signal;
[0121] The second-order difference result of the first-order difference of the pressure signal is performed again to obtain the pressure signal after the second-order difference; the differential unit of the second-order difference is the same as the differential unit of the first-order difference; wherein the second-order difference result of the pressure signal represents the acceleration of the pressure signal, and when there is no leakage in the pipeline network, the acceleration is zero.
[0122] Optionally, the pipe network leakage detection device further includes: a model training module; the model training module is used to:
[0123] Acquire a preset number of leakage pressure signals that last for a preset time, and add sample labels that characterize leakage to the leakage pressure signals;
[0124] Acquire a preset number of non-leakage pressure signals that last for a preset time, and add sample labels indicating no leakage to the leakage pressure signals;
[0125] Determine the leakage pressure signal and the no-leakage pressure signal as a sample set; divide the sample set into a training sample set and a test sample set;
[0126] Alternately inputting the leakage pressure signal and the non-leakage pressure signal in the training sample set into the initial neural network to obtain the prediction classification result of the training sample; the initial neural network is a lightweight neural network with a self-attention mechanism added, and has a signal detection function;
[0127] The loss value between the predicted classification result and the sample label is determined by a loss function, and the network parameters of the initial neural network are adjusted based on the loss value to obtain a target neural network; the loss value represents: the gap between the classification of the training sample predicted by the initial neural network and the sample label of the training sample;
[0128] After the target neural network training is completed, inputting the test sample set into the target neural network;
[0129] The loss value of the test sample set is obtained, and when the loss value is less than a preset value, it is determined that the training of the target neural network is completed.
[0130] It should be noted that the system embodiment is similar to the method embodiment, so the description is relatively simple, and the relevant parts can be referred to the method embodiment.
[0131] The present disclosure also provides an electronic device, referring to Figure 4 , Figure 4 Schematic diagram of an electronic device shown in an embodiment of the present disclosure. Figure 4 As shown, the electronic device 400 includes: a memory 410 and a processor 420. The memory 410 and the processor 420 are connected via a bus communication. A computer program is stored in the memory 410. The computer program can be run on the processor 420 to implement the steps in the pipeline leakage detection method disclosed in the embodiment of the present disclosure.
[0132] The embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the pipe network leakage detection method disclosed in the embodiment of the present disclosure are implemented.
[0133] The embodiment of the present disclosure also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the pipeline leakage detection method described in the first aspect.
[0134] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0135] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, devices or computer program products. Therefore, the embodiments of the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0136] The embodiments of the present disclosure are described with reference to the flowcharts and / or block diagrams of the methods, apparatuses, electronic devices, and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0137] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0139] Although some embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiment and all changes and modifications that fall within the scope of the present disclosure.
[0140] The above is a detailed introduction to a pipe network leakage detection method, device, electronic device and storage medium provided by the present disclosure. Specific examples are used in this article to illustrate the principles and implementation methods of the present disclosure. The description of the above embodiments is only used to help understand the method of the present disclosure and its core idea; at the same time, for general technical personnel in the field, according to the ideas of the present disclosure, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present disclosure.
Claims
1. A method for detecting leakage in a pipe network, characterized in that: include: Obtaining the pressure signal collected by the pressure sensor on the pipeline within a preset time; Preprocessing the collected pressure signal to obtain a preprocessed pressure signal, the preprocessing including: time domain mean smoothing filtering, first-order difference and second-order difference; the smoothing window of the smoothing filter is adapted to the difference unit; Performing wavelet transformation on the preprocessed pressure signal to obtain a two-dimensional image in the time-frequency domain; the two-dimensional image in the time-frequency domain expresses the time-frequency domain information of the pressure signal; Inputting the time-frequency domain two-dimensional image into a target neural network; the target neural network is a lightweight neural network with a self-attention mechanism added; Performing feature extraction on the time-frequency domain two-dimensional image by using the target neural network; According to the characteristics of the two-dimensional image in the time-frequency domain, the two-dimensional image in the time-frequency domain is classified as abnormal; According to the abnormal classification of the pressure signal, it is determined whether the pipe network is leaking.
2. The method according to claim 1, characterized in that: The step of performing wavelet transform on the preprocessed pressure signal to obtain a two-dimensional image in the time-frequency domain includes: Selecting a preset number of frequency scales within a preset frequency range, and determining the selected frequency scales as wavelet scales for wavelet transformation; According to the wavelet scale, using a target wavelet to perform a wavelet transform on the preprocessed pressure signal to obtain a wavelet coefficient; Taking the absolute value of the wavelet coefficients and rendering to obtain a two-dimensional image; The two-dimensional image is scaled to a preset scale, and the scaled two-dimensional image is determined as the time-frequency domain two-dimensional image.
3. The method according to claim 1, characterized in that The extracting features of the time-frequency domain two-dimensional image by the target neural network includes: Performing feature extraction of a preset scale on the time-frequency domain two-dimensional image to obtain a feature map of the preset scale; The step of classifying the time-frequency domain two-dimensional image for abnormality according to the features of the time-frequency domain two-dimensional image comprises: Performing a self-attention operation on the feature map to obtain a two-dimensional vector corresponding to the two-dimensional image in the time-frequency domain; The two-dimensional vector is adjusted again to obtain a one-dimensional vector, and the one-dimensional vector is input into a fully connected layer for abnormal classification.
4. The method according to claim 1, characterized in that: Performing a first-order difference and a second-order difference on the pressure signal includes: Determine a first data point in the pressure signal; the first data point is data collected by the pressure sensor at a target time; Determine a second data point separated from the first data point by a differential unit; the differential unit represents the time interval between the collection of the first data point and the second data point; Subtracting the first data point from the second data point completes the first-order difference of the pressure signal; wherein the first-order difference result of the pressure signal represents the flow rate of the pressure signal; The second-order difference result of the first-order difference of the pressure signal is performed again to obtain the pressure signal after the second-order difference; the differential unit of the second-order difference is the same as the differential unit of the first-order difference; wherein the second-order difference result of the pressure signal represents the acceleration of the pressure signal, and when there is no leakage in the pipeline network, the acceleration is zero.
5. The method according to claim 1, characterized in that The training steps of the target neural network include: Acquire a preset number of leakage pressure signals that last for a preset time, and add sample labels that characterize leakage to the leakage pressure signals; Acquire a preset number of non-leakage pressure signals that last for a preset time, and add sample labels indicating no leakage to the leakage pressure signals; Determine the leakage pressure signal and the no-leakage pressure signal as a sample set; divide the sample set into a training sample set and a test sample set; Alternately inputting the leakage pressure signal and the non-leakage pressure signal in the training sample set into the initial neural network to obtain the prediction classification result of the training sample; the initial neural network is a lightweight neural network with a self-attention mechanism added, and has a signal detection function; The loss value between the predicted classification result and the sample label is determined by a loss function, and the network parameters of the initial neural network are adjusted based on the loss value to obtain a target neural network; the loss value represents: the gap between the classification of the training sample predicted by the initial neural network and the sample label of the training sample; After the target neural network training is completed, inputting the test sample set into the target neural network; The loss value of the test sample set is obtained, and when the loss value is less than a preset value, it is determined that the training of the target neural network is completed.
6. A pipe network leakage detection device, characterized in that: include: An acquisition module is used to acquire a pressure signal collected by a pressure sensor on the pipeline within a preset time; A preprocessing module is used to preprocess the collected pressure signal to obtain a preprocessed pressure signal, wherein the preprocessing includes: time domain mean smoothing filtering, first-order difference and second-order difference; the smoothing window of the smoothing filter is adapted to the difference unit; A wavelet transform module is used to perform wavelet transform on the preprocessed pressure signal to obtain a two-dimensional image in the time-frequency domain; the two-dimensional image in the time-frequency domain expresses the time-frequency domain information of the pressure signal; An input module, used for inputting the time-frequency domain two-dimensional image into a target neural network; the target neural network is a lightweight neural network with a self-attention mechanism added; An extraction module, used for performing feature extraction on the time-frequency domain two-dimensional image through the target neural network; A classification module, used for classifying the time-frequency domain two-dimensional image for abnormality according to the characteristics of the time-frequency domain two-dimensional image; The determination module is used to determine whether the pipe network is leaking according to the abnormal classification of the pressure signal.
7. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the pipeline leakage detection method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the pipeline leakage detection method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Pipe leak detection method and device
CN109931506A
Pipeline leakage aperture identification method based on feature migration and time-frequency diagram
CN113935377A
Vibration spectrum peak capturing method
CN117490834A
Cited By
Water supply network leakage detection method and system combined with time-frequency domain analysis and medium
CN120012328A
A method, system, and medium for leak detection in water supply networks that combines time-frequency domain analysis.
CN120012328B
5G portable WiFi signal enhancement method and system
CN120111511A
Water leakage detection device and water leakage detection method
CN121033525A
A water leakage detection device and a water leakage detection method
CN121033525B
