Water supply system leakage detection method and device based on cloud edge collaboration and storage medium
Patent Information
- Application Number
- CN202511517251.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-23
- Publication Date
- 2026-01-16
Smart Images

Figure CN121350702A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of water supply system detection, and in particular to a method, device and storage medium for detecting leaks in water supply systems based on cloud-edge collaboration. Background Technology
[0002] Urban water supply systems are core infrastructure ensuring the normal operation of cities, encompassing the entire process from source water protection and water treatment to distribution networks, end-user supply, and intelligent management. Among these, the urban water supply network is crucial for water transport. However, both aging pipe materials and construction issues can lead to leaks in urban water supply systems, resulting in significant water waste. Current technologies employ methods such as acoustic detection, radar detection, and infrared spectroscopy to detect leaks. However, these methods rely on human experience, leading to subjective biases and low accuracy. Summary of the Invention
[0003] Therefore, the purpose of this application is to provide a cloud-edge collaborative method, device and storage medium for leak detection in water supply systems, which can overcome the shortcomings of the prior art.
[0004] To achieve the above objectives, the technical solution adopted in this application is as follows: The first aspect of this application provides a cloud-edge collaborative method for detecting leaks in a water supply system, including: A first water supply flow training sample of the first water pipe and a second water supply flow training sample of a plurality of second water pipes are obtained; wherein the sample data volume of the second water supply flow training sample is less than that of the first water supply flow training sample. The first model to be trained is trained based on the first water supply flow training sample to obtain the first flow prediction model; Based on the first water supply flow training sample and multiple second water supply flow training samples, the similarity of multiple flow samples is obtained; Based on the similarity of the multiple flow samples, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, parameter transfer training is performed on the second model to be trained for the multiple second water pipes to obtain the second flow prediction model for the multiple second water pipes. The second flow prediction model is deployed to the edge. Based on the actual flow data of the second water pipe and the predicted flow data of the corresponding second flow prediction model, edge detection is performed on the second water pipe to obtain the leakage detection result of the second water pipe. The first flow prediction model is deployed to the edge. Based on the actual flow data of the first water pipe and the predicted flow data of the corresponding first flow prediction model, edge detection is performed on the first water pipe to obtain the leakage detection result of the first water pipe.
[0005] Compared with the prior art, this application has the following beneficial effects: This application presents a cloud-edge collaborative water supply system leakage detection method. It trains a first training model based on a first water supply flow training sample from a first water pipe with a large sample size. Then, based on the first water supply flow training sample and multiple second water supply flow training samples, it obtains multiple flow sample similarities. Next, based on the multiple flow sample similarities, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, it performs parameter transfer training on the second training models of the multiple second water pipes to obtain second flow prediction models for the multiple second water pipes. Finally, it deploys the second flow prediction models to the edge and performs edge detection on the second water pipes based on the actual flow data of the second water pipes and the predicted flow data of the corresponding second flow prediction models to obtain the leakage detection results for the second water pipes. This method is a technical solution that uses flow sample similarity for transfer learning training to train a highly accurate second flow prediction model based on a second water supply flow training sample with a smaller sample size, and uses this model for leakage detection of second water pipes. This can improve the detection efficiency and accuracy of water supply system leaks.
[0006] As one implementation, the step of obtaining the similarity of multiple flow samples based on the first water supply flow training sample and multiple second water supply flow training samples includes: The first water supply flow training sample is used as the source domain, and multiple second water supply flow training samples are used as multiple target domains. The domain similarity between multiple target domains and the source domain is obtained, and the highest domain similarity is stored as the flow sample similarity. If the number of target domains is greater than a preset threshold, the second water supply flow training sample corresponding to the flow sample similarity is determined as the source domain, the domain similarity between the remaining target domains and the source domains is updated, and the highest domain similarity is stored as the flow sample similarity.
[0007] In this embodiment, the highest domain similarity between the target domain and the source domain is stored as the flow sample similarity, and the second water supply flow training sample corresponding to the flow sample similarity is determined as the source domain. This updates the domain similarity between the remaining target domains and the source domains. When the source domain and the target domain change, the domain similarity can be updated in a timely manner to obtain the initial highest domain similarity. The highest domain similarity after the source domain and the target domain change is used as the flow sample similarity, thereby accurately obtaining the flow sample similarity.
[0008] As one implementation method, the domain similarity between the target domain and the source domain is obtained through the following steps: Obtain the maximum mean difference between the target domain and the source domain; The domain similarity is obtained based on the maximum mean difference; wherein, the smaller the maximum mean difference, the greater the domain similarity.
[0009] In this embodiment, the domain similarity is obtained by calculating the maximum mean difference between the target domain and the source domain, which can accurately determine the domain similarity between the target domain and the source domain.
[0010] As one implementation, the step of obtaining the maximum mean difference between the target domain and the source domain includes: The maximum mean difference can be obtained using the following formula: , in, The maximum mean difference; For the source domain; For the target domain; For mapping functions; The amount of training data in the source domain; The amount of training data for the target domain; The training samples of the source domain One sample data; The training samples for the target domain Sample data.
[0011] As one implementation, the step of performing parameter transfer training on the second model to be trained for the multiple second water pipes based on the similarity of the multiple flow samples, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples to obtain the second flow prediction model for the multiple second water pipes includes: If the source domain of the traffic sample similarity corresponds to the traffic prediction model, and the target domain of the traffic sample similarity corresponds to the model to be trained, the model parameters of the traffic prediction model are transferred to the model to be trained to obtain a transfer learning model; the traffic prediction model includes a first traffic prediction model and a second traffic prediction model; the model to be trained includes a second model to be trained. The transfer learning model is trained based on the training sample data of the target domain; the second flow prediction model of the second water pipe corresponding to the target domain is obtained.
[0012] In this embodiment, based on the source domain and target domain of the flow sample similarity, flow prediction models and training models for two water pipes with high flow sample similarity can be obtained. By combining the model parameters of the flow prediction model and the training sample data corresponding to the target domain to perform transfer training on the training model, a second flow prediction model with high prediction accuracy for the corresponding second water pipe can be obtained.
[0013] As one implementation, the step of performing edge detection on the second water pipe based on the actual flow data of the second water pipe and the predicted flow data of the corresponding second flow prediction model to obtain the leakage detection result of the second water pipe includes: Obtain the difference between the actual flow rate data of the second water pipe and the predicted flow rate data; If the data difference is outside the preset threshold range, the actual traffic data is determined to be abnormal data; The leakage detection results are obtained based on the abnormal data.
[0014] In this embodiment, based on the difference between actual traffic data and predicted traffic data, abnormal data can be accurately obtained to obtain leakage detection results.
[0015] As one implementation method, the step of obtaining the leakage detection result based on the abnormal data includes: If the abnormal data continues to appear, the leak detection result is determined to be a leak and an alarm is sent to the cloud.
[0016] In this embodiment, the occurrence of a leak is determined based on the continuous abnormal data, and an alarm is sent to the cloud when a leak is detected, so that users can quickly obtain alarm information through the cloud.
[0017] As one implementation, the step of obtaining a first water supply flow training sample from the first water pipe and a second water supply flow training sample from multiple second water pipes includes: The training data of water supply flow rate of the first water pipe and the training data of water supply flow rate of the plurality of second water pipes are filtered respectively to obtain the first water supply flow rate filtered data and the plurality of second water supply flow rate filtered data. The first water supply flow rate filtered data and the plurality of second water supply flow rate filtered data are normalized respectively to obtain the first water supply flow rate training sample and the plurality of second water supply flow rate training samples.
[0018] In this embodiment, filtering and normalization processes can reduce the interference of data noise on the first water supply flow training sample and multiple second water supply flow training samples, thereby improving the accuracy of the trained model.
[0019] A second aspect of this application provides a cloud-edge collaborative water supply system leakage detection device, comprising: The training sample acquisition module is used to acquire a first water supply flow training sample of the first water pipe and a second water supply flow training sample of a plurality of second water pipes; wherein the sample data volume of the second water supply flow training sample is less than that of the first water supply flow training sample. The first prediction model training module is used to train the first model to be trained corresponding to the first water pipe based on the first water supply flow training sample to obtain the first flow prediction model. The sample similarity acquisition module is used to obtain the similarity of multiple flow samples based on the first water supply flow training sample and multiple second water supply flow training samples; The second prediction model training module is used to perform parameter transfer training on the second model to be trained for the multiple second water pipes based on the similarity of the multiple flow samples, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, so as to obtain the second flow prediction model for the multiple second water pipes. The leak detection result acquisition module is used to deploy the second flow prediction model to the edge, perform edge detection on the second water pipe based on the actual flow data of the second water pipe and the predicted flow data of the corresponding second flow prediction model, and obtain the leak detection result of the second water pipe; and deploy the first flow prediction model to the edge, perform edge detection on the first water pipe based on the actual flow data of the first water pipe and the predicted flow data of the corresponding first flow prediction model, and obtain the leak detection result of the first water pipe.
[0020] Compared with the prior art, the beneficial effects of this application are: This application discloses a cloud-edge collaborative water supply system leak detection device. It trains a first training model based on a first water supply flow training sample from a first water pipe with a large sample size. Then, based on the first water supply flow training sample and multiple second water supply flow training samples, it obtains multiple flow sample similarities. Next, based on the multiple flow sample similarities, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, it performs parameter transfer training on the second training models for the multiple second water pipes to obtain second flow prediction models for the multiple second water pipes. Finally, it deploys the second flow prediction models to the edge, based on the actual flow data of the second water pipes and the corresponding... The predicted flow data of the second flow prediction model is used to perform edge detection on the second water pipe to obtain the leakage detection result of the second water pipe. The first flow prediction model is deployed to the edge, and edge detection is performed on the first water pipe based on the actual flow data of the first water pipe and the corresponding predicted flow data of the first flow prediction model to obtain the leakage detection result of the first water pipe. This is a technical solution that uses transfer learning training based on the similarity of flow samples to train a highly accurate second flow prediction model based on the second water supply flow training samples with a small amount of sample data. This model can be used for leakage detection of the second water pipe, which can improve the detection efficiency and accuracy of leakage in the water supply system.
[0021] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the cloud-edge collaborative water supply system leak detection method described above.
[0022] To better understand and implement this application, the following detailed description is provided in conjunction with the accompanying drawings. Attached Figure Description
[0023] Figure 1 This is a flowchart illustrating a cloud-edge collaborative water supply system leakage detection method according to an embodiment of this application; Figure 2 This is a schematic diagram of cloud-edge collaboration in a water supply system leakage detection method based on cloud-edge collaboration according to an embodiment of this application; Figure 3 This is a schematic diagram illustrating the stages of a cloud-edge collaborative water supply system leakage detection method according to an embodiment of this application; Figure 4 This is a schematic diagram of the module connection of a cloud-edge collaborative water supply system leakage detection device according to an embodiment of this application; 100. Cloud-edge collaborative water supply system leakage detection device; 101. Training sample acquisition module; 102. First prediction model training module; 103. Sample similarity acquisition module; 104. Second prediction model training module; 105. Leakage detection result acquisition module. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0025] It should be understood that the described embodiments are merely some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of the embodiments of this application.
[0026] In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. In the description of this application, it should be understood that the terms "first," "second," "third," etc., are used only to distinguish similar objects and are not necessarily used to describe a specific order or sequence, nor should they be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances. The singular forms "a," "the," and "the" used in this application and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. The word "if" as used herein can be interpreted as "when," "when," or "in response to determination."
[0027] Furthermore, in the description of this application, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0028] Please see Figure 1 This is a flowchart of a cloud-edge collaborative water supply system leakage detection method provided in the first aspect of the embodiments of this application. The method includes: S1: Obtain a first water supply flow training sample from the first water pipe and a second water supply flow training sample from multiple second water pipes; wherein the sample data volume of the second water supply flow training sample is less than that of the first water supply flow training sample.
[0029] Among them, the first water pipe and the second water pipe are both water pipe parts of the water supply system. The training samples of the first water supply flow and the training samples of the second water supply flow of each second water pipe can be offline data used for model training.
[0030] S2: Train the first model to be trained corresponding to the first water pipe based on the first water supply flow training sample to obtain the first flow prediction model.
[0031] The first model to be trained is LSTM (Long Short-Term Memory Network), which is a special type of recurrent neural network (RNN) designed to handle long-term dependency problems. It solves the gradient vanishing / exploding defects of traditional RNNs through a gating mechanism and is widely used in time series modeling tasks.
[0032] The first water supply flow training sample has a large amount of sample data. Therefore, the first flow prediction model trained based on the first water supply flow training sample has high accuracy in predicting the flow of the first water pipe. Both the first and second water supply flow training samples include target water supply flow data identified as output, as well as historical water supply flow data before the target water supply flow data. The historical water supply flow data before the target water supply flow data is used as input. For example, the historical water supply flow data is the flow value of the previous 8 times, and the target water supply flow data is the flow value of the 9th time.
[0033] S3: Based on the first water supply flow training sample and multiple second water supply flow training samples, obtain the similarity of multiple flow samples.
[0034] The multiple flow sample similarities include the flow sample similarity between the first water supply flow training sample and the second water supply flow training sample, as well as the flow sample similarity between two second water supply flow training samples. The flow sample similarity indicates the similarity between two corresponding water supply flow training samples, and also represents the similarity of the corresponding two water pipes in the data. The water supply flow training samples include the first water supply flow training sample and the second water supply flow training sample, and the water pipes include the first water pipe and the second water pipe.
[0035] It should be noted that steps S2 and S3 are two independent steps, meaning there is no restriction on the execution order between steps S2 and S3. When using the cloud-edge collaborative water supply system leakage detection method of this embodiment, users can execute steps S2 and S3 simultaneously, or execute one of the two steps.
[0036] S4: Based on the similarity of the multiple flow samples, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, perform parameter transfer training on the second training model of the multiple second water pipes to obtain the second flow prediction model of the multiple second water pipes.
[0037] Specifically, based on the similarity of the multiple flow rate samples, two water pipes that are similar in data can be identified. Therefore, based on the similarity of the water pipe data, the model parameters of the trained flow rate prediction model are transferred to the second model to be trained. This model is then trained using the corresponding second water supply flow rate training samples, thus enabling the training of a highly accurate second flow rate prediction model based on the smaller sample size of the second water supply flow rate training samples. The trained flow rate prediction model can be either the first flow rate prediction model or the second flow rate prediction model.
[0038] S5: Deploy the second flow prediction model to the edge, perform edge detection on the second water pipe based on the actual flow data of the second water pipe and the predicted flow data of the corresponding second flow prediction model, and obtain the leakage detection result of the second water pipe; deploy the first flow prediction model to the edge, perform edge detection on the first water pipe based on the actual flow data of the first water pipe and the predicted flow data of the corresponding first flow prediction model, and obtain the leakage detection result of the first water pipe.
[0039] In this application, the cloud-edge collaboration refers to the cloud being responsible for model training and the edge being responsible for leak detection, with each performing its own function. This is because the low computing power of the edge is not conducive to model training, while uploading all data collected at the edge to the cloud for leak detection would consume a lot of bandwidth. Therefore, only uploading the alarm information after the edge detects a leak to the cloud, and then having the cloud handle maintenance scheduling, can effectively balance detection efficiency and training efficiency. The cloud-edge collaboration-based water supply system leak detection method of this application can improve the detection efficiency and accuracy of leak detection in urban water supply systems.
[0040] Compared with the prior art, the beneficial effects of this application are: This application's cloud-edge collaborative water supply system leakage detection method trains a first training model based on a first water supply flow training sample from a first water pipe with a large sample size. Then, based on the first water supply flow training sample and multiple second water supply flow training samples, it obtains multiple flow sample similarities. Next, based on the multiple flow sample similarities, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, it performs parameter transfer training on the second training models for the multiple second water pipes to obtain second flow prediction models for the multiple second water pipes. Finally, it deploys the second flow prediction models to the edge, based on the actual flow data of the second water pipes and the corresponding... The predicted flow data of the second flow prediction model is used to perform edge detection on the second water pipe to obtain the leakage detection result of the second water pipe. The first flow prediction model is deployed to the edge, and edge detection is performed on the first water pipe based on the actual flow data of the first water pipe and the corresponding predicted flow data of the first flow prediction model to obtain the leakage detection result of the first water pipe. This is a technical solution that uses transfer learning training based on the similarity of flow samples to train a highly accurate second flow prediction model based on the second water supply flow training samples with a small amount of sample data. This model can be used for leakage detection of the second water pipe, which can improve the detection efficiency and accuracy of leakage in the water supply system.
[0041] In a feasible embodiment, step S1: obtaining a first water supply flow training sample from the first water pipe and a second water supply flow training sample from multiple second water pipes, includes: S11: Filter the water supply flow training data of the first water pipe and the water supply flow training data of the plurality of second water pipes respectively to obtain the first water supply flow filtered data and the plurality of second water supply flow filtered data.
[0042] The training data of the water supply flow rate of the first water pipe and the training data of the water supply flow rate of the multiple second water pipes can be filtered and denoised using a moving average filter, as shown in the following formula: , in, This is the filtered data; For the first One sample data, , This is the size of the moving window during filtering.
[0043] S12: Normalize the first water supply flow filtering data and the plurality of second water supply flow filtering data respectively to obtain the first water supply flow training sample and the plurality of second water supply flow training samples.
[0044] Normalization can be achieved using the following formula: , in, The normalized water supply flow rate is used as the training sample. This represents the maximum value of the normalized data. This represents the minimum value of the normalized data. This represents the maximum value of the data before normalization. This represents the minimum value of the data before normalization.
[0045] In this embodiment, filtering and normalization processes can reduce the interference of data noise on the first water supply flow training sample and multiple second water supply flow training samples, thereby improving the accuracy of the trained model.
[0046] In a feasible embodiment, step S3: obtaining the similarity of multiple flow samples based on the first water supply flow training sample and multiple second water supply flow training samples, includes: S31: Take the first water supply flow training sample as the source domain, take multiple second water supply flow training samples as multiple target domains, obtain the domain similarity between multiple target domains and the source domain, and store the highest domain similarity as the flow sample similarity.
[0047] For example, the first water supply flow training sample includes sample 1, and multiple second water supply flow training samples include sample 2, sample 3, sample 4, sample 5, and sample 6. That is, sample 1 is the source domain, and samples 2, 3, 4, 5, and 6 are respectively the target domains. The domain similarity between the multiple target domains and the source domains includes the domain similarity between sample 2 and sample 1, sample 3 and sample 1, sample 4 and sample 1, sample 5 and sample 1, and sample 6 and sample 1. Among them, if the domain similarity between sample 2 and sample 1 is the highest, the domain similarity between sample 2 and sample 1 is stored as the flow sample similarity. When storing the domain similarity between sample 2 and sample 1 as the flow sample similarity, the relationship between sample 2 as the target domain and sample 1 as the source domain is also simultaneously stored in the flow sample similarity.
[0048] S32: If the number of target domains is greater than a preset number threshold, the second water supply flow training sample corresponding to the flow sample similarity is determined as the source domain, the domain similarity between the remaining target domains and the source domains is updated, and the highest domain similarity is stored as the flow sample similarity.
[0049] The preset quantity threshold is 1 by default. When the number of target domains is greater than the preset quantity threshold, step S32 is repeated until the number of target domains is equal to 1.
[0050] Continuing the example above, since there are target domains such as sample 2, sample 3, sample 4, sample 5, and sample 6, the number of target domains is greater than 1. Since the domain similarity between sample 2 and sample 1 has already been stored as flow sample similarity, meaning the second water supply flow training sample corresponding to the flow sample similarity includes sample 2, sample 2 is determined as the source domain. Sample 1 and sample 2 are then designated as source domains, and samples 3, 4, 5, and 6 are designated as target domains. Then, the domain similarities between the remaining target domains and the respective source domains are updated. The updated domain similarities include the previously obtained domain similarities between sample 3 and sample 1, sample 4 and sample 1, sample 5 and sample 1, and sample 6 and sample 1, as well as the newly obtained domain similarities between sample 3 and sample 2, sample 4 and sample 2, sample 5 and sample 2, and sample 6 and sample 2. If the highest domain similarity at this point is the domain similarity between sample 3 and sample 1, then the domain similarity between sample 3 and sample 1 is stored as the traffic sample similarity. When storing the domain similarity between sample 3 and sample 1 as the traffic sample similarity, the relationship between sample 3 as the target domain and sample 1 as the source domain is also simultaneously stored in the traffic sample similarity.
[0051] Subsequently, since there are target domains such as sample 3, sample 4, sample 5, and sample 6, the number of target domains is greater than 1. Since the domain similarity between sample 2 and sample 1, and between sample 3 and sample 1, have already been stored as flow sample similarities, the second water supply flow training samples corresponding to the flow sample similarities include sample 2 and sample 3. Since sample 2 has already been determined as the source domain, sample 3 is also now determined as the source domain, making sample 1, sample 2, and sample 3 the source domains, and sample 4, sample 5, and sample 6 the target domains. Then, the domain similarities between the remaining target domains and the respective source domains are updated. The updated domain similarities include the previously obtained domain similarities between sample 4 and sample 1, sample 5 and sample 1, sample 6 and sample 1, sample 4 and sample 2, sample 5 and sample 2, sample 6 and sample 2, as well as the newly obtained domain similarities between sample 4 and sample 3, sample 5 and sample 3, and sample 6 and sample 3. If the highest domain similarity at this time is the domain similarity between sample 4 and sample 1, then the domain similarity between sample 4 and sample 1 is stored as the traffic sample similarity. When storing the domain similarity between sample 4 and sample 1 as the traffic sample similarity, the relationship between sample 4 as the target domain and sample 1 as the source domain is also simultaneously stored in the traffic sample similarity.
[0052] Subsequently, since there are target domains such as sample 4, sample 5, and sample 6, the number of target domains is greater than 1. Since the domain similarity between sample 2 and sample 1, the domain similarity between sample 3 and sample 1, and the domain similarity between sample 4 and sample 1 have been stored as flow sample similarity, the second water supply flow training samples corresponding to the flow sample similarity include sample 2, sample 3, and sample 4. Since sample 2 and sample 3 have been determined as source domains, sample 4 is now also determined as a source domain, so that sample 1, sample 2, sample 3, and sample 4 are respectively used as source domains, and sample 5 and sample 6 are used as target domains. Then, the domain similarity between the remaining target domains and the remaining source domains is updated. The updated domain similarity includes the previously acquired domain similarities between sample 5 and sample 1, sample 6 and sample 1, sample 5 and sample 2, sample 6 and sample 2, sample 5 and sample 3, sample 6 and sample 3, as well as the newly acquired domain similarities between sample 5 and sample 4, and sample 6 and sample 4. If the highest domain similarity at this point is between sample 6 and sample 3, the domain similarity between sample 6 and sample 3 is stored as the traffic sample similarity. When storing the domain similarity between sample 6 and sample 3 as the traffic sample similarity, the relationship between sample 6 as the target domain and sample 3 as the source domain is also simultaneously stored in the traffic sample similarity.
[0053] Then, since there are target domains such as sample 5 and sample 6, the number of target domains is greater than 1. Because the domain similarity between sample 2 and sample 1, sample 3 and sample 1, sample 4 and sample 1, and sample 6 and sample 3 have already been stored as flow sample similarities, the second water supply flow training samples corresponding to the flow sample similarities include sample 2, sample 3, sample 4, and sample 6. Since sample 2, sample 3, and sample 4 have already been determined as source domains, sample 6 is now also determined as a source domain, making sample 1, sample 2, sample 3, sample 4, and sample 6 as source domains, and sample 5 as a target domain. Then, the domain similarities between the remaining target domains and the remaining source domains are updated. The updated domain similarities now include the previously obtained domain similarities between sample 5 and sample 1, sample 5 and sample 2, sample 5 and sample 3, sample 5 and sample 4, and the newly obtained domain similarity between sample 5 and sample 6. If the highest domain similarity at this point is the domain similarity between sample 5 and sample 2, then the domain similarity between sample 5 and sample 2 is stored as the traffic sample similarity. When storing the domain similarity between sample 5 and sample 2 as the traffic sample similarity, the relationship between sample 5 as the target domain and sample 2 as the source domain is also simultaneously stored in the traffic sample similarity.
[0054] At this point, since only sample 5 remains as the target domain, step S32 ends the loop. The obtained traffic sample similarity includes the domain similarity between sample 2 (target domain) and sample 1 (source domain), the domain similarity between sample 3 (target domain) and sample 1 (source domain), the domain similarity between sample 4 (target domain) and sample 1 (source domain), the domain similarity between sample 5 (target domain) and sample 2 (source domain), and the domain similarity between sample 6 (target domain) and sample 3 (source domain).
[0055] In this embodiment, the highest domain similarity between the target domain and the source domain is stored as the flow sample similarity, and the second water supply flow training sample corresponding to the flow sample similarity is determined as the source domain. This updates the domain similarity between the remaining target domains and the source domains. When the source domain and the target domain change, the domain similarity can be updated in a timely manner to obtain the initial highest domain similarity. The highest domain similarity after the source domain and the target domain change is used as the flow sample similarity, thereby accurately obtaining the flow sample similarity.
[0056] In a feasible embodiment, the domain similarity between the target domain and the source domain is obtained through the following steps: Obtain the maximum mean difference between the target domain and the source domain; The domain similarity is obtained based on the maximum mean difference; wherein, the smaller the maximum mean difference, the greater the domain similarity.
[0057] In this embodiment, the domain similarity is obtained by calculating the maximum mean difference between the target domain and the source domain, which can accurately determine the domain similarity between the target domain and the source domain.
[0058] In a feasible embodiment, the step of obtaining the maximum mean difference between the target domain and the source domain includes: The maximum mean difference can be obtained using the following formula: , in, The maximum mean difference; For the source domain; For the target domain; For mapping functions; The amount of training data in the source domain; The amount of training data for the target domain; The training samples of the source domain One sample data; The training samples for the target domain Sample data.
[0059] In one feasible implementation, to further square the maximum mean difference to highlight the differences between them, the formula for squaring the maximum mean difference is as follows: .
[0060] In a feasible embodiment, step S4: performing parameter transfer training on the second training model of the multiple second water pipes based on the similarity of the multiple flow samples, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples to obtain the second flow prediction model of the multiple second water pipes, includes: S41: If the source domain of the traffic sample similarity corresponds to the traffic prediction model, and the target domain of the traffic sample similarity corresponds to the model to be trained, the model parameters of the traffic prediction model are transferred to the model to be trained to obtain a transfer learning model; the traffic prediction model includes a first traffic prediction model and a second traffic prediction model; the model to be trained includes a second model to be trained.
[0061] S42: Train the transfer learning model based on the training sample data of the target domain; obtain the second flow prediction model of the second water pipe corresponding to the target domain.
[0062] The sequential flow of steps S3 and S4 in this application includes various combinations, such as, but not limited to: Combination 1, executing S31-S41-S42-S32 sequentially, and then continuing to execute S41-S42 after each execution of S32; Combination 2, executing S31, then simultaneously executing steps S32 and S41, and then executing step S42 after executing step S41, and then executing steps S41 and S42 after executing step S32; Combination 3, cyclically executing S31-S32 to obtain several traffic sample similarities, and then executing S41 and S42, etc., sequential flow combinations.
[0063] In combinations one and two, since the execution of steps S41 and S42 is related to steps S31 and S32, the sequential flow of the conditional loop is relatively easy to understand. Therefore, the following example will be used to illustrate combination three. The traffic sample similarity includes the domain similarity between sample 2 and sample 1, the domain similarity between sample 3 and sample 1, and the domain similarity between sample 4 and sample 3. When step S41 is executed at the beginning, since the traffic prediction model only has the first traffic prediction model corresponding to sample 1, while the models to be trained include three second models to be trained corresponding to samples 2, 3, and 4 respectively, there exists a domain similarity between sample 2 and sample 1, and a domain similarity between sample 3 and sample 1 that meets the condition that the source domain corresponds to the traffic prediction model and the target domain corresponds to the model to be trained.
[0064] The model parameters of the first flow prediction model are transferred to the second training model corresponding to sample 2 to obtain the transfer learning model 2 corresponding to sample 2; wherein, the transfer learning model 2 is the transfer learning model corresponding to sample 2. Then, the transfer learning model 2 is trained according to sample 2 to obtain the second flow prediction model corresponding to sample 2, that is, the second flow prediction model corresponding to water pipe 2; wherein, water pipe 2 is the second water pipe corresponding to sample 2.
[0065] The model parameters of the first flow prediction model are transferred to the second training model corresponding to sample 3 to obtain the transfer learning model 3 corresponding to sample 3; wherein, the transfer learning model 3 is the transfer learning model corresponding to sample 3. Then, the transfer learning model 3 is trained according to sample 3 to obtain the second flow prediction model corresponding to sample 3, that is, the second flow prediction model corresponding to water pipe 3; wherein, water pipe 3 is the second water pipe corresponding to sample 3.
[0066] Since the domain similarity between sample 4 and sample 3 also meets the condition that the source domain corresponds to the flow prediction model and the target domain corresponds to the model to be trained, after obtaining the second flow prediction model corresponding to sample 3, the second flow prediction model corresponding to sample 3 can be transferred to the second model to be trained corresponding to sample 4, resulting in the transfer learning model 4 corresponding to sample 4; where transfer learning model 4 is the transfer learning model corresponding to sample 4. Then, the transfer learning model 4 is trained based on sample 4 to obtain the second flow prediction model corresponding to sample 4, i.e., the second flow prediction model corresponding to water pipe 4; where water pipe 4 is the second water pipe corresponding to sample 4.
[0067] In this embodiment, based on the source domain and target domain of the flow sample similarity, flow prediction models and training models for two water pipes with high flow sample similarity can be obtained. By combining the model parameters of the flow prediction model and the training sample data corresponding to the target domain to perform transfer training on the training model, a second flow prediction model with high prediction accuracy for the corresponding second water pipe can be obtained.
[0068] In a feasible embodiment, step S5: performing edge detection on the second water pipe based on the actual flow rate data of the second water pipe and the predicted flow rate data of the corresponding second flow prediction model to obtain the leakage detection result of the second water pipe, includes: S51: Obtain the data difference between the actual flow rate data of the second water pipe and the predicted flow rate data.
[0069] S52: If the data difference is outside the preset threshold range, the actual traffic data is determined to be abnormal data.
[0070] The preset threshold range can be represented by a lower threshold and an upper threshold. If the data difference is less than the lower threshold or greater than the upper threshold, it indicates that the data difference is outside the preset threshold range. As one implementation, the lower threshold is... The upper limit of the threshold is ,in, for The mean of all residuals during the training process at each time step. for The standard deviation of all residuals during the training process. Standard scores related to the confidence level.
[0071] S53: Based on the abnormal data, the leakage detection result is obtained.
[0072] In this embodiment, based on the difference between the actual traffic data and the predicted traffic data, abnormal data can be accurately obtained to obtain leakage detection results.
[0073] In a feasible embodiment, step S53: obtaining the leakage detection result based on the abnormal data, includes: If the abnormal data continues to appear, the leak detection result is determined to be a leak and an alarm is sent to the cloud.
[0074] In this embodiment, the occurrence of a leak is determined based on the continuous abnormal data, and an alarm is sent to the cloud when a leak is detected, so that users can quickly obtain alarm information through the cloud.
[0075] This application achieves this through a cloud-edge collaboration approach. Specifically, the model is trained and thresholds are calculated in the cloud, then deployed to the edge. The edge performs online leak detection based on predefined leak judgment criteria. Simultaneously, the cloud periodically updates the prediction model parameters and thresholds for the edge to ensure model accuracy. This method uses LSTM as the prediction model and combines it with transfer learning to construct pipeline flow prediction models for different edges.
[0076] Please see Figure 2 As one implementation method, the cloud-edge collaborative water supply system leakage detection method of this application embodiment can be implemented based on cloud-edge collaboration, and is used for leakage detection in urban water supply systems: the cloud trains the prediction model and calculates the threshold, and then deploys it to the edge. The edge performs online leakage detection according to the set leakage judgment criteria. At the same time, the cloud periodically updates the prediction model parameters and thresholds of the edge to ensure the accuracy of the model. LSTM is used as the prediction model, and transfer learning is combined to construct pipeline flow prediction models for different edges.
[0077] Please see Figure 3 The cloud-edge collaborative water supply system leakage detection method of this application can be divided into a model training stage and a leakage detection stage. In the model training stage, offline data is used to train the LSTM, and transfer learning (TL) is introduced during the training process to accelerate the training process and reduce the amount of data required. Then, a threshold for leakage detection is calculated. Finally, the prediction model and threshold are deployed to the edge.
[0078] The leak detection phase involves using online data at the edge to perform traffic prediction. Leak detection is then performed based on the calculated residuals and actual traffic data. If a leak occurs, an alert is generated and sent to a server in the cloud.
[0079] In this application, the edge refers to the network edge side that is close to the object or data source.
[0080] Please see Figure 4 The second aspect of this application provides a cloud-edge collaborative water supply system leakage detection device 100, comprising: The training sample acquisition module 101 is used to acquire a first water supply flow training sample of the first water pipe and a second water supply flow training sample of a plurality of second water pipes; wherein the sample data volume of the second water supply flow training sample is less than that of the first water supply flow training sample. The first prediction model training module 102 is used to train the first model to be trained corresponding to the first water pipe based on the first water supply flow training sample to obtain the first flow prediction model. The sample similarity acquisition module 103 is used to obtain multiple flow sample similarities based on the first water supply flow training sample and multiple second water supply flow training samples; The second prediction model training module 104 is used to perform parameter transfer training on the second model to be trained for the multiple second water pipes based on the similarity of the multiple flow samples, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, so as to obtain the second flow prediction model for the multiple second water pipes. The leakage detection result acquisition module 105 is used to deploy the second flow prediction model to the edge, perform edge detection on the second water pipe based on the actual flow data of the second water pipe and the predicted flow data of the corresponding second flow prediction model, and obtain the leakage detection result of the second water pipe; and deploy the first flow prediction model to the edge, perform edge detection on the first water pipe based on the actual flow data of the first water pipe and the predicted flow data of the corresponding first flow prediction model, and obtain the leakage detection result of the first water pipe.
[0081] In summary, the cloud-edge collaborative water supply system leakage detection device 100 of this application trains a first training model corresponding to the first water supply flow training sample of the first water pipe with a large amount of sample data. Then, based on the first water supply flow training sample and multiple second water supply flow training samples, it obtains multiple flow sample similarities. Then, based on the multiple flow sample similarities, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, it performs parameter transfer training on the second training models of the multiple second water pipes to obtain the second flow prediction models of the multiple second water pipes. Finally, it deploys the second flow prediction models to the edge and performs edge detection on the second water pipes based on the actual flow data of the second water pipes and the predicted flow data of the corresponding second flow prediction models to obtain the leakage detection results of the second water pipes. This is a technical solution that uses flow sample similarity for transfer learning training to train a highly accurate second flow prediction model based on the second water supply flow training sample with a small amount of sample data, and uses it for leakage detection of the second water pipes. This can improve the detection efficiency and accuracy of water supply system leaks.
[0082] It should be noted that the cloud-edge collaborative water supply system leakage detection device 100 provided in the second aspect of this application is only illustrated by the above-described division of functional modules when executing the cloud-edge collaborative water supply system leakage detection method. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the cloud-edge collaborative water supply system leakage detection device 100 provided in the second aspect of this application and the cloud-edge collaborative water supply system leakage detection method of the first aspect of this application belong to the same concept, and its implementation process is detailed in the method embodiment, which will not be repeated here.
[0083] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the cloud-edge collaborative water supply system leak detection method described above.
[0084] The device embodiments described above are merely illustrative. The components described as separate parts may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without any inventive effort.
[0085] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied 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.
[0086] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function selected in one or more boxes.
[0087] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function selected in one or more boxes.
[0088] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0089] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0090] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0091] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0092] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for leak detection in a water supply system based on cloud-edge collaboration, characterized in that, include: A first water supply flow training sample of the first water pipe and a second water supply flow training sample of a plurality of second water pipes are obtained; wherein the sample data volume of the second water supply flow training sample is less than that of the first water supply flow training sample. The first model to be trained is trained based on the first water supply flow training sample to obtain the first flow prediction model; Based on the first water supply flow training sample and multiple second water supply flow training samples, the similarity of multiple flow samples is obtained; Based on the similarity of the multiple flow samples, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, parameter transfer training is performed on the second model to be trained for the multiple second water pipes to obtain the second flow prediction model for the multiple second water pipes. The second flow prediction model is deployed to the edge. Based on the actual flow data of the second water pipe and the predicted flow data of the corresponding second flow prediction model, edge detection is performed on the second water pipe to obtain the leakage detection result of the second water pipe. The first flow prediction model is deployed to the edge. Based on the actual flow data of the first water pipe and the predicted flow data of the corresponding first flow prediction model, edge detection is performed on the first water pipe to obtain the leakage detection result of the first water pipe.
2. The method for leak detection in a water supply system based on cloud-edge collaboration according to claim 1, characterized in that, The step of obtaining the similarity of multiple flow samples based on the first water supply flow training sample and multiple second water supply flow training samples includes: The first water supply flow training sample is used as the source domain, and multiple second water supply flow training samples are used as multiple target domains. The domain similarity between the multiple target domains and the source domain is obtained, and the highest domain similarity is stored as the flow sample similarity. If the number of target domains is greater than a preset threshold, the second water supply flow training sample corresponding to the flow sample similarity is determined as the source domain, the domain similarity between the remaining target domains and the source domains is updated, and the highest domain similarity is stored as the flow sample similarity.
3. The method for leak detection in a water supply system based on cloud-edge collaboration according to claim 2, characterized in that, The domain similarity between the target domain and the source domain is obtained through the following steps: Obtain the maximum mean difference between the target domain and the source domain; The domain similarity is obtained based on the maximum mean difference; wherein, the smaller the maximum mean difference, the greater the domain similarity.
4. The method for leak detection in a water supply system based on cloud-edge collaboration according to claim 3, characterized in that, The step of obtaining the maximum mean difference between the target domain and the source domain includes: The maximum mean difference can be obtained using the following formula: , in, The maximum mean difference; For the source domain; For the target domain; For mapping functions; The amount of training data in the source domain; The amount of training data for the target domain; The training samples of the source domain One sample data; The training samples for the target domain Sample data.
5. The method for leak detection in a water supply system based on cloud-edge collaboration according to claim 2, characterized in that, The step of performing parameter transfer training on the second model to be trained for the multiple second water pipes based on the similarity of the multiple flow samples, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples to obtain the second flow prediction model for the multiple second water pipes includes: If the source domain of the traffic sample similarity corresponds to the traffic prediction model, and the target domain of the traffic sample similarity corresponds to the model to be trained, the model parameters of the traffic prediction model are transferred to the model to be trained to obtain a transfer learning model; the traffic prediction model includes a first traffic prediction model and a second traffic prediction model; the model to be trained includes a second model to be trained. The transfer learning model is trained based on the training sample data of the target domain; the second flow prediction model of the second water pipe corresponding to the target domain is obtained.
6. The method for leak detection in a water supply system based on cloud-edge collaboration according to claim 1, characterized in that, The step of performing edge detection on the second water pipe based on the actual flow data of the second water pipe and the predicted flow data of the corresponding second flow prediction model to obtain the leakage detection result of the second water pipe includes: Obtain the difference between the actual flow rate data of the second water pipe and the predicted flow rate data; If the data difference is outside the preset threshold range, the actual traffic data is determined to be abnormal data; The leakage detection results are obtained based on the abnormal data.
7. The method for leak detection in a water supply system based on cloud-edge collaboration according to claim 6, characterized in that, The step of obtaining the leakage detection result based on the abnormal data includes: If the abnormal data continues to appear, the leak detection result is determined to be a leak and an alarm is sent to the cloud.
8. The method for leak detection in a water supply system based on cloud-edge collaboration according to claim 1, characterized in that, The steps of obtaining the first water supply flow training sample of the first water pipe and the second water supply flow training samples of multiple second water pipes include: The training data of water supply flow rate of the first water pipe and the training data of water supply flow rate of the plurality of second water pipes are filtered respectively to obtain the first water supply flow rate filtered data and the plurality of second water supply flow rate filtered data. The first water supply flow rate filtered data and the plurality of second water supply flow rate filtered data are normalized respectively to obtain the first water supply flow rate training sample and the plurality of second water supply flow rate training samples.
9. A leak detection device for a water supply system based on cloud-edge collaboration, characterized in that, include: The training sample acquisition module is used to acquire a first water supply flow training sample of the first water pipe and a second water supply flow training sample of a plurality of second water pipes; wherein the sample data volume of the second water supply flow training sample is less than that of the first water supply flow training sample. The first prediction model training module is used to train the first model to be trained corresponding to the first water pipe based on the first water supply flow training sample to obtain the first flow prediction model. The sample similarity acquisition module is used to obtain the similarity of multiple flow samples based on the first water supply flow training sample and multiple second water supply flow training samples; The second prediction model training module is used to perform parameter transfer training on the second model to be trained for the multiple second water pipes based on the similarity of the multiple flow samples, the model parameters of the first flow prediction model, and the multiple second water supply flow training samples, so as to obtain the second flow prediction model for the multiple second water pipes. The leak detection result acquisition module is used to deploy the second flow prediction model to the edge, perform edge detection on the second water pipe based on the actual flow data of the second water pipe and the predicted flow data of the corresponding second flow prediction model, and obtain the leak detection result of the second water pipe; and deploy the first flow prediction model to the edge, perform edge detection on the first water pipe based on the actual flow data of the first water pipe and the predicted flow data of the corresponding first flow prediction model, and obtain the leak detection result of the first water pipe.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, it implements the steps of the cloud-edge collaborative water supply system leakage detection method as described in any one of claims 1 to 8.