A method and system for predicting water quality changes in high-rise buildings based on image recognition
By acquiring multimodal time-series data of the inner wall and center of the pipe using image recognition technology, and combining it with a long short-term memory network, the problems of lag and single-dimensional prediction in traditional water quality monitoring are solved, enabling early and accurate warning and safety assurance of water quality changes in high-rise buildings.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-02
- Publication Date
- 2026-03-13
AI Technical Summary
Traditional water quality monitoring technologies cannot effectively capture pollution characteristics such as biofilm adhesion and rust morphology on the inner walls of water pipes in high-rise buildings, resulting in delayed early warnings. Furthermore, they lack the ability to analyze the spatiotemporal evolution of pollutants, have insufficient dynamic prediction capabilities, and are difficult to achieve early warning and accurate prediction.
An image recognition-based method is used to acquire time-series image data of the inner wall and center of the pipe. Through feature extraction and multimodal fusion, combined with a long short-term memory network, a water quality change prediction model is constructed to achieve comprehensive prediction of multi-dimensional data.
It improves the accuracy and timeliness of water quality change prediction, enables early identification of complex water quality risks, and enhances the water supply safety of secondary water supply systems in high-rise buildings.
Smart Images

Figure CN120766082B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of power system communication technology, and in particular to a method and system for predicting water quality changes in high-rise buildings based on image recognition. Background Technology
[0002] With the acceleration of urbanization, the secondary water supply system of high-rise buildings, as a core facility to ensure the safety of residents' water use, has attracted much attention for its water quality stability and pollution early warning capabilities. Traditional water quality monitoring technology mainly relies on physical and chemical sensors (such as residual chlorine sensors, turbidity meters, etc.) to collect water quality parameters in real time and trigger early warnings by judging thresholds. However, such methods have significant limitations, mainly including: (1) Lack of visual pollution detection: Sensors cannot capture visible pollution features such as biofilm adhesion, rust morphology, and algae growth on the inner wall of water pipes, which are often the direct causes of microbial over-standard or metal ion precipitation. For example, rust spot corrosion (circularity > 0.7) may lead to heavy metal infiltration, but traditional sensors can only alarm when water quality parameters deteriorate (such as turbidity > 1 NTU), resulting in a lag of more than 24 hours. (2) Single data dimension: Existing technologies are mostly based on single-point sensor data and lack the ability to analyze the spatiotemporal evolution of pollutants. Studies have shown that the distribution of microbial films on the inner wall of pipes has a nonlinear relationship with water flow velocity, and it is difficult to accurately predict the trend of pollution diffusion based solely on pH or residual chlorine data. (3) Insufficient dynamic prediction capability: Prediction models based on historical sensor data (such as time series analysis) are poorly adapted to sudden pollution, especially lacking a response mechanism to changes in optical characteristics (such as sudden changes in fluorescence intensity caused by algal blooms), resulting in insufficient prediction accuracy and difficulty in providing a reliable basis for proactive prevention and control.
[0003] In recent years, optical imaging technology has been gradually applied in the field of water quality monitoring, such as detecting suspended solids concentration using underwater cameras. However, existing image recognition solutions are mostly limited to static particulate matter statistics, lacking effective solutions for key issues such as image distortion correction in complex pipeline environments, low-light imaging optimization, and multispectral feature fusion. Furthermore, image noise caused by high-turbidity water or reflections from curved pipe surfaces further reduces the reliability of visual inspection. To address these technical bottlenecks, an innovative monitoring method is urgently needed that can simultaneously acquire and fuse multi-dimensional data on visual features of the pipeline inner wall and water quality parameters, enabling early prediction and accurate warning of water quality changes through dynamic models, thereby improving the active protection capabilities and water safety levels of secondary water supply systems in high-rise buildings. Summary of the Invention
[0004] To address the aforementioned technical issues, this application provides a method and system for predicting water quality changes in high-rise buildings based on image recognition, thereby improving the water supply security of secondary water supply systems in high-rise buildings.
[0005] In a first aspect, embodiments of this application provide a method for predicting water quality changes in high-rise buildings based on image recognition, including:
[0006] A time-series dataset of a target pipe for a preset time period is obtained. The time-series dataset includes first image time-series data, second image time-series data, and water quality sensor time-series data of the target water pipe for the preset time period. The first image time-series data is constructed based on pipe inner wall image data at multiple times of the target water pipe, and the second image time-series data is constructed based on pipe center image data at multiple times of the target water pipe.
[0007] Feature extraction was performed on the first image time series data and the second image time series data respectively to obtain the corresponding rust spot change features on the inner wall of the pipe and the fluorescence change features at the center of the pipe.
[0008] The rust stain variation characteristics on the inner wall of the pipe, the fluorescence variation characteristics at the center of the pipe, and the time series data from the water quality sensor are fused in a multimodal manner to obtain multimodal time series data.
[0009] The multimodal time series data is input into a preset water quality change prediction model, so that the water quality change prediction model can predict the water quality change trend of the target pipeline based on the multimodal time series data, and then output the corresponding water quality change prediction result.
[0010] Based on the water quality change prediction results, a corresponding early warning signal is generated;
[0011] The water quality change prediction model is obtained by training an initial water quality change prediction model based on a historical time series dataset. The initial water quality change prediction model is constructed based on a long short-term memory network.
[0012] This application provides an image recognition-based method for predicting water quality changes in high-rise buildings. By extracting image features from several image datasets and combining them with sensor data, a multimodal time-series dataset is constructed, including images of rust spots on the inner wall of pipes, fluorescence images at the center of the pipes, and sensor data. This overcomes the limitations of traditional single-point sensor monitoring in terms of pollution feature perception dimensions, enabling the water quality change prediction model to comprehensively predict water quality changes in target pipes from multiple dimensions, thus improving the accuracy of water quality change prediction. Furthermore, this application employs a long short-term memory network to construct the prediction model, which can effectively capture the temporal evolution patterns of water quality sensor data and combine it with the patterns of rust spot changes on the inner wall of pipes and the patterns of algal biodiversity changes in water. This gives the prediction model the ability to identify complex water quality risks such as heavy metal leaching and excessive microorganisms at an early stage. As the final link in the residential water supply system, the secondary water supply system of high-rise buildings especially needs this early identification capability to ensure the safety of residents' water use. Compared with existing single-modal water quality detection or prediction technologies, the water quality change prediction method based on multimodal data provided in this embodiment significantly improves the timeliness of prediction and risk tracing capabilities for sudden water quality events, thereby enhancing the water supply safety of secondary water supply systems in high-rise buildings.
[0013] Furthermore, the step of constructing the first image time-series data based on the pipe inner wall image data of the target water pipe at multiple times includes:
[0014] The optical imaging device at the first preset position of the target water pipe acquires the pipe inner wall image data at multiple times, and marks the GPS timing signal of the corresponding time for each of the pipe inner wall image data.
[0015] Based on the GPS timing signal of the pipeline inner wall image data, the individual inner wall image data are arranged in chronological order to obtain the initial first image time series data;
[0016] According to a preset time interval, cubic spline interpolation is used to interpolate and reconstruct the initial first image time series data to build first image time series data with equal time intervals.
[0017] This application provides a method for acquiring first image time-series data. Continuous time-series images are acquired using a fixed-position optical imaging device, forming a stable spatial reference coordinate system, making the morphological analysis of the rusted area comparable. Finally, cubic spline interpolation is used to construct first image time-series data with equal time intervals, which can accurately capture the gradual process of rust spots developing from pitting corrosion to general corrosion. This provides a reliable time-series imaging basis for predicting the trend of rust spots on the inner wall of pipelines, and at the same time provides standardized input data for subsequent model predictions, improving the accuracy of model predictions.
[0018] Furthermore, the step of constructing the second image time-series data based on the pipe center image data of the target water pipe at multiple times includes:
[0019] When acquiring image data of the inner wall of the pipe, the second preset position of the target water pipe is illuminated by an active imaging device using excitation light of a preset wavelength, and a fluorescence image of a preset band at the second preset position is captured at the same time. This allows for the acquisition of pipe center image data at multiple times, and the GPS timing signal of the corresponding time is marked on each of the pipe center image data.
[0020] Based on the GPS timing signal of the pipeline center image data, the pipeline center image data are arranged in chronological order to obtain the initial second image time series data;
[0021] According to a preset time interval, cubic spline interpolation is used to interpolate and reconstruct the initial second image time series data to build second image time series data with equal time intervals.
[0022] This application provides a method for acquiring second image time-series data. An active excitation light-fluorescence imaging mechanism is introduced during the image data acquisition process, constructing a specific detection channel for biological pollution characteristics. Through the combined design of preset wavelength excitation light illumination and preset band fluorescence acquisition, background light interference can be effectively suppressed even in a closed pipe water environment, ensuring that imaging stability is unaffected by changes in water flow velocity. This solves the signal fluctuation problem of traditional optical detection methods under dynamic hydraulic conditions, and is particularly suitable for monitoring the concentration of fluorescent substances such as algal metabolites, improving the accuracy of subsequent water quality change prediction.
[0023] In one possible implementation, the step of extracting features from the first image time-series data to obtain the corresponding rust spot change features on the inner wall of the pipe includes:
[0024] Based on image recognition technology, the rust spot area is segmented from the first image time series data to generate rust spot images of the inner wall of each pipe corresponding to the inner wall image data of each pipe.
[0025] Based on the image data of the inner walls of each pipe, the area coverage and edge fractal dimension of the rust spots on the inner walls of each pipe are calculated respectively.
[0026] Based on the changing trends of the area coverage and edge fractal dimension over time, the rust stain variation characteristics of the inner wall of the pipe are constructed.
[0027] This application provides a method for extracting the variation characteristics of rust spots on the inner wall of a pipeline. It accurately segments rust spot regions in each image using image recognition technology and quantitatively characterizes corrosion features using a dual-parameter system of area coverage and edge fractal dimension. The area coverage reflects the changing trend of the corrosion scale, while the edge fractal dimension quantifies the irregularity of the rust spot morphology. The combined application of these two parameters can distinguish different corrosion stages (such as the active oxidation period and the passivation and peeling period), thereby more accurately extracting the corresponding rust spot variation characteristics from the time-series data of the first image, ensuring the accuracy of subsequent water quality change predictions.
[0028] In one possible implementation, the step of extracting features from the second image time-series data to obtain the corresponding central fluorescence change features of the pipe includes:
[0029] The Otsu algorithm is used to binarize the second image time series data to generate a binarized image corresponding to the image data of each pipeline center.
[0030] The average grayscale value of each of the binarized images is calculated;
[0031] Based on the average gray value of each of the binarized images and the preset gray-concentration mapping model, the concentration value of metabolites corresponding to the center image data of each channel is generated. The gray-concentration mapping model is constructed by fitting several algal metabolite solutions of different concentrations and several corresponding binarized images using the least squares method.
[0032] Based on the trend of the metabolite concentration over time, the fluorescence change characteristics of the center of the channel were constructed.
[0033] This application provides a method for extracting fluorescence change features at the center of a pipeline. By combining the binarization processing of the Otsu algorithm with a pre-built gray-scale-concentration mapping model, a digital transformation path from fluorescence image data to biocontamination concentration is constructed, realizing the data conversion from the image dimension to the biofeature dimension. The feature extraction method provided by this application effectively transforms visual information into numerical features that can participate in model training, making up for the subjective defects of traditional manual interpretation methods, providing richer reference data for subsequent water quality change prediction, and improving the accuracy of water quality change prediction.
[0034] Furthermore, the water quality change prediction model predicts the water quality change trend of the target pipeline based on the multimodal time series data, and then outputs the corresponding water quality change prediction results, including:
[0035] The multi-head attention mechanism is used to assign weights to each modality in the multimodal time series data, and the corresponding weights of each modality are determined.
[0036] The water quality sensor time series data in the multimodal time series data is input into a bidirectional LSTM network so that the bidirectional LSTM network can capture the forward and reverse time dependence features respectively, and then output the corresponding bidirectional hidden state sequence.
[0037] Based on the corresponding weights of each modality, the bidirectional hidden state sequence, the rust spot change features on the inner wall of the pipe, and the fluorescence change features at the center of the pipe are weighted and spliced together to obtain a fused feature vector;
[0038] The fused feature vector is input into a stacked LSTM layer so that the stacked LSTM layer outputs the final hidden state sequence. The stacked LSTM layer is constructed by connecting multiple LSTM layers in sequence. In the stacked LSTM layer, the output data of each LSTM layer is used as the input data of the next LSTM layer.
[0039] The final hidden state sequence is mapped to a preset prediction space through a fully connected layer, and the predicted water quality parameters for several future time steps are output.
[0040] Based on the predicted values of each water quality parameter and the preset threshold, the corresponding water quality change prediction results are output.
[0041] This application provides a water quality change prediction method within a model, integrating a multi-head attention mechanism, a bidirectional LSTM network, and stacked LSTM layers into the water quality change prediction model. This forms a hybrid architecture for multimodal data, enabling dynamic feature fusion and multi-step water quality parameter prediction. The multi-head attention mechanism evaluates the importance of each modality in the multimodal time-series data and assigns weights. The bidirectional LSTM network captures the forward temporal dependencies and backward historical correlations of sensor data. The stacked structure enhances feature abstraction capabilities through multi-layer nonlinear transformations, effectively adapting to the input multimodal time-series data and improving the accuracy of prediction results. Furthermore, this application uses a weighted concatenation strategy during feature fusion, allowing the model to adaptively adjust the contribution weights of each modality based on different operating conditions, significantly improving the robustness of the prediction model under sudden pollution events.
[0042] In one possible implementation, the step of training an initial water quality change prediction model based on a historical time-series dataset to obtain the water quality change prediction model includes:
[0043] The initial water quality change prediction model is obtained by constructing a long short-term memory network. The initial water quality change prediction model includes a weight allocation layer, a bidirectional LSTM network layer, a feature fusion layer, a stacked LSTM layer, and a fully connected layer.
[0044] A loss function is constructed based on mean squared error and attention weight regularization term;
[0045] We obtained historical time-series datasets of pipes in several high-rise buildings and corresponding water quality change data, and then constructed a labeled training dataset.
[0046] The initial water quality change prediction model is trained based on the training dataset and the loss function to obtain several model parameters;
[0047] The initial water quality change prediction model is updated based on the aforementioned model parameters to obtain the water quality change prediction model.
[0048] This application provides a training method for a water quality change prediction model. Based on a composite loss function of mean squared error and attention weight regularization, the method simultaneously optimizes the model's prediction accuracy and feature selection bias during training. The regularization constraint mechanism effectively prevents the model from over-relying on a certain type of feature, enhancing the robustness of the water quality change prediction model. In constructing the training dataset, historical time-series datasets of different high-rise buildings are used. This effectively alleviates the performance degradation problem caused by data distribution offset, allowing the trained water quality change prediction model to be deployed simultaneously in multiple building scenarios, improving the model's cross-building scenario applicability and deployment convenience.
[0049] Secondly, correspondingly, embodiments of this application provide a high-rise building water quality change prediction system based on image recognition, including an acquisition module, an image feature extraction module, a multimodal fusion module, a prediction module, and an early warning module;
[0050] The acquisition module is used to acquire a time series dataset of a target pipe over a preset time period. The time series dataset includes a first image time series data, a second image time series data, and water quality sensor time series data of the target water pipe over the preset time period. The first image time series data is constructed based on pipe inner wall image data of the target water pipe at multiple times, and the second image time series data is constructed based on pipe center image data of the target water pipe at multiple times.
[0051] The image feature extraction module is used to extract features from the first image time series data and the second image time series data respectively, to obtain the corresponding rust spot change features on the inner wall of the pipe and the fluorescence change features at the center of the pipe.
[0052] The multimodal fusion module is used to perform multimodal fusion of the rust spot change characteristics on the inner wall of the pipe, the fluorescence change characteristics at the center of the pipe, and the time series data of the water quality sensor to obtain multimodal time series data;
[0053] The prediction module is used to input the multimodal time series data into a preset water quality change prediction model, so that the water quality change prediction model can predict the water quality change trend of the target pipeline based on the multimodal time series data, and then output the corresponding water quality change prediction result.
[0054] The early warning module is used to generate a corresponding early warning signal based on the water quality change prediction results;
[0055] The water quality change prediction model is obtained by training an initial water quality change prediction model based on a historical time series dataset. The initial water quality change prediction model is constructed based on a long short-term memory network.
[0056] Furthermore, the water quality change prediction model predicts the water quality change trend of the target pipeline based on the multimodal time series data, and then outputs the corresponding water quality change prediction results, including:
[0057] The multi-head attention mechanism is used to assign weights to each modality in the multimodal time series data, and the corresponding weights of each modality are determined.
[0058] The water quality sensor time series data in the multimodal time series data is input into a bidirectional LSTM network so that the bidirectional LSTM network can capture the forward and reverse time dependence features respectively, and then output the corresponding bidirectional hidden state sequence.
[0059] Based on the corresponding weights of each modality, the bidirectional hidden state sequence, the rust spot change features on the inner wall of the pipe, and the fluorescence change features at the center of the pipe are weighted and spliced together to obtain a fused feature vector;
[0060] The fused feature vector is input into a stacked LSTM layer so that the stacked LSTM layer outputs the final hidden state sequence. The stacked LSTM layer is constructed by connecting multiple LSTM layers in sequence. In the stacked LSTM layer, the output data of each LSTM layer is used as the input data of the next LSTM layer.
[0061] The final hidden state sequence is mapped to a preset prediction space through a fully connected layer, and the predicted water quality parameters for several future time steps are output.
[0062] Based on the predicted values of each water quality parameter and the preset threshold, the corresponding water quality change prediction results are output.
[0063] Furthermore, the water quality change prediction system also includes a model training module, which is used to train the initial water quality change prediction model based on historical time series datasets to obtain the water quality change prediction model. The model training module includes a model building unit, a loss function building unit, a training data acquisition unit, a training unit, and a model update unit.
[0064] The model building unit is used to build the initial water quality change prediction model based on the long short-term memory network. The initial water quality change prediction model includes a weight allocation layer, a bidirectional LSTM network layer, a feature fusion layer, a stacked LSTM layer, and a fully connected layer.
[0065] The loss function construction unit is used to construct a loss function based on mean squared error and attention weight regularization term;
[0066] The training data acquisition unit is used to acquire historical time series datasets of pipes in several high-rise buildings and corresponding water quality change data, and then construct a labeled training dataset.
[0067] The training unit is used to train the initial water quality change prediction model based on the training dataset and the loss function to obtain several model parameters;
[0068] The model update unit is used to update the initial water quality change prediction model according to the several model parameters to obtain the water quality change prediction model. Attached Figure Description
[0069] Figure 1 A flowchart illustrating a method for predicting water quality changes in high-rise buildings based on image recognition, provided in an embodiment of this application;
[0070] Figure 2 A schematic diagram of the model architecture for a method for predicting water quality changes in high-rise buildings based on image recognition, provided in an embodiment of this application;
[0071] Figure 3 This is a schematic diagram of a high-rise building water quality change prediction system based on image recognition, provided as an embodiment of this application. Detailed Implementation
[0072] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0073] It should be noted that the step numbers in this document are only for the convenience of explaining the specific embodiments and are not intended to limit the order in which the steps are performed. In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0074] Example 1:
[0075] like Figure 1 As shown, Embodiment 1 provides a method for predicting water quality changes in high-rise buildings based on image recognition, including steps S1-S5:
[0076] Step S1: Obtain a time series dataset of the target pipe for a preset time period. The time series dataset includes first image time series data, second image time series data, and water quality sensor time series data of the target water pipe for a preset time period. The first image time series data is constructed based on the pipe inner wall image data of the target water pipe at multiple times. The second image time series data is constructed based on the pipe center image data of the target water pipe at multiple times.
[0077] Step S2: Extract features from the first image time series data and the second image time series data respectively to obtain the corresponding rust spot change features on the inner wall of the pipe and the fluorescence change features at the center of the pipe;
[0078] Step S3: Perform multimodal fusion of the rust spot change characteristics on the inner wall of the pipe, the fluorescence change characteristics at the center of the pipe, and the time series data from the water quality sensor to obtain multimodal time series data;
[0079] Step S4: Input the multimodal time series data into a preset water quality change prediction model, so that the water quality change prediction model can predict the water quality change trend of the target pipeline based on the multimodal time series data, and then output the corresponding water quality change prediction result.
[0080] Step S5: Generate a corresponding early warning signal based on the water quality change prediction results;
[0081] The water quality change prediction model is obtained by training an initial water quality change prediction model based on a historical time series dataset. The initial water quality change prediction model is constructed based on a long short-term memory network.
[0082] This application provides an image recognition-based method for predicting water quality changes in high-rise buildings. By extracting image features from several image datasets and combining them with sensor data, a multimodal time-series dataset is constructed, including images of rust spots on the inner wall of pipes, fluorescence images at the center of the pipes, and sensor data. This overcomes the limitations of traditional single-point sensor monitoring in terms of pollution feature perception dimensions, enabling the water quality change prediction model to comprehensively predict water quality changes in target pipes from multiple dimensions, thus improving the accuracy of water quality change prediction. Furthermore, this application employs a long short-term memory network to construct the prediction model, which can effectively capture the temporal evolution patterns of water quality sensor data and combine it with the patterns of rust spot changes on the inner wall of pipes and the patterns of algal biodiversity changes in water. This gives the prediction model the ability to identify complex water quality risks such as heavy metal leaching and excessive microorganisms at an early stage. As the final link in the residential water supply system, the secondary water supply system of high-rise buildings especially needs this early identification capability to ensure the safety of residents' water use. Compared with existing single-modal water quality detection or prediction technologies, the water quality change prediction method based on multimodal data provided in this embodiment significantly improves the timeliness of prediction and risk tracing capabilities for sudden water quality events, thereby enhancing the water supply safety of secondary water supply systems in high-rise buildings.
[0083] In a preferred embodiment, the water quality sensor time-series data is acquired through an integrated multi-parameter sensor array, and the water quality sensor time-series data includes the residual chlorine value, turbidity value, and other parameters in the target pipeline at various times. Value and pH value.
[0084] Furthermore, in step S1, constructing the first image time-series data based on the pipe inner wall image data of the target water pipe at multiple times includes:
[0085] The optical imaging device at the first preset position of the target water pipe acquires the pipe inner wall image data at multiple times, and marks the GPS timing signal of the corresponding time for each of the pipe inner wall image data.
[0086] Based on the GPS timing signal of the pipeline inner wall image data, the individual inner wall image data are arranged in chronological order to obtain the initial first image time series data;
[0087] According to a preset time interval, cubic spline interpolation is used to interpolate and reconstruct the initial first image time series data to build first image time series data with equal time intervals.
[0088] This application provides a method for acquiring first image time-series data. Continuous time-series images are acquired using a fixed-position optical imaging device, forming a stable spatial reference coordinate system, making the morphological analysis of the rusted area comparable. Finally, cubic spline interpolation is used to construct first image time-series data with equal time intervals, which can accurately capture the gradual process of rust spots developing from pitting corrosion to general corrosion. This provides a reliable time-series imaging basis for predicting the trend of rust spots on the inner wall of pipelines, and at the same time provides standardized input data for subsequent model predictions, improving the accuracy of model predictions.
[0089] In a preferred embodiment, a 4K endoscopic imager equipped with a ring-shaped LED illumination system is deployed at a first predetermined location on the pipeline. During the acquisition of pipeline inner wall image data, a current GPS timestamp is appended to each frame, thus imbuing each frame with time information. After arranging the various inner wall image data in chronological order, cubic spline interpolation is used to reconstruct the initial first image time series data. Cubic spline interpolation constructs piecewise cubic polynomials between adjacent data points, ensuring the continuity of the first and second derivatives of the interpolation function at the nodes, thereby generating a smooth time series. The mathematical form is:
[0090] S(t) = a i (tt i ) 3 +b i (tt i ) 2 +c i (tt i )+d i , t∈[t i , t i +1];
[0091] Where the coefficient a i b i c i d i Boundary conditions (such as natural splines): Solving for continuity constraints. In the embodiments of this application, the specific process of reconstructing each image data using cubic spline interpolation is as follows:
[0092] 1. Data Preprocessing. The absolute timestamp (e.g., UTC time) of each image is parsed from the GPS timing signal and converted to a uniform time unit (e.g., seconds or milliseconds), thus assigning a time value to each image. Simultaneously, the pixel values (e.g., RGB or grayscale values) of each image are normalized to a uniform range (e.g., [0,1]) to reduce the impact of lighting or sensor differences. Based on the time value and pixel value corresponding to each image, the original time series t is constructed. original =[t1,t2,…,t N ] and pixel value sequence voriginal =[v1,v2,…,v N Then, based on a preset time interval, a uniform time point sequence t covering the original time range is generated. new =[t0,t0+Δt,t0+2Δt,…,t end Since the evolution of rust spots is a long-term process, the time interval Δt in this embodiment is set to 4 hours, that is, the time interval between adjacent images in the final first image time series data is 4 hours.
[0093] 2. Interpolation Reconstruction. For each pixel (h, w, c) in each pipe inner wall image data, based on t... original and v original Fitting to obtain cubic spline functions Sh , w , c ( t The cubic spline function is used to calculate the uniform time point sequence t. new Interpolation at various points: v new (h,w,c) (t new,k ) = Sh , w , c (t) new,k ), where t new,k v represents the time point corresponding to the k-th position in a uniform time point sequence. new (h,w,c) (t new,k Let represent the pixel value corresponding to pixel (h, w, c) in the k-th image of the uniform time point sequence after interpolation reconstruction, where (h, w) represents the pixel position in the image, and c represents the channel (e.g., R / G / B) of that pixel position. Based on the above equation, each t in the uniform time point sequence... new,k By substituting the cubic spline function, interpolation calculations are performed for all pixel positions and channels to generate complete temporal data for the first image.
[0094] Furthermore, in step S1, the step of constructing the second image time-series data based on the pipe center image data of the target water pipe at multiple times includes:
[0095] When acquiring image data of the inner wall of the pipe, the second preset position of the target water pipe is illuminated by an active imaging device using excitation light of a preset wavelength, and a fluorescence image of a preset band at the second preset position is captured at the same time. This allows for the acquisition of pipe center image data at multiple times, and the GPS timing signal of the corresponding time is marked on each of the pipe center image data.
[0096] Based on the GPS timing signal of the pipeline center image data, the pipeline center image data are arranged in chronological order to obtain the initial second image time series data;
[0097] According to a preset time interval, cubic spline interpolation is used to interpolate and reconstruct the initial second image time series data to build second image time series data with equal time intervals.
[0098] This application provides a method for acquiring second image time-series data. An active excitation light-fluorescence imaging mechanism is introduced during the image data acquisition process, constructing a specific detection channel for biological pollution characteristics. Through the combined design of preset wavelength excitation light illumination and preset band fluorescence acquisition, background light interference can be effectively suppressed even in a closed pipe water environment, ensuring that imaging stability is unaffected by changes in water flow velocity. This solves the signal fluctuation problem of traditional optical detection methods under dynamic hydraulic conditions, and is particularly suitable for monitoring the concentration of fluorescent substances such as algal metabolites, improving the accuracy of subsequent water quality change prediction.
[0099] In a preferred embodiment, an active imaging device, comprising a 405nm laser excitation source and a 520±10nm bandpass filter, is deployed at a second predetermined location on the pipeline. The active imaging device is connected to an optical imaging device via Bluetooth for data exchange. When the optical imaging device is about to acquire image data of the pipeline's inner wall, it sends a synchronization signal to the active imaging device, enabling the active imaging device to simultaneously acquire image data of the pipeline's center and assign corresponding GPS timing signals to each pipeline center image data. Similarly, the GPS timing signals of each pipeline center image data are converted into a unified time unit, thus attaching a time value to each pipeline center image data. Based on these time values, the images are arranged to obtain initial second image time-series data. Similar to the processing of the initial first image time-series data, cubic spline interpolation is used to interpolate and reconstruct the initial second image time-series data, constructing second image time-series data with 4-hour intervals.
[0100] In one possible implementation, step S2, which involves extracting features from the first image time-series data to obtain the corresponding pipe inner wall rust spot change features, includes:
[0101] Based on image recognition technology, the rust spot area is segmented from the first image time series data to generate rust spot images of the inner wall of each pipe corresponding to the inner wall image data of each pipe.
[0102] Based on the image data of the inner walls of each pipe, the area coverage and edge fractal dimension of the rust spots on the inner walls of each pipe are calculated respectively.
[0103] Based on the changing trends of the area coverage and edge fractal dimension over time, the rust stain variation characteristics of the inner wall of the pipe are constructed.
[0104] This application provides a method for extracting the variation characteristics of rust spots on the inner wall of a pipeline. It accurately segments rust spot regions in each image using image recognition technology and quantitatively characterizes corrosion features using a dual-parameter system of area coverage and edge fractal dimension. The area coverage reflects the changing trend of the corrosion scale, while the edge fractal dimension quantifies the irregularity of the rust spot morphology. The combined application of these two parameters can distinguish different corrosion stages (such as the active oxidation period and the passivation and peeling period), thereby more accurately extracting the corresponding rust spot variation characteristics from the time-series data of the first image, ensuring the accuracy of subsequent water quality change predictions.
[0105] In a preferred embodiment, in step S2, an improved U-Net network is used to segment the rust spot region from the first image time-series data to obtain rust spot images of each pipe inner wall. Based on the number of rust spot pixels in each pipe inner wall rust spot image and the number of pixels in the corresponding pipe inner wall image data, the area coverage of each pipe inner wall rust spot image is calculated. Simultaneously, box counting is applied to calculate the fractal dimension of each pipe inner wall rust spot image. The specific process for calculating the fractal dimension using box counting for a given pipe inner wall rust spot image is as follows:
[0106] 1. Divide the image of the inner wall of the pipe into several square grids with a side length of m.
[0107] 2. Calculate the number of grids N (m) covered by the rust spot outline in the corresponding pipe inner wall rust spot image.
[0108] 3. Repeat different m values (e.g., 1, 2, 4, 8, 16 pixels) and record different N(m).
[0109] 4. By fitting each log(N(m)) and log(1 / m) using linear regression, the slope is the fractal dimension D.
[0110] Finally, based on the changing trends of the area coverage and edge fractal dimension over time, the variation features of the rust spots on the inner wall of the pipe are constructed. Each variation feature specifically includes the corresponding rust spot area coverage, the growth rate of the rust spot area coverage, the fractal dimension of the rust spot, the rate of change of the fractal dimension of the rust spot, and a stage code. The stage code is determined based on the fractal dimension of the current rust spot image on the inner wall of the pipe, for example:
[0111]
[0112] In one possible implementation, step S2, which involves extracting features from the second image time-series data to obtain the corresponding central fluorescence change features of the pipeline, includes:
[0113] The Otsu algorithm is used to binarize the second image time series data to generate a binarized image corresponding to the image data of each pipeline center.
[0114] The average grayscale value of each of the binarized images is calculated;
[0115] Based on the average gray value of each of the binarized images and the preset gray-concentration mapping model, the concentration value of metabolites corresponding to the center image data of each channel is generated. The gray-concentration mapping model is constructed by fitting several algal metabolite solutions of different concentrations and several corresponding binarized images using the least squares method.
[0116] Based on the trend of the metabolite concentration over time, the fluorescence change characteristics of the center of the channel were constructed.
[0117] This application provides a method for extracting fluorescence change features at the center of a pipeline. By combining the binarization processing of the Otsu algorithm with a pre-built gray-scale-concentration mapping model, a digital transformation path from fluorescence image data to biocontamination concentration is constructed, realizing the data conversion from the image dimension to the biofeature dimension. The feature extraction method provided by this application effectively transforms visual information into numerical features that can participate in model training, making up for the subjective defects of traditional manual interpretation methods, providing richer reference data for subsequent water quality change prediction, and improving the accuracy of water quality change prediction.
[0118] In a preferred embodiment, the construction process of the gray-scale-density mapping model in step S2 is specifically as follows:
[0119] 1. Calibration experiment: Prepare 6 groups of algal metabolite solutions (concentration range 0-50 mg / L), acquire fluorescence images using the same imaging parameters, and calculate the average gray value:
[0120]
[0121] 2. Model Fitting: The linear model C = a⋅G + b was fitted using the least squares method. The fitted parameters were a = 0.205, b = -3.1, and the coefficient of determination R² = 0.989.
[0122] After obtaining the gray-scale-concentration mapping model, the average gray value of each binarized image is substituted into the gray-scale-concentration mapping model to calculate the corresponding metabolite concentration value. Finally, based on the concentration values of each metabolite, the corresponding concentration growth rate, the overall concentration mean, standard deviation, and maximum value are calculated to construct a feature vector, which represents the fluorescence change characteristics at the center of the channel.
[0123] Furthermore, in step S4, the water quality change prediction model predicts the water quality change trend of the target pipeline based on the multimodal time series data, and then outputs the corresponding water quality change prediction result, including:
[0124] The multi-head attention mechanism is used to assign weights to each modality in the multimodal time series data, and the corresponding weights of each modality are determined.
[0125] The water quality sensor time series data in the multimodal time series data is input into a bidirectional LSTM network so that the bidirectional LSTM network can capture the forward and reverse time dependence features respectively, and then output the corresponding bidirectional hidden state sequence.
[0126] Based on the corresponding weights of each modality, the bidirectional hidden state sequence, the rust spot change features on the inner wall of the pipe, and the fluorescence change features at the center of the pipe are weighted and spliced together to obtain a fused feature vector;
[0127] The fused feature vector is input into a stacked LSTM layer so that the stacked LSTM layer outputs the final hidden state sequence. The stacked LSTM layer is constructed by connecting multiple LSTM layers in sequence. In the stacked LSTM layer, the output data of each LSTM layer is used as the input data of the next LSTM layer.
[0128] The final hidden state sequence is mapped to a preset prediction space through a fully connected layer, and the predicted water quality parameters for several future time steps are output.
[0129] Based on the predicted values of each water quality parameter and the preset threshold, the corresponding water quality change prediction results are output.
[0130] This application provides a water quality change prediction method within a model, integrating a multi-head attention mechanism, a bidirectional LSTM network, and stacked LSTM layers into the water quality change prediction model. This forms a hybrid architecture for multimodal data, enabling dynamic feature fusion and multi-step water quality parameter prediction. The multi-head attention mechanism evaluates the importance of each modality in the multimodal time-series data and assigns weights. The bidirectional LSTM network captures the forward temporal dependencies and backward historical correlations of sensor data. The stacked structure enhances feature abstraction capabilities through multi-layer nonlinear transformations, effectively adapting to the input multimodal time-series data and improving the accuracy of prediction results. Furthermore, this application uses a weighted concatenation strategy during feature fusion, allowing the model to adaptively adjust the contribution weights of each modality based on different operating conditions, significantly improving the robustness of the prediction model under sudden pollution events.
[0131] In a preferred embodiment, the model architecture of the water quality change prediction model is as follows: Figure 2 As shown, the model includes a weight allocation layer, a bidirectional LSTM network layer, a feature fusion layer, a stacked LSTM layer, and a fully connected layer. When multimodal time-series data is input into the water quality change prediction model, the data first enters the weight allocation layer. The weight allocation layer assigns weights to each modality in the multimodal time-series data based on a multi-head attention mechanism, determining the corresponding weights for each modality. Specifically, for a given modality of time-series data, it is input into an independent attention head, and a query matrix Q, a key matrix K, and a value matrix V are generated through linear transformation. Then, the corresponding attention weights are calculated based on these three matrices.
[0132] Q = XWQ , K = XWK , V = XWV
[0133]
[0134] in, X ∈R T x d T is the number of time steps, and d is the feature dimension. WQ , WK , WV These are learnable parameters. Based on the above formula, the attention weights of the four independent attention heads are combined through parallel outputs and then a linear transformation is used to obtain the corresponding weights of the temporal data for this modality.
[0135] Head i = Attention(Q i ,K i V i );
[0136] MultiHead(Q,K,V) = Concat(Head1,...,Head4)W O ;
[0137] In one possible scenario, the weighted result is: sensor data: 0.35, rust feature: 0.40, fluorescence feature: 0.25.
[0138] Since the water quality sensor time-series data has not undergone feature extraction before being input into the model, the bidirectional LSTM network captures the forward and backward time-dependent features of the water quality sensor time-series data within the model, and then outputs the corresponding bidirectional hidden state sequence, as shown in the following formula:
[0139] Positive propagation:
[0140] Backpropagation:
[0141] Two-way hidden state:
[0142] Among them, h t This represents the bidirectional hidden state at time t in the time series data of the water quality sensor. This represents the positive time dependence feature at time t in the time series data of the water quality sensor. The inverse time-dependent feature at time t in the water quality sensor time-series data is represented by LSTM(), which is the computation function corresponding to the bidirectional LSTM network. This is the raw data at time t in the time series data of the water quality sensor.
[0143] Then, the bidirectional hidden state sequence, the rust spot change features on the inner wall of the pipe, and the fluorescence change features at the center of the pipe are weighted and concatenated to obtain a fused feature vector. The specific formula is as follows:
[0144] ; where α, β, and γ are the attention weights for each modality, satisfying α+β+γ=1.
[0145] Finally, the feature dimension of the fused feature vector is reduced layer by layer by stacked LSTM layers to obtain the final hidden state sequence of the preset dimension. The final hidden state sequence is then mapped to the preset prediction space through a fully connected layer to output the predicted water quality parameters for several future time steps.
[0146] In one possible implementation, the step of training an initial water quality change prediction model based on a historical time-series dataset to obtain the water quality change prediction model includes:
[0147] The initial water quality change prediction model is obtained by constructing a long short-term memory network. The initial water quality change prediction model includes a weight allocation layer, a bidirectional LSTM network layer, a feature fusion layer, a stacked LSTM layer, and a fully connected layer.
[0148] A loss function is constructed based on mean squared error and attention weight regularization term;
[0149] We obtained historical time-series datasets of pipes in several high-rise buildings and corresponding water quality change data, and then constructed a labeled training dataset.
[0150] The initial water quality change prediction model is trained based on the training dataset and the loss function to obtain several model parameters;
[0151] The initial water quality change prediction model is updated based on the aforementioned model parameters to obtain the water quality change prediction model.
[0152] This application provides a training method for a water quality change prediction model. Based on a composite loss function of mean squared error and attention weight regularization, the method simultaneously optimizes the model's prediction accuracy and feature selection bias during training. The regularization constraint mechanism effectively prevents the model from over-relying on a certain type of feature, enhancing the robustness of the water quality change prediction model. In constructing the training dataset, historical time-series datasets of different high-rise buildings are used. This effectively alleviates the performance degradation problem caused by data distribution offset, allowing the trained water quality change prediction model to be deployed simultaneously in multiple building scenarios, improving the model's cross-building scenario applicability and deployment convenience.
[0153] In a preferred embodiment, the training process of the water quality change prediction model is as follows:
[0154] 1. Model Architecture Design
[0155] Initial Model Construction: An initial water quality change prediction model was built based on a Long Short-Term Memory (LSTM) network, comprising the following modules: Weight Allocation Layer: Multi-head attention mechanism (4 attention heads, 16 head dimensions). Bidirectional LSTM Network Layer: 64 hidden units, sequence length 50. Feature Fusion Layer: Weighted splicing strategy, fusing sensor data, rust spot features, and fluorescence features. Stacked LSTM Layer: 3 layers (64→32→16 units), nonlinear transformation enhances feature abstraction capabilities. Fully Connected Layer: Mapped to a 24-dimensional output space (predicting parameters for the next 24 hours).
[0156] Model parameter initialization: Weight matrix: Xavier initialization (mean 0, variance 1). Bias term: initialized to 0.
[0157] 2. Loss Function Construction
[0158] Mean Squared Error (MSE): Measures the predicted value Compared with the true value Differences:
[0159]
[0160] Attention weight regularization term: Prevents the model from over-relying on a single modality and is used to constrain the distribution of attention weights.
[0161]
[0162] Where α, β, and γ are the weights of sensor data, rust spot features, and fluorescence features, and λ = μ = ν = 0.3 (the optimal value determined by ablation experiments).
[0163] The composite loss function is obtained as follows:
[0164]
[0165] 3. Training Data Acquisition and Preprocessing
[0166] Historical dataset construction: Collect pipeline monitoring data from 5 high-rise buildings (building height 80-150 meters), covering different materials (galvanized steel pipe, stainless steel pipe, PE pipe) and pollution types (rust-dominated, algae bloom).
[0167] Data range: The time span is from 2021 to 2023, totaling 720 days.
[0168] Data entries: 6 sets of multimodal data are generated for each building per day (corresponding to a preset 4-hour time interval).
[0169] Data annotation:
[0170] Turbidity > 1.0 NTU and residual chlorine < 0.3 mg / L, marked as a red alert (label = 2).
[0171] Turbidity > 1.0 NTU or residual chlorine < 0.3 mg / L is marked as a yellow alert (label = 1).
[0172] Normal operating conditions are marked as no warning (label=0).
[0173] Data partitioning: Training set: 80% (576 days), used for model parameter updates. Validation set: 15% (108 days), used for hyperparameter tuning. Test set: 5% (36 days), used for final performance evaluation.
[0174] 4. Model Training Process
[0175] Training parameter settings:
[0176] Optimizer: Adam (learning rate 1e-3, weight decay 1e-5).
[0177] Batch size: 32 (each batch contains data from 32 consecutive time windows).
[0178] Training rounds: 200 (early stop mechanism: terminate when the validation set loss has not improved for 10 consecutive rounds).
[0179] After completing the above preparation process, the initial water quality change prediction model is trained based on the training dataset and the loss function to obtain the water quality change prediction model.
[0180] Example 2:
[0181] like Figure 3 As shown, Embodiment 2 provides a high-rise building water quality change prediction system based on image recognition, including an acquisition module 10, an image feature extraction module 20, a multimodal fusion module 30, a prediction module 40, and an early warning module 50.
[0182] The acquisition module 10 is used to acquire a time series dataset of a target pipe over a preset time period. The time series dataset includes a first image time series data, a second image time series data, and water quality sensor time series data of the target water pipe over the preset time period. The first image time series data is constructed based on pipe inner wall image data of the target water pipe at multiple times, and the second image time series data is constructed based on pipe center image data of the target water pipe at multiple times.
[0183] The image feature extraction module 20 is used to extract features from the first image time series data and the second image time series data respectively, to obtain the corresponding pipe inner wall rust spot change features and pipe center fluorescence change features;
[0184] The multimodal fusion module 30 is used to perform multimodal fusion of the rust spot change characteristics on the inner wall of the pipe, the fluorescence change characteristics at the center of the pipe, and the time series data of the water quality sensor to obtain multimodal time series data;
[0185] The prediction module 40 is used to input the multimodal time series data into a preset water quality change prediction model, so that the water quality change prediction model can predict the water quality change trend of the target pipeline based on the multimodal time series data, and then output the corresponding water quality change prediction result.
[0186] The early warning module 50 is used to generate a corresponding early warning signal based on the water quality change prediction results;
[0187] The water quality change prediction model is obtained by training an initial water quality change prediction model based on a historical time series dataset. The initial water quality change prediction model is constructed based on a long short-term memory network.
[0188] This application provides an image recognition-based water quality change prediction system for high-rise buildings. By extracting image features from several image datasets and combining them with sensor data, a multimodal time-series dataset is constructed, including images of rust spots on the inner wall of pipes, fluorescence images at the center of the pipes, and sensor data. This overcomes the limitations of traditional single-point sensor monitoring in terms of pollution feature perception dimensions, enabling the water quality change prediction model to comprehensively predict water quality changes in target pipes from multiple dimensions, thus improving the accuracy of water quality change prediction. Furthermore, this application employs a long short-term memory network to construct the prediction model, which can effectively capture the temporal evolution patterns of water quality sensor data and combine it with the patterns of rust spot changes on the inner wall of pipes and the patterns of algal biodiversity changes in water. This gives the prediction model the ability to identify complex water quality risks such as heavy metal leaching and excessive microorganisms at an early stage. As the final link in the residential water supply system, the secondary water supply system of high-rise buildings especially needs this early identification capability to ensure the safety of residents' water use. Compared with existing single-modal water quality detection or prediction technologies, the water quality change prediction method based on multimodal data provided in this embodiment significantly improves the timeliness of prediction and risk tracing capabilities for sudden water quality events, thereby enhancing the water supply safety of secondary water supply systems in high-rise buildings.
[0189] For a more detailed explanation of the working principle and procedures of this embodiment, please refer to the relevant description in Embodiment 1.
[0190] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of this application. It should be understood that the above descriptions are merely specific embodiments of this application and are not intended to limit the scope of protection of this application. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application for those skilled in the art.
Claims
1. A method for predicting water quality changes in high-rise buildings based on image recognition, characterized in that, include: A time-series dataset of a target pipe for a preset time period is obtained. The time-series dataset includes first image time-series data, second image time-series data, and water quality sensor time-series data of the target water pipe for the preset time period. The first image time-series data is constructed based on pipe inner wall image data at multiple times of the target water pipe, and the second image time-series data is constructed based on pipe center image data at multiple times of the target water pipe. Based on image recognition technology, rust spots are segmented from the first image time-series data to generate rust spot images of the inner walls of various pipes, corresponding to the inner wall image data of each pipe. Based on the inner wall image data of each pipe, the area coverage and edge fractal dimension of each rust spot image are calculated. Based on the changing trends of the area coverage and edge fractal dimension over time, the rust spot variation characteristics of the inner walls of the pipes are constructed. The Otsu algorithm is used to binarize the second image time-series data to generate binarized images corresponding to the center image data of each pipe. The average grayscale value of each binarized image is calculated. Based on the average grayscale value of each binarized image and a preset grayscale-concentration mapping model, the metabolite concentration value corresponding to the center image data of each pipe is generated. The grayscale-concentration mapping model is constructed using least squares fitting based on several algal metabolite solutions of different concentrations and several corresponding binarized images. Based on the changing trends of the metabolite concentration value over time, the fluorescence variation characteristics of the center of the pipe are constructed. The rust stain variation characteristics on the inner wall of the pipe, the fluorescence variation characteristics at the center of the pipe, and the time series data from the water quality sensor are fused in a multimodal manner to obtain multimodal time series data. The multimodal time series data is input into a preset water quality change prediction model, so that the water quality change prediction model can predict the water quality change trend of the target pipeline based on the multimodal time series data, and then output the corresponding water quality change prediction result. Based on the water quality change prediction results, a corresponding early warning signal is generated; The water quality change prediction model is obtained by training an initial water quality change prediction model based on a historical time series dataset. The initial water quality change prediction model is constructed based on a long short-term memory network.
2. The method for predicting water quality changes in high-rise buildings based on image recognition as described in claim 1, characterized in that, The step of constructing the first image time-series data based on pipe inner wall image data of the target water pipe at multiple times includes: The optical imaging device at the first preset position of the target water pipe acquires the pipe inner wall image data at multiple times, and marks the GPS timing signal of the corresponding time for each of the pipe inner wall image data. Based on the GPS timing signal of the pipeline inner wall image data, the individual inner wall image data are arranged in chronological order to obtain the initial first image time series data; According to a preset time interval, cubic spline interpolation is used to interpolate and reconstruct the initial first image time series data to build first image time series data with equal time intervals.
3. The method for predicting water quality changes in high-rise buildings based on image recognition as described in claim 2, characterized in that, The step of constructing the second image time-series data based on pipeline center image data of the target water pipe at multiple times includes: When acquiring image data of the inner wall of the pipe, the second preset position of the target water pipe is illuminated by an active imaging device using excitation light of a preset wavelength, and a fluorescence image of a preset band at the second preset position is captured at the same time. This allows for the acquisition of pipe center image data at multiple times, and the GPS timing signal of the corresponding time is marked on each of the pipe center image data. Based on the GPS timing signal of the pipeline center image data, the pipeline center image data are arranged in chronological order to obtain the initial second image time series data; According to a preset time interval, cubic spline interpolation is used to interpolate and reconstruct the initial second image time series data to build second image time series data with equal time intervals.
4. The method for predicting water quality changes in high-rise buildings based on image recognition as described in claim 1, characterized in that, The water quality change prediction model predicts the water quality change trend of the target pipeline based on the multimodal time series data, and then outputs the corresponding water quality change prediction results, including: The multi-head attention mechanism is used to assign weights to each modality in the multimodal time series data, and the corresponding weights of each modality are determined. The water quality sensor time series data in the multimodal time series data is input into a bidirectional LSTM network so that the bidirectional LSTM network can capture the forward and reverse time dependence features respectively, and then output the corresponding bidirectional hidden state sequence. Based on the corresponding weights of each modality, the bidirectional hidden state sequence, the rust spot change features on the inner wall of the pipe, and the fluorescence change features at the center of the pipe are weighted and spliced together to obtain a fused feature vector; The fused feature vector is input into a stacked LSTM layer so that the stacked LSTM layer outputs the final hidden state sequence. The stacked LSTM layer is constructed by connecting multiple LSTM layers in sequence. In the stacked LSTM layer, the output data of each LSTM layer is used as the input data of the next LSTM layer. The final hidden state sequence is mapped to a preset prediction space through a fully connected layer, and the predicted water quality parameters for several future time steps are output. Based on the predicted values of each water quality parameter and the preset threshold, the corresponding water quality change prediction results are output.
5. A method for predicting water quality changes in high-rise buildings based on image recognition as described in any one of claims 1-4, characterized in that, The process of training an initial water quality change prediction model based on a historical time-series dataset to obtain the water quality change prediction model includes: The initial water quality change prediction model is obtained by constructing a long short-term memory network. The initial water quality change prediction model includes a weight allocation layer, a bidirectional LSTM network layer, a feature fusion layer, a stacked LSTM layer, and a fully connected layer. A loss function is constructed based on mean squared error and attention weight regularization term; We obtained historical time-series datasets of pipes in several high-rise buildings and corresponding water quality change data, and then constructed a labeled training dataset. The initial water quality change prediction model is trained based on the training dataset and the loss function to obtain several model parameters; The initial water quality change prediction model is updated based on the aforementioned model parameters to obtain the water quality change prediction model.
6. A high-rise building water quality change prediction system based on image recognition, characterized in that, It includes an acquisition module, an image feature extraction module, a multimodal fusion module, a prediction module, and an early warning module; The acquisition module is used to acquire a time series dataset of a target pipe over a preset time period. The time series dataset includes a first image time series data, a second image time series data, and water quality sensor time series data of the target water pipe over the preset time period. The first image time series data is constructed based on pipe inner wall image data of the target water pipe at multiple times, and the second image time series data is constructed based on pipe center image data of the target water pipe at multiple times. The image feature extraction module is used to segment the rust spot region from the first image time series data based on image recognition technology, and generate rust spot images of the inner wall of the pipe corresponding to the inner wall image data of each pipe; according to the inner wall image data of each pipe, the area coverage and edge fractal dimension of each inner wall rust spot image are calculated respectively; according to the changing trend of the area coverage and edge fractal dimension over time, the rust spot change characteristics of the inner wall of the pipe are constructed. The image feature extraction module is used to binarize the second image time-series data using the Otsu algorithm to generate binarized images corresponding to the center image data of each pipe; calculate the average gray value of each binarized image; generate the metabolite concentration value corresponding to each center image data of each pipe based on the average gray value of each binarized image and a preset gray-concentration mapping model, wherein the gray-concentration mapping model is constructed by fitting several algal metabolite solutions of different concentrations and several corresponding binarized images using the least squares method; and construct the fluorescence change feature of the center of the pipe based on the change trend of the metabolite concentration value over time. The multimodal fusion module is used to perform multimodal fusion of the rust spot change characteristics on the inner wall of the pipe, the fluorescence change characteristics at the center of the pipe, and the time series data of the water quality sensor to obtain multimodal time series data; The prediction module is used to input the multimodal time series data into a preset water quality change prediction model, so that the water quality change prediction model can predict the water quality change trend of the target pipeline based on the multimodal time series data, and then output the corresponding water quality change prediction result. The early warning module is used to generate a corresponding early warning signal based on the water quality change prediction results; The water quality change prediction model is obtained by training an initial water quality change prediction model based on a historical time series dataset. The initial water quality change prediction model is constructed based on a long short-term memory network.
7. The image recognition-based water quality change prediction system for high-rise buildings as described in claim 6, characterized in that, The water quality change prediction model predicts the water quality change trend of the target pipeline based on the multimodal time series data, and then outputs the corresponding water quality change prediction results, including: The multi-head attention mechanism is used to assign weights to each modality in the multimodal time series data, and the corresponding weights of each modality are determined. The water quality sensor time series data in the multimodal time series data is input into a bidirectional LSTM network so that the bidirectional LSTM network can capture the forward and reverse time dependence features respectively, and then output the corresponding bidirectional hidden state sequence. Based on the corresponding weights of each modality, the bidirectional hidden state sequence, the rust spot change features on the inner wall of the pipe, and the fluorescence change features at the center of the pipe are weighted and spliced together to obtain a fused feature vector; The fused feature vector is input into a stacked LSTM layer so that the stacked LSTM layer outputs the final hidden state sequence. The stacked LSTM layer is constructed by connecting multiple LSTM layers in sequence. In the stacked LSTM layer, the output data of each LSTM layer is used as the input data of the next LSTM layer. The final hidden state sequence is mapped to a preset prediction space through a fully connected layer, and the predicted water quality parameters for several future time steps are output. Based on the predicted values of each water quality parameter and the preset threshold, the corresponding water quality change prediction results are output.
8. A high-rise building water quality change prediction system based on image recognition as described in claim 6 or 7, characterized in that, The water quality change prediction system also includes a model training module, which is used to train the initial water quality change prediction model based on historical time series datasets to obtain the water quality change prediction model. The model training module includes a model building unit, a loss function building unit, a training data acquisition unit, a training unit, and a model update unit. The model building unit is used to build the initial water quality change prediction model based on the long short-term memory network. The initial water quality change prediction model includes a weight allocation layer, a bidirectional LSTM network layer, a feature fusion layer, a stacked LSTM layer, and a fully connected layer. The loss function construction unit is used to construct a loss function based on mean squared error and attention weight regularization term; The training data acquisition unit is used to acquire historical time series datasets of pipes in several high-rise buildings and corresponding water quality change data, and then construct a labeled training dataset. The training unit is used to train the initial water quality change prediction model based on the training dataset and the loss function to obtain several model parameters; The model update unit is used to update the initial water quality change prediction model according to the several model parameters to obtain the water quality change prediction model.
Citation Information
Patent Citations
Water quality state fusion perception and prediction traceability method
CN118070234A