Environment self-adaptive ultrasonic gas leakage detection method based on self-encoder

By employing autoencoder-based semi-supervised learning and lightweight model updating, the problems of poor environmental adaptability and high model update cost in ultrasonic gas leak detection methods are solved, achieving efficient gas leak detection and environmental adaptability.

CN120974369APending Publication Date: 2025-11-18XI'AN UNIVERSITY OF ARCHITECTURE AND TECHNOLOGY

Patent Information

Application Number
CN202511067988.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-31
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing ultrasonic gas leak detection methods rely on a single feature quantity, which is prone to false alarms or missed detections. Furthermore, they have poor environmental adaptability in complex industrial scenarios, high model update costs, and difficulty in achieving lightweight online updates.

Method used

A semi-supervised learning method based on autoencoders is adopted. A convolutional autoencoder is trained using leak-free data under normal operating conditions. An anomaly detector is constructed by extracting time-frequency features and embedding representation vectors. A lightweight model update mechanism is adopted to continuously improve the detection performance using data accumulated during system use.

Benefits of technology

Driven by data without abnormal leaks, it achieves efficient gas leak detection, reduces data acquisition and labeling costs, has higher practical application value, and can quickly adapt to environmental changes while maintaining detection accuracy and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120974369A_ABST
    Figure CN120974369A_ABST
Patent Text Reader

Abstract

The invention discloses an environment self-adaptive ultrasonic gas leakage detection method based on a self-encoder. The method comprises the following steps of: 1, acquiring a sound signal, and collecting environmental background noise when no gas leaks under a normal working condition; 2, carrying out fixed-length segmentation processing on the sound signals, and extracting logarithmic Mel spectrum features; step 3, establishing a convolutional auto-encoder neural network model; step 4, extracting embedded representation vectors of all normal samples in the training set by using the auto-encoder model trained in the step 3 to form a normal sample feature library, then training an anomaly detector, and determining an optimal detection threshold according to anomaly score values of all the normal samples in the verification set; and 5, when the environment changes, updating the normal sample feature library and the abnormal sample feature library by using newly accumulated sound data, retraining the abnormal detector and updating the detection threshold. According to the method, the problems of scarcity of leaked data, high acquisition cost and poor environmental adaptability in a real scene are effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of gas leak detection technology, and specifically to an environmentally adaptive ultrasonic gas leak detection method based on a self-encoder. Background Technology

[0002] Existing ultrasonic gas leak detection technologies can be divided into two categories: traditional sound pressure level threshold detection methods and data-driven AI detection methods. Sound pressure level threshold detection methods detect leaks by real-time monitoring of the sound pressure level (SPL) in an ultrasonic frequency band (e.g., 20–70 kHz) and comparing it to a preset threshold. This method relies solely on the sound pressure level within a fixed ultrasonic frequency range, limiting its detection performance and accuracy. For example, for early, minute leaks, the frequency of the leaking sound signal may be below 20 kHz, easily leading to missed detections; furthermore, ultrasonic interference sources present in complex industrial environments can easily cause false alarms.

[0003] Data-driven AI detection algorithms can be divided into supervised and semi-supervised methods based on the different training data settings. Currently, more research is focused on supervised methods, which require a large amount of labeled audio data with and without leakage during model training to learn a binary classification model of "input features - leakage determination".

[0004] Supervised methods heavily rely on abnormal gas leak data. However, gas leaks occur infrequently in real-world industrial settings, and obtaining real leak data is difficult and costly, limiting the practical application of supervised algorithms. While experimental setups can artificially simulate leak sounds, it's challenging to completely replicate real leak signals with full characteristics. Therefore, artificially simulated leak samples cannot guarantee the accuracy and comprehensiveness of feature extraction. Furthermore, real-world leak types and the conditions under which leaks occur are complex and variable. Supervised methods are prone to overfitting to the training dataset, lacking adaptability to new environments and anomaly types under new conditions. Moreover, model updates often require full network retraining, which is costly and hinders lightweight online updates.

[0005] Among existing ultrasonic gas leak detection methods, Honeywell's Searchzone Sonik is the most advanced. TMTraditional sound pressure level threshold detection algorithms, exemplified by the BKSN21EX online ultrasonic leak detector from Beijing Enterprises Power, rely solely on the sound pressure level within a fixed ultrasonic frequency band, limiting their detection performance and accuracy. For example, the frequency of the leaking sound signal may be below 20kHz for early, minute leaks, easily leading to missed detections; furthermore, ultrasonic interference sources in complex industrial settings can easily cause false alarms. Supervised methods, such as the Chinese patent "CN104412087A Ultrasonic Gas Leak Detector with False Alarm Identification" and the literature "A framework combining acoustic features extraction method and randomforest algorithm for gas pipeline leak detection and classification" (AppliedAcoustics, vol. 182, p. 108255, 2021), heavily rely on abnormal gas leak data. However, the low incidence of gas leaks in actual industrial scenarios and the difficulty and high cost of obtaining real leak data limit the practical application of supervised algorithms. While experimental setups can be used to artificially simulate leak sounds, it is difficult to completely replicate real leak signals with full characteristics. Therefore, using artificially simulated leak samples makes it challenging to ensure the accuracy and comprehensiveness of feature extraction. Furthermore, real-world leak types and the conditions under which leaks occur are complex and variable. Supervised methods are prone to overfitting to the training dataset, lacking adaptability to anomalies in new environments and conditions. Moreover, model updates often require full network retraining, which is costly and makes lightweight online updates difficult to achieve.

[0006] The semi-supervised methods in the literature "Pipeline leak detection by using time-domain statistical features" (IEEE Sensors Journal, vol. 17, no. 19, pp. 6431-6442, 2017) and "A self-supervised leak detection method for natural gas gathering pipelines considering unlabeled multi-class non-leak data" (Computers in Industry, vol. 159-160, pp. 104102, 2024) are only applicable to environmentally constrained scenarios. They lack environmental adaptation mechanisms when background noise conditions change, and new noise data unseen by the model is easily judged as anomalous, leading to a sharp decline in detection performance. Furthermore, while a small amount of real gas leak data can often be collected during the use of the detection system, research on how semi-supervised methods can utilize this small amount of anomalous leak data to continuously improve model detection performance is still very limited. Summary of the Invention

[0007] To overcome the shortcomings of existing technologies, this invention aims to provide an environment-adaptive ultrasonic gas leak detection method based on an autoencoder. Driven by the absence of abnormal leak data, a convolutional autoencoder model is trained using semi-supervised learning techniques to establish the distribution of normal data and achieve anomaly detection. This invention uses only leak-free data under normal operating conditions to train the model, effectively solving the problems of scarce and costly leak data acquisition in real-world scenarios, thus possessing higher practical application value. Simultaneously, it effectively utilizes newly collected environmental noise data and a small amount of abnormal leak data during system operation, continuously improving the model's detection performance and environmental adaptability through online difficult sample screening and a lightweight model update strategy. This invention aims to overcome the shortcomings of existing ultrasonic gas leak detection methods, such as strong dependence on abnormal samples, poor environmental adaptability, and high model update costs.

[0008] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0009] An environmentally adaptive ultrasonic gas leak detection method based on an autoencoder includes the following steps;

[0010] Step 1: Sound Acquisition and Dataset Construction

[0011] Sound signals were acquired using a single wideband MEMS microphone, and ambient background noise was collected under normal operating conditions without gas leakage to construct a normal sample dataset; the normal sample dataset was then divided into a training set and a validation set.

[0012] Step 2: Time-frequency feature extraction:

[0013] The sound signal collected by the microphone is segmented into fixed lengths, and low-frequency and high-frequency cutoff frequencies are set to extract the log-Mel spectrum features of the sound signal within the frequency band.

[0014] Step 3: Autoencoder Training:

[0015] A convolutional autoencoder neural network model is established using the normal sample dataset constructed in step one. The model is trained based on the reconstruction error between the input and output, where the output of the encoder module in the autoencoder is regarded as the embedded representation vector of the input sound signal.

[0016] Step 4: Anomaly Detector Training and Anomaly Detection

[0017] Using the autoencoder model trained in step three, the embedded representation vectors of all normal samples in the training set are extracted to form a normal sample feature library. Then, an anomaly detector is trained based on the k-nearest neighbor clustering algorithm. The anomaly score of the test sound sample is defined as the minimum cosine distance between its embedded representation vector and all cluster centers of the normal sample feature library. At the same time, based on the anomaly scores of all normal samples in the validation set, the p-quantile method is used to determine the optimal detection threshold.

[0018] Step 5: Model Update Mechanism

[0019] When the system deployment environment is changed or the environmental noise changes significantly, or when several abnormal gas leak samples are accumulated during system use, the model trained in step three is used to extract the embedding representation vector of the newly accumulated sound data, update the normal sample feature library and establish the abnormal sample feature library, retrain the abnormal detector in step four and update the detection threshold.

[0020] In step one, a single wideband MEMS microphone is used to collect sound signals, with a maximum sampling frequency of 192kHz, sufficient to cover the ultrasonic frequency band of gas leak sounds. The microphone is positioned within 3 meters of the industrial gas transmission pipeline, directly facing the potential critical leak points in the pipeline, to receive the sound signals generated during gas leaks. In step two, the segment length of the time-domain sound signal is set to 1 second to cover sufficient information for analysis while minimizing computational load. When performing spectral analysis on the sound signal, low-frequency and high-frequency cutoff frequencies are set according to the acoustic characteristics of gas leaks to filter out low-frequency noise, focusing only on the key characteristic frequency bands of the gas leak ultrasonic signal, which effectively reduces background noise interference.

[0021] The process of extracting log-Mel spectrum features from a sound signal x[n] (n=1,2,…,N) includes:

[0022] The sound signal is converted into a two-dimensional time spectrum using short-time Fourier transform. A Mel triangular filter bank is constructed based on parameters such as low-frequency and high-frequency cutoff frequencies and the number of Mel filters. This filter bank is then multiplied with the two-dimensional time spectrum to obtain the Mel spectrum, which maps the frequency dimension from a linear scale to a Mel scale. Finally, each value in the Mel spectrum is converted to a decibel scale to obtain the logarithmic Mel spectrum.

[0023] Log-Mel spectrum reflects the frequency component distribution of a sound signal in both the time and frequency domains, helping to characterize the different time-frequency structural characteristics of gas leak sounds and environmental noise. Gas leak sounds typically have steady-state high-frequency noise, such as broadband high-frequency components generated by turbulence, and may also contain harmonic structures. Environmental noise, such as wind noise and machine noise, is mostly concentrated in low frequencies or has time-varying non-steady-state characteristics, such as sudden sounds or periodic mechanical vibrations. Mel-scale transformation and logarithmic compression amplify the differences in frequency distribution and time-domain stability between gas leaks and environmental noise, providing highly informative and effective feature inputs for neural network-based detection models to distinguish between these two types of sounds. Let the extracted log-Mel spectrum features be denoted as […]. Where F indicates the frequency domain dimension, which is the number of Mel filters; T indicates the time domain dimension, which is the number of time-domain frames in the short-time Fourier transform.

[0024] In step three, the log-Mel spectrum features of the sound signal are used as the model input, and the reconstruction error between the input and output is used as the loss function to train the convolutional autoencoder model to learn the feature distribution of the normal sample class.

[0025] Convolutional autoencoders are symmetrical encoder-decoder structures that use two-dimensional convolutional layers to process two-dimensional time-frequency feature data of sound signals. Sound signals have non-stationary and dynamically changing characteristics. Compared with fully connected linear layers, the local receptive field of convolutional layers can efficiently capture local dynamic features in the time-frequency domain. At the same time, with fewer parameters, the computational load and model complexity are reduced, and key spectral features appearing in different time periods can be effectively detected.

[0026] The encoder contains four convolutional layers, each sequentially employing 2D convolution, batch normalization, ReLU activation, and 2×2 max pooling. The number of channels gradually increases from 1 to 16, 32, 64, and 128, while simultaneously compressing the time-frequency domain feature space. The encoder output is a latent feature representation, denoted as...

[0027]

[0028] Where f enc :(F,T)→(C,F′ ,T ′ ) represents the encoder module, C and F ′ and T ′ These indicate the channel, frequency domain, and time domain dimensions, respectively, with C = 128;

[0029] The decoder uses four deconvolutional layers to reverse the operation, reconstructing the input data using the latent feature representations output by the encoder. Each layer contains 2x upsampling, deconvolution, batch normalization, and a ReLU activation function. The final output is a reconstructed result with the same dimension as the input, represented as follows:

[0030]

[0031] Where f dec :(C,F ′ ,T ′ (F,T) represents the decoder module;

[0032] During the training phase, leak-free data under normal operating conditions is used to train the autoencoder model. The optimization objective is to minimize the reconstruction error between the input and output, thereby establishing the key feature distribution of the normal sample data. The reconstruction error is calculated using the formula defined as follows:

[0033]

[0034] Where ||·||2 represents the L2 norm. By minimizing the reconstruction loss, the autoencoder model learns to compress and reconstruct the feature distribution of normal, leak-free data; for gas leak data that the model has not seen before, the model will be unable to reconstruct accurately, resulting in a large reconstruction error, and the potential representation output by the encoder will also deviate from the distribution of normal data.

[0035] The trained autoencoder model acts as a feature extractor, flattening the latent feature representation Z output by the encoder into a shape of (C, F′*T′). Then, through average pooling, the average value of the last dimension after flattening is calculated to obtain an embedding representation vector of dimension C, denoted as . This embedded representation vector contains key features of the input data and can be used to distinguish between normal data and abnormal leaked data.

[0036] In step four, an anomaly detector is constructed using the embedded representation vector of the input data. The processing flow includes:

[0037] (1) Use the autoencoder trained in step three to extract the embedding representation vectors of all normal samples in the training set to form a normal sample feature library.

[0038] (2) For Clustering was performed using the k-nearest neighbor algorithm, resulting in K cluster centers. As a reference feature set for normal samples;

[0039] (3) During the testing phase, an embedded representation vector x is extracted from the test sound sample. The anomaly score is defined as the minimum cosine distance between its embedded representation vector and the K cluster centers of the normal sample reference feature set:

[0040]

[0041] The smaller the score value, the closer the characteristics of the test sound are to those of normal, leak-free sound data, and the greater the probability of it being predicted as normal; conversely, the larger the score value, the greater the probability that the test sound has a gas leak.

[0042] (4) For all samples in the validation set, calculate their anomaly scores. Select the critical value t at p=0.9 based on these scores using the p-quantile method. The anomaly determination results for the test samples are as follows:

[0043]

[0044] To address potential changes in the testing environment and effectively utilize new data accumulated during system use, step five employs a lightweight model update mechanism. This mechanism leverages new data collected during offline or online system use to continuously enhance the model's detection performance and environmental adaptability. During the model update process, the autoencoder remains frozen, updating only the anomaly detector and detection threshold to reduce computational complexity while ensuring continuous optimization of detection accuracy.

[0045] Depending on the application scenario and requirements, two different model update mechanisms are adopted: offline and online.

[0046] Offline mode requires preparing training data for the new environment in advance, performing an offline, one-time update on the model, and then directly using it in the new testing environment. It is suitable for scenarios where data in the new environment can be obtained in advance when changing deployment environments.

[0047] Online mode is suitable for scenarios where data in the new environment cannot be obtained in advance when changing the deployment environment, or for scenarios where the environmental noise characteristics fluctuate greatly over time and the model needs to have environmental adaptability. The model needs to be plug-and-play, automatically accumulate data in the new environment and update the model during the test, and quickly adapt to changes in the test environment.

[0048] In online mode, during the use of the detection system, new environmental noise data and potential abnormal leakage data need to be collected in real time, dynamically filtered, and saved in a data buffer. The data is then periodically updated according to the system's set cycle (e.g., weekly). Online data filtering and saving adopts the principle of least confidence, and the processing flow is as follows:

[0049] A fixed-size data buffer B is set up to filter and store the data collected in real time by the detection system according to the minimum confidence principle; the confidence of the detection system in predicting the input data is defined as the absolute value of the difference between its anomaly score and the detection threshold, i.e.

[0050] q = |score - t|

[0051] The lower the confidence level, the closer the anomaly score of the input data is to the detection threshold boundary, and the more "difficult" it is to distinguish. Therefore, it needs to be given special attention and has value for further annotation and learning. For each collected sound signal x i Extract its embedded representation vector e i And calculate the anomaly score s i and confidence value q i If the data buffer is not full, save directly (x) i ,e i ,q i Data triples are sent to buffer B;

[0052] If the buffer is full, a confidence competition strategy is used to retain data with lower confidence and higher judgment difficulty.

[0053] In the current data buffer B, let

[0054]

[0055] The rules for filtering and saving data are as follows:

[0056]

[0057] When the set time for model updates is reached, manual verification is triggered to confirm the labels of each data sample in the data buffer, classify them into environmental noise and abnormal leakage categories, and store them in the normal data buffer B respectively. n and exception class data buffer B a Then, the model update process is initiated. After completing one round of model updates, the current data buffer is cleared to prepare for the next round of data filtering and model updates.

[0058] The process for updating the model using newly accumulated environmental noise and anomalous leakage data is as follows:

[0059] (1) If This means accumulating new environmental noise data and merging the embedded representation vectors of the new data into the existing normal sample feature library. In, that is Retrain the k-nearest neighbor model for normal sample classes to obtain the updated reference feature set for normal samples.

[0060] (2) If A number of abnormal gas leak data have been accumulated, and an abnormal sample feature library has been constructed using the embedded representation vectors of this data. Train the k-nearest neighbor model for the outlier sample class to obtain L cluster centers. As a reference feature set for abnormal samples;

[0061] (3) Considering both normal and abnormal sample reference feature sets, a fused abnormality score is calculated. Based on the normal sample reference set, the abnormality metric of the test sample is the minimum cosine distance between its embedded representation vector x and all vectors in that reference set:

[0062]

[0063] Based on the anomalous sample reference set, the anomaly metric is the maximum cosine similarity between the embedded representation vector x and all vectors in the reference set:

[0064]

[0065] The final fused anomaly score is a weighted sum of the scores from the two models mentioned above, calculated using the following formula:

[0066]

[0067] Where γ≥0 are weighting coefficients.

[0068] (4) Merge the new environmental noise data into the validation set, and use the updated detection model to calculate the anomaly score on the validation set according to the threshold determination method in step four, and update the detection threshold t.

[0069] The beneficial effects of this invention are:

[0070] 1. This invention proposes an ultrasonic gas leak anomaly detection method based on a convolutional autoencoder that does not rely on leak data samples. This overcomes the shortcomings of existing detection algorithms that depend on large amounts of leak data, and has higher application value in real-world scenarios where abnormal leak samples are scarce. Furthermore, during the model update phase, it can effectively utilize the small amount of abnormal leak sample data accumulated during system use to continuously improve model performance. Therefore, the technical solution of this invention is particularly suitable for scenarios such as chemical and gas leaks where abnormal leak data is difficult to obtain, significantly reducing data acquisition and annotation costs.

[0071] 2. This invention proposes a lightweight online model update mechanism. Its core advantage lies in its ability to achieve efficient and intelligent adaptation and performance improvement when faced with sudden changes in environmental noise, deployment scenario migration, or the accumulation of a small number of abnormal gas leak samples. This is achieved through a lightweight dynamic feature library update mechanism. The method employs the minimum confidence principle to online filter sample data that is difficult to identify and of higher value. During model updates, the autoencoder remains frozen, and incremental updates are performed only on the feature libraries of normal sample classes and abnormal leak classes within the embedding representation space. This allows for rapid matching and adaptation to new environmental features, improving the model's detection accuracy and robustness under environmental changes or cross-scenario deployment. This mechanism enables the system to quickly adapt to environmental changes and maintain continuous detection accuracy without requiring significant computational resources, meeting the long-term online monitoring needs of industrial scenarios. Attached Figure Description

[0072] Figure 1 This is a schematic diagram of the principle of the gas leak detection method based on the self-encoder of the present invention.

[0073] Figure 2 This is a schematic diagram of the data filtering and model update process in the online mode of this invention.

[0074] Figure 3 This is a schematic diagram of the confusion matrix showing the detection accuracy under new noise types before and after model update in offline mode of the present invention.

[0075] Figure 4 This is a schematic diagram showing the change in the detection accuracy of the model under new noise types in the online mode of this invention with the number of update rounds. Detailed Implementation

[0076] The present invention will now be described in further detail with reference to the accompanying drawings.

[0077] like Figure 1 , Figure 2 As shown, the environmentally adaptive ultrasonic gas leak detection method based on an autoencoder includes the following steps;

[0078] Step 1: Sound Acquisition and Dataset Construction

[0079] Sound signals were acquired using a single wideband MEMS microphone, and ambient background noise was collected under normal operating conditions without gas leakage to construct a normal sample dataset.

[0080] Step 2: Time-frequency feature extraction:

[0081] The sound signal collected by the microphone is segmented into fixed lengths, and low-frequency and high-frequency cutoff frequencies are set to extract the log-Mel spectrum features of the sound signal within the frequency band.

[0082] Step 3: Autoencoder Training:

[0083] A convolutional autoencoder neural network model is established using the normal sample dataset constructed in step one. The model is trained based on the reconstruction error between the input and output, where the output of the encoder module in the autoencoder is regarded as the embedded representation vector of the input sound signal.

[0084] Step 4: Anomaly Detector Training and Anomaly Detection

[0085] Using the autoencoder model trained in step three, the embedded representation vectors of all normal samples in the training set are extracted to form a normal sample feature library. Then, an anomaly detector is trained based on the k-nearest neighbor clustering algorithm. The anomaly score of the test sound sample is defined as the minimum cosine distance between its embedded representation vector and all cluster centers of the normal sample feature library. At the same time, based on the anomaly scores of all normal samples in the validation set, the p-quantile method is used to determine the optimal detection threshold.

[0086] Step 5: Model Update Mechanism

[0087] When the system deployment environment is changed or the environmental noise changes significantly, or when several abnormal gas leak samples are accumulated during system use, the model trained in step three is used to extract the embedding representation vector of the newly accumulated sound data, update the normal sample feature library and establish the abnormal sample feature library, retrain the abnormal detector in step four and update the detection threshold.

[0088] In step one, sound signals are acquired using a single wideband MEMS microphone with a sampling frequency of up to 192kHz, sufficient to cover the ultrasonic frequency band of gas leak sounds. The microphone is positioned within 3 meters of the industrial gas transmission pipeline network, directly facing the potential critical leak points in the network, to receive the sound signals generated during gas leaks.

[0089] In step two, the segment length of the time-domain sound signal is set to 1 second to cover sufficient information for analysis while minimizing computational load. When performing spectral analysis on the sound signal, low-frequency and high-frequency cutoff frequencies are set according to the acoustic characteristics of gas leakage to filter out low-frequency noise, focusing only on the key characteristic frequency bands of the gas leakage ultrasonic signal, which effectively reduces background noise interference.

[0090] The process of extracting log-Mel spectrum features for a sound signal x[n] (n=1,2,…,N) includes:

[0091] The sound signal is converted into a two-dimensional time spectrum using short-time Fourier transform. A Mel triangular filter bank is constructed based on parameters such as low-frequency and high-frequency cutoff frequencies and the number of Mel filters. This filter bank is multiplied by the time spectrum obtained in the previous step to obtain the Mel spectrum, which maps the frequency dimension from a linear scale to a Mel scale. Finally, each value in the Mel spectrum is converted to a decibel scale to obtain the logarithmic Mel spectrum.

[0092] Log-Mel spectrum reflects the frequency component distribution of a sound signal in both the time and frequency domains, helping to characterize the different time-frequency structural characteristics of gas leak sounds and environmental noise. Gas leak sounds typically have steady-state high-frequency noise, such as broadband high-frequency components generated by turbulence, and may also contain harmonic structures. Environmental noise, such as wind noise and machine noise, is mostly concentrated in low frequencies or has time-varying non-steady-state characteristics, such as sudden sounds or periodic mechanical vibrations. Mel-scale transformation and logarithmic compression amplify the differences in frequency distribution and time-domain stability between gas leaks and environmental noise, providing highly informative and effective feature inputs for neural network-based detection models to distinguish between these two types of sounds. Let the extracted log-Mel spectrum features be denoted as […]. Where F indicates the frequency domain dimension, which is the number of Mel filters; T indicates the time domain dimension, which is the number of time-domain frames in the short-time Fourier transform.

[0093] In step three, the normal sample dataset constructed in step one is divided into a training set and a validation set. The logarithmic Mel spectrum features of the sound signal are used as the model input, and the reconstruction error between the input and output is used as the loss function to train the convolutional autoencoder model to learn the feature distribution of the normal sample class.

[0094] Convolutional autoencoders are symmetrical encoder-decoder structures that use two-dimensional convolutional layers to process two-dimensional time-frequency feature data of sound signals. Sound signals have non-stationary and dynamically changing characteristics. Compared with fully connected linear layers, the local receptive field of convolutional layers can efficiently capture local dynamic features in the time-frequency domain. At the same time, with fewer parameters, the computational load and model complexity are reduced, and key spectral features appearing in different time periods can be effectively detected.

[0095] The encoder contains four convolutional layers, each sequentially employing 2D convolution, batch normalization, ReLU activation, and 2×2 max pooling. The number of channels gradually increases from 1 to 16, 32, 64, and 128, while simultaneously compressing the time-frequency domain feature space. The encoder output is a latent feature representation, denoted as...

[0096]

[0097] Where f enc :(F,T)→(C,F ′ ,T ′ ) represents the encoder module, C and F′ and T ′ These indicate the channel, frequency domain, and time domain dimensions, respectively, with C = 128;

[0098] The decoder uses four deconvolutional layers to reverse the operation, reconstructing the input data using the latent feature representations output by the encoder. Each layer contains 2x upsampling, deconvolution, batch normalization, and a ReLU activation function. The final output is a reconstructed result with the same dimension as the input, represented as follows:

[0099]

[0100] Where f dec :(C,F ′ ,T ′ )→(F,T) represents the decoder module.

[0101] During the training phase, the autoencoder model is trained using only leak-free data under normal operating conditions. The optimization objective is to minimize the reconstruction error between the input and output to establish the key feature distribution of the normal sample data. The reconstruction error is calculated using the formula defined as follows:

[0102]

[0103] Where ||·||2 represents the L2 norm. By minimizing the reconstruction loss, the autoencoder model learns to compress and reconstruct the feature distribution of normal, leak-free data. However, for gas leak data that the model has never seen before, the model will be unable to reconstruct it accurately, resulting in a large reconstruction error. At the same time, the underlying representation output by the encoder will also deviate from the distribution of normal data.

[0104] The trained autoencoder model can be viewed as a feature extractor. Further, the latent feature representation Z output by the encoder is flattened into a shape of (C, F′*T′). Then, through average pooling, the average value of the last dimension after flattening is calculated to obtain an embedding representation vector of dimension C, denoted as... This embedded representation vector contains key features of the input data and can be used to distinguish between normal data and abnormal leaked data.

[0105] In step four, an anomaly detector is constructed using the embedded representation vector of the input data. The processing flow includes:

[0106] (1) Use the autoencoder trained in step three to extract the embedding representation vectors of all normal samples in the training set to form a normal sample feature library.

[0107] (2) For Clustering was performed using the k-nearest neighbor algorithm, resulting in K cluster centers. As a reference feature set for normal samples;

[0108] (3) During the testing phase, an embedded representation vector x is extracted from the test sound sample. The anomaly score is defined as the minimum cosine distance between its embedded representation vector and the K cluster centers of the normal sample reference feature set:

[0109]

[0110] The smaller the score value, the closer the characteristics of the test sound are to those of normal, leak-free sound data, and the greater the probability of it being predicted as normal; conversely, the larger the score value, the greater the probability that the test sound has a gas leak.

[0111] (4) For all samples in the validation set, calculate their anomaly scores. Select the critical value t at p=0.9 based on these scores using the p-quantile method. The anomaly determination results for the test samples are as follows:

[0112]

[0113] To address potential changes in the testing environment and effectively utilize new data accumulated during system use, step five of this invention employs a lightweight model update mechanism. This mechanism leverages new data collected during offline or online system use to continuously enhance the model's detection performance and environmental adaptability. During the model update process, the autoencoder remains frozen, updating only the anomaly detector and detection threshold to reduce computational complexity while ensuring continuous optimization of detection accuracy.

[0114] Depending on the application scenario and requirements, two different model update mechanisms can be adopted: offline and online.

[0115] Offline mode requires training data for the new environment to be prepared in advance. It allows for offline, one-time updates to the model, which can then be used directly in the new testing environment. This mode is suitable for scenarios where data in the new environment can be obtained in advance when changing deployment environments.

[0116] Online mode is suitable for scenarios where data in the new environment cannot be obtained in advance when changing deployment environments, or for scenarios where environmental noise characteristics fluctuate greatly over time and the model needs to have environmental adaptability. The model needs to be plug-and-play, automatically accumulate data in the new environment and update the model during the test, and quickly adapt to changes in the test environment.

[0117] In online mode, during the use of the detection system, it is necessary to collect, dynamically filter and save new environmental noise data and possible abnormal leakage data in real time, store them in the data buffer, and regularly start the data label manual confirmation and model update process according to the system set cycle (such as once a week). Figure 2This is a flowchart illustrating the online data filtering and model updating process described in this document. The online data filtering and saving process employs the least confidence principle, and its workflow is as follows:

[0118] A fixed-size data buffer B is set up to filter and store the data collected in real time by the detection system according to the minimum confidence principle. The confidence level of the detection system's prediction result for the input data is defined as the absolute value of the difference between its anomaly score and the detection threshold, i.e.

[0119] q = |score - t|

[0120] The lower the confidence level, the closer the anomaly score of the input data is to the detection threshold boundary, and the more "difficult" it is to distinguish. Therefore, it needs to be given special attention and has value for further annotation and learning. For each collected sound signal x i Extract its embedded representation vector e i And calculate the anomaly score s i and confidence value q i If the data buffer is not full, save directly (x) i ,e i ,q i Data triples are sent to buffer B;

[0121] If the buffer is full, a confidence competition strategy is used to retain data with lower confidence and higher judgment difficulty.

[0122] In the current data buffer B, let

[0123]

[0124] The rules for filtering and saving data are as follows:

[0125]

[0126] When the set time for model updates is reached, manual verification is triggered to confirm the labels of each data sample in the data buffer, classify them into environmental noise and abnormal leakage categories, and store them in the normal data buffer B respectively. n and exception class data buffer B a Then, the model update process is initiated. After completing one round of model updates, the current data buffer is cleared to prepare for the next round of data filtering and model updates.

[0127] The process for updating the model using newly accumulated environmental noise and anomalous leakage data is as follows:

[0128] (1) If This means accumulating new environmental noise data and merging the embedded representation vectors of the new data into the existing normal sample feature library. In, that is Retrain the k-nearest neighbor model for normal sample classes to obtain the updated reference feature set for normal samples.

[0129] (2) If A number of abnormal gas leak data have been accumulated, and an abnormal sample feature library has been constructed using the embedded representation vectors of this data. Train the k-nearest neighbor model for the outlier sample class to obtain L cluster centers. As a reference feature set for abnormal samples;

[0130] (3) Considering both normal and abnormal sample reference feature sets, a fused abnormality score is calculated. Based on the normal sample reference set, the abnormality metric of the test sample is the minimum cosine distance between its embedded representation vector x and all vectors in that reference set:

[0131]

[0132] Based on the anomalous sample reference set, the anomaly metric is the maximum cosine similarity between the embedded representation vector x and all vectors in the reference set:

[0133]

[0134] The final fused anomaly score is a weighted sum of the scores from the two models mentioned above, calculated using the following formula:

[0135]

[0136] Where γ≥0 are weighting coefficients.

[0137] (4) Merge the new environmental noise data into the validation set, and use the updated detection model to calculate the anomaly score on the validation set according to the threshold determination method in step four, and update the detection threshold t.

[0138] To verify the effectiveness of the technical solution of this invention for acoustic detection of gas leaks, this embodiment conducted simulation experiments on the publicly available dataset IDMT-ISA-COMPRESSED-AIR and compared it with sound pressure level detection algorithms and supervised classification algorithms. This dataset simulates an industrial compressed air system, using a microphone to record gas leak sound data under different gas pressures, leak types, and background noise conditions. The compressed air system has two pressure configurations: 6 bar and 5 bar. Leak types include exhaust port leaks and damaged pipe leaks, with the leak size adjusted by a knob controlling the exhaust port. Background noise includes three types: relatively quiet laboratory environment, hydraulic press noise, and factory workshop noise. In this embodiment, data recorded using a microphone 2 meters away from the leak point includes ambient background noise when there is no gas leak and sound data when there is a gas leak. The microphone sampling rate is 48kHz, and each sound signal is approximately 30 seconds long. Several segments of sound signals with and without leaks were recorded for each noise type, and divided into training, validation, and test sets in a 4:1:1 ratio, with a balanced proportion of no-leak and leak data in each dataset.

[0139] Table 1 shows the key parameter configurations for the autoencoder detection method described in this paper. The low-frequency cutoff frequency is set to 15kHz to filter out low-frequency noise interference, allowing the model to focus more on the characteristics of the ultrasonic frequency band related to gas leakage. The autoencoder model was trained using only normal, leak-free data from the training set, with 100 training epochs. Model performance is measured by the detection accuracy on the test set, calculated using the following formula:

[0140]

[0141] Table 1 Algorithm Parameter Configuration

[0142] parameter Parameter value Low frequency cutoff frequency fmin = 15000 High-frequency cutoff frequency fmax = 24000 Number of Mel filters F=128 Number of training iterations for the model epoch=100 Number of cluster centers K = L = 16 Abnormal scoring weighting coefficient γ = 0.2

[0143] Table 2 presents the accuracy results of the autoencoder detection method (AE) described in this paper under different noise types, and compares its performance with the sound pressure level detection method (SPL) and the supervised classification method based on convolutional neural networks (CNN). It can be seen that the SPL method's performance deteriorates significantly under more complex noise types such as hydraulic presses and factory workshops, and it is easily affected by noise interference. In contrast, the autoencoder detection method in this embodiment maintains consistent performance across different noise types and exhibits higher stability. Compared with supervised methods, the autoencoder detection method achieves comparable detection performance, and because it does not use any leaked sound data during training, it has a greater competitive advantage in real-world application scenarios where leaked data is scarce.

[0144] Table 2 Comparison of detection accuracy of autoencoder detection method with other methods under different noise types.

[0145] Detection Algorithm Laboratory noise Hydraulic press noise Factory workshop noise SPL 0.9375 0.8750 0.8958 CNN (Supervised) 0.9792 0.9583 0.9750 Semi-supervised AE 0.9375 0.9479 0.9583

[0146] To verify the effectiveness of the model update mechanism described herein, this embodiment uses an autoencoder detection model trained in a quiet laboratory environment as the base model. Offline and online model updates and tests are performed in a noisy factory environment. In offline mode, the model is updated only once. All data in the training set corresponding to the new noise type are prepared in advance for updating the base model. The confusion matrix on the new noise type test set before and after the model update is as follows: Figure 3 As shown, since the basic model has never seen any data under factory noise conditions, most of the leak-free and leaky data in this noise environment were predicted as anomalous leaky data. However, after updating the model with data of the new noise type, the overall performance of the model was significantly improved, verifying the effectiveness of the model update mechanism.

[0147] To simulate model updates in online mode and considering the low leakage rate in real-world scenarios, this embodiment adds data under several new noise types in successive rounds at a ratio of no leakage:with leakage = 10:1, updating the model a total of 5 times. The curve showing the change in the model's detection accuracy under the new noise types with each update round is shown below. Figure 4 As can be seen, with the increase in update rounds, the model accumulates more data on new noise types in online mode, and the detection accuracy steadily improves accordingly.

[0148] The gas leak detection method based on autoencoder adopted in this invention maintains excellent detection performance even without gas leak training data. Moreover, it can automatically adapt to environmental changes through a lightweight model update mechanism and continuously improve model performance using data from new environments, making it suitable for practical application scenarios.

Claims

1. An environment-adaptive ultrasonic gas leak detection method based on a self-encoder, characterized in that, Includes the following steps; Step 1: Use a single wideband MEMS microphone to collect sound signals and collect ambient background noise under normal operating conditions without gas leakage to construct a normal sample dataset; The normal sample dataset is divided into a training set and a validation set; Step 2: Perform fixed-length segmentation on the sound signal collected by the microphone, set low-frequency and high-frequency cutoff frequencies, and extract the log-Mel spectrum features of the sound signal within this frequency range; Step 3: Establish a convolutional autoencoder neural network model. Using the normal sample dataset constructed in Step 1, train the model based on the reconstruction error between the input and output. The output of the encoder module in the autoencoder is regarded as the embedded representation vector of the input sound signal. Step 4: Use the autoencoder model trained in Step 3 to extract the embedding representation vectors of all normal samples in the training set to form a normal sample feature library. Then, train the anomaly detector based on the k-nearest neighbor clustering algorithm. The anomaly score of the test sound sample is defined as the minimum cosine distance between its embedding representation vector and all cluster centers of the normal sample feature library. At the same time, based on the anomaly scores of all normal samples in the validation set, the p-quantile method is used to determine the optimal detection threshold. Step 5: When the system deployment environment is changed or the environmental noise changes significantly, or when several abnormal gas leak samples are accumulated during system use, the model trained in Step 3 is used to extract the embedding representation vector of the newly accumulated sound data, update the normal sample feature library and establish the abnormal sample feature library, retrain the abnormal detector in Step 4 and update the detection threshold.

2. The environmentally adaptive ultrasonic gas leak detection method based on a self-encoder according to claim 1, characterized in that, In step one, sound signals are collected using a single broadband MEMS microphone. The microphone is positioned within 3 meters of the industrial gas transmission pipeline network, directly facing the possible critical leak points in the pipeline network, in order to receive the sound signals generated when a gas leak occurs.

3. The environmentally adaptive ultrasonic gas leak detection method based on a self-encoder according to claim 1, characterized in that, In step two, the process of extracting log-Mel spectrum features from a sound signal x[n] (n=1,2,…,N) includes: The sound signal is converted into a two-dimensional time spectrum using short-time Fourier transform. A Mel triangular filter bank is constructed based on the low-frequency and high-frequency cutoff frequencies and the number of Mel filters. This filter bank is then multiplied with the two-dimensional time spectrum to obtain the Mel spectrum, with the frequency dimension mapped from a linear scale to a Mel scale. Finally, each value in the Mel spectrum is converted to a decibel scale to obtain the logarithmic Mel spectrum. Let the extracted log-Mel spectrum features be denoted as Where F indicates the frequency domain dimension, which is the number of Mel filters; T indicates the time domain dimension, which is the number of time-domain frames in the short-time Fourier transform.

4. The environmentally adaptive ultrasonic gas leak detection method based on a self-encoder according to claim 1, characterized in that, In step three, the log-Mel spectrum features of the sound signal are used as the model input, and the reconstruction error between the input and output is used as the loss function to train the convolutional autoencoder model to learn the feature distribution of the normal sample class.

5. The environmentally adaptive ultrasonic gas leak detection method based on a self-encoder according to claim 4, characterized in that, Convolutional autoencoders are symmetrical encoder-decoder structures that use two-dimensional convolutional layers to process the two-dimensional time-spectral feature data of audio signals. The encoder contains four convolutional layers, each sequentially employing 2D convolution, batch normalization, ReLU activation, and 2×2 max pooling. The number of channels gradually increases from 1 to 16, 32, 64, and 128, while simultaneously compressing the time-frequency domain feature space. The encoder output is a latent feature representation, denoted as... Where f enc :(F,T)→(C,F′,T′) represents the encoder module, where C, F′, and T′ indicate the channel, frequency domain, and time domain dimensions, respectively, and C = 128; The decoder uses four deconvolutional layers to reverse the operation, reconstructing the input data using the latent feature representations output by the encoder. Each layer contains 2x upsampling, deconvolution, batch normalization, and a ReLU activation function. The final output is a reconstructed result with the same dimension as the input, represented as follows: Where f dec :(C,F′,T′)→(F,T) represents the decoder module; During the training phase, leak-free data under normal operating conditions is used to train the autoencoder model. The optimization objective is to minimize the reconstruction error between the input and output, thereby establishing the key feature distribution of the normal sample data. The reconstruction error is calculated using the formula defined as follows: Where ||·||2 represents the L2 norm; The trained autoencoder model serves as a feature extractor. It flattens the latent feature representation Z output by the encoder into a shape of (C, F′*T′), and then uses average pooling to average the last dimension of the flattened representation, resulting in an embedding representation vector of dimension C, denoted as . This embedded representation vector contains key features of the input data and can be used to distinguish between normal data and abnormal leaked data.

6. The environmentally adaptive ultrasonic gas leak detection method based on a self-encoder according to claim 5, characterized in that, In step four, an anomaly detector is constructed using the embedded representation vector of the input data. The processing flow includes: (1) Use the autoencoder trained in step three to extract the embedding representation vectors of all normal samples in the training set to form a normal sample feature library. (2) For Clustering was performed using the k-nearest neighbor algorithm, resulting in K cluster centers. As a reference feature set for normal samples; (3) During the testing phase, an embedded representation vector x is extracted from the test sound sample. The anomaly score is defined as the minimum cosine distance between its embedded representation vector and the K cluster centers of the normal sample reference feature set: The smaller the score value, the closer the characteristics of the test sound are to those of normal, leak-free sound data, and the greater the probability of it being predicted as normal; conversely, the larger the score value, the greater the probability that the test sound has a gas leak. (4) For all samples in the validation set, calculate their anomaly score. Using the p-quantile method, select the critical value at p=0.9 as the detection threshold t. The anomaly determination result for the test samples is:

7. The environmentally adaptive ultrasonic gas leak detection method based on an autoencoder according to claim 6, characterized in that, Step five employs a lightweight model update mechanism, utilizing new data collected during offline or online system use to continuously enhance the model's detection performance and environmental adaptability. Depending on the application scenario and requirements, two different model update mechanisms are adopted: offline and online. Offline mode requires preparing training data for the new environment in advance, updating the model offline and in one go, and then directly using it in the new testing environment. It is suitable for scenarios where data in the new environment can be obtained in advance when changing the deployment environment. Online mode is suitable for scenarios where data in the new environment cannot be obtained in advance when changing deployment environments, or for scenarios where environmental noise characteristics fluctuate greatly over time and the model needs to have environmental adaptability. The model needs to be plug-and-play, automatically accumulate data in the new environment and update the model during the test, and quickly adapt to changes in the test environment.

8. The environmentally adaptive ultrasonic gas leak detection method based on a self-encoder according to claim 7, characterized in that, In online mode, during the use of the detection system, new environmental noise data and potential abnormal leakage data need to be collected in real time, dynamically filtered, and saved, and stored in the data buffer. The data labeling manual verification and model update process is initiated periodically according to the system settings. Online data filtering and saving adopts the principle of least confidence, and its processing flow is as follows: A fixed-size data buffer B is set up to filter and store the data collected in real time by the detection system according to the minimum confidence principle; the confidence of the detection system in predicting the input data is defined as the absolute value of the difference between its anomaly score and the detection threshold, i.e. q = |score - t| The lower the confidence level, the closer the anomaly score of the input data is to the detection threshold boundary, and the more "difficult" it is to distinguish; for each collected sound signal x i Extract its embedded representation vector e i And calculate the anomaly score s i and confidence value q i If the data buffer is not full, save directly (x) i ,e i ,q i Data triples are sent to buffer B; If the buffer is full, a confidence competition strategy is used to retain data with lower confidence and higher decision difficulty. In the current data buffer B, let... The rules for filtering and saving data are as follows: When the set time for model updates is reached, manual verification is triggered to confirm the labels of each data sample in the data buffer, classify them into environmental noise and abnormal leakage categories, and store them in the normal data buffer B respectively. n and exception class data buffer B a Then, the model update process is initiated. After completing one round of model update, the current data buffer is cleared to prepare for the next round of data filtering and model update.

9. The environmentally adaptive ultrasonic gas leak detection method based on a self-encoder according to claim 8, characterized in that, The process for updating the model using newly accumulated environmental noise and anomalous leakage data is as follows: (1) If This means accumulating new environmental noise data and merging the embedded representation vectors of the new data into the existing normal sample feature library. In, that is Retrain the k-nearest neighbor model for normal sample classes to obtain the updated reference feature set for normal samples. (2) If A number of abnormal gas leak data have been accumulated, and an abnormal sample feature library has been constructed using the embedded representation vectors of this data. Train the k-nearest neighbor model for the outlier sample class to obtain L cluster centers. As a reference feature set for abnormal samples; (3) Considering the reference feature sets of normal and abnormal samples, calculate a fused abnormal score. Based on the reference set of normal samples, the abnormality metric of the test sample is the minimum cosine distance between its embedded representation vector x and all vectors in the reference set: Based on the anomalous sample reference set, the anomaly metric is the maximum cosine similarity between the embedded representation vector x and all vectors in the reference set: The final fused anomaly score is a weighted sum of the scores from the two models mentioned above, calculated using the following formula: Where γ≥0 are the weighting coefficients; (4) Merge the new environmental noise data into the validation set, and use the updated detection model to calculate the anomaly score on the validation set according to the threshold determination method in step four, and update the detection threshold t.

Citation Information

Patent Citations

  • Ultrasonic gas leak detector with false alarm discrimination

    CN104412087A

Cited By

  • Airflow interference pipeline acoustic measurement correction method and device

    CN121954205A