Intelligent detection method for dynamic process of highway surface water
By introducing a watershed attention mechanism and a 3D convolutional network into a dual-stream fusion neural network, and combining multi-task learning and physical perception loss functions, the problems of low accuracy and violation of patterns in highway water accumulation detection are solved, and real-time, accurate detection and multi-parameter prediction of the dynamic process of water accumulation are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- RES INST OF HIGHWAY MINIST OF TRANSPORT
- Filing Date
- 2026-04-07
- Publication Date
- 2026-06-30
AI Technical Summary
Existing technologies for detecting water accumulation on highways suffer from problems such as low accuracy, lack of time-series analysis, single parameters, and prediction results that do not conform to the laws of fluid mechanics. They cannot accurately detect the dynamic process of water accumulation. Furthermore, traditional dual-flow fusion neural networks cannot dynamically adjust the contribution of spatial and temporal information, are easily affected by lighting and background interference, and have single output information and low time-series modeling efficiency.
Spatial features are extracted using a watershed attention mechanism, and temporal features are processed by a 3D convolutional network. A dynamic feature fusion module and a multi-task learning framework are designed, and a physical perception loss function is introduced to construct a dual-flow fusion neural network architecture, enabling simultaneous prediction of water accumulation stage, area ratio, runoff direction, and water receding rate.
It enables real-time and accurate detection of the dynamic process of water accumulation on highways, improving detection accuracy and reliability. It can quantify water accumulation parameters, conforms to the laws of fluid mechanics, and improves the accuracy and computational efficiency of multi-task prediction.
Smart Images

Figure CN122313147A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and intelligent transportation technology, and in particular to an intelligent detection method for the dynamic process of water accumulation on highways. Background Technology
[0002] Upgrading and renovating highways is a massive and complex undertaking. The first step is to assess the overall condition of the road, especially the pavement. With the passage of time and the rapid development of pavement construction techniques and materials, the water drainage and receding performance of highways has become a crucial indicator for determining whether an upgrade or renovation is necessary.
[0003] Existing methods for detecting water accumulation mainly rely on manual inspections or simple image processing (such as color thresholding and background modeling), which have the following prominent problems: Low accuracy: Traditional visual methods are easily affected by lighting, shadows, and road surface materials, and cannot accurately distinguish between water accumulation and wet road surfaces.
[0004] Lack of temporal analysis: Single-frame detection cannot capture dynamic changes in water accumulation (such as runoff velocity and receding trend), making it difficult to identify sudden water accumulation.
[0005] Limited parameters: It can only determine whether there is water accumulation, but cannot quantify key information such as the area of water accumulation and the direction of flow, and cannot support the business application needs of refined road data.
[0006] Physically unknowable: Purely data-driven deep learning models may output results that violate the laws of fluid dynamics (such as runoff against gravity), leading to unreliable analysis results.
[0007] In recent years, two-stream fusion neural networks (such as Two-Stream CNN proposed by Simonyan et al.) have been applied in video action recognition, but their direct application to water accumulation detection has many drawbacks: 1. The fusion method is simple and crude: whether it's splicing or averaging, it's a static and unchanging fusion. However, in a waterlogged scenario, the importance of information changes dynamically. For example, when it first starts raining, it's most important to see the shape of the puddles; after the water starts flowing, it's more important to see the direction of the water. Traditional methods cannot handle this change, leading to insufficient use of information.
[0008] Traditional two-stream networks often employ simple feature concatenation or weighted averaging, failing to dynamically adjust the contribution of spatial and temporal information based on scene changes (e.g., whether the water has just formed or is still flowing). In summary, existing simple feature fusion methods cannot adapt to the dynamic changes in the importance of spatial and temporal information under sunny / rainy weather scenarios. Furthermore, existing methods do not consider fluid physics constraints, often resulting in anti-physics fallacies in predictions.
[0009] 2. Spatial focus deviation: The spatial flow of existing dual-stream fusion neural networks lacks specific focus on water accumulation areas. They are trained on general datasets such as ImageNet and can identify cats, dogs, cars, etc., but do not have water accumulation recognition function. They lack an intrinsic driving force to actively focus on the subtle features of water surface such as reflection and texture, and are easily interfered with by the surrounding background such as road surface and guardrail.
[0010] 3. Predictions that disregard physics: Water flow is governed by gravity; water flows downhill, and the surface area doesn't increase out of thin air during receding water. However, purely data-driven models don't understand these principles. In order to fit the data, they might output counter-physical results such as water flowing uphill or negative receding rates, which is unacceptable in engineering.
[0011] 4. Insufficient Output Information: Traditional dual-flow networks typically perform only one classification task. However, road maintenance assessments require more than just information on the presence or absence of water accumulation; they also need quantitative indicators such as the size of the accumulated area, the direction of flow, and the speed of water receding. These indicators are interconnected, and predicting them individually is ineffective and wastes the inherent relationships between the data.
[0012] 5. Insufficient temporal modeling: Standard 3D convolution scans simultaneously in time and space, but the optical flow graph itself is already a condensed motion information. Using complex 3D convolution kernels to scan the time dimension only increases the computational load and is inefficient. Summary of the Invention
[0013] The purpose of this invention is to at least address one of the aforementioned technical deficiencies.
[0014] Therefore, the purpose of this invention is to propose an intelligent detection method for the dynamic process of water accumulation on highways, which can detect the dynamic process of water accumulation on highways in real time and accurately, providing important technical support for traffic safety.
[0015] To achieve the above objectives, embodiments of the present invention provide an intelligent detection method for the dynamic process of water accumulation on highway pavements, comprising the following steps: S1: Acquire videos of multiple sections of the highway, preprocess the video frames of each video, and calculate the dense optical flow of adjacent frames to obtain the optical flow sequence; S2, Construct a dual-stream fusion neural network architecture, which includes a spatial stream network, a temporal stream network, and a dynamic feature fusion mechanism, wherein: S21, Integrating a watershed attention mechanism into the spatial flow network to extract spatial features includes: performing initial convolution and halving the spatial size of the preprocessed image, sequentially passing it through each residual block group of the ResNet34 backbone network, and integrating the watershed attention mechanism on the feature map of the last residual block group; automatically identifying the boundary and center of the water accumulation area using the gradient information of the feature map calculated by the watershed attention mechanism, generating an attention weight map, multiplying it element-wise with the original features to generate an attention-weighted feature map, and performing global average pooling to obtain the spatial features related to water accumulation. ; S22, the temporal flow network uses a 3D convolutional network to process the optical flow sequence and extract temporal features, including: organizing the optical flow sequence into a 5-dimensional tensor and inputting it into stacked 3D convolutional layers; performing sliding window calculations along the spatial dimension in each convolutional operation to extract local motion features; retaining the temporal dimension T as an independent dimension in the output feature map of each layer; averaging the temporal dimension T using a temporal pooling layer to aggregate information from different times into a global motion feature vector; and mapping the global motion feature vector to the same dimension as the spatial features using a fully connected layer to obtain the water accumulation-related temporal features. ; S23, initiate the dynamic feature fusion mechanism based on the spatial features. and time series characteristics The fusion weights of spatial flow and temporal flow are adaptively calculated, and the spatial features and temporal features are dynamically fused according to the fusion weights to generate fused features. S3. Construct a multi-task prediction network and use a multi-task learning framework to simultaneously predict the water accumulation stage, water accumulation area ratio, runoff direction and water receding rate, and generate corresponding prediction results. S4, The prediction results are constrained by the physical perception loss function to conform to the laws of fluid mechanics; S5 uses a cloud platform to perform data analysis and risk assessment on the constrained prediction results, and triggers an early warning when the risk level is detected to be higher than the threshold.
[0016] Furthermore, in S1, each video segment is configured with a frame-level annotation file. The temporal sequence length and input image size are set according to the configuration file. All videos are traversed, and each video file is paired with its corresponding annotation file. The video frames of each video are normalized in size, converted in color space, and standardized. Dense optical flow between adjacent frames is calculated to obtain an optical flow sequence. A sliding window is used to extract training samples from the frame sequence and optical flow sequence. Each sample is encapsulated as a triplet consisting of a frame sequence, an optical flow sequence, and a corresponding multi-task annotation. The annotation file includes the water accumulation stage, water accumulation area ratio, runoff direction, water receding rate, and runoff state.
[0017] Furthermore, in S21, the watershed attention mechanism includes: The feature map X is input into the first convolutional layer for transformation, which halves the number of channels in the input feature map to obtain an intermediate feature map. ; Calculate intermediate feature maps The gradient magnitude map G is obtained by measuring the gradient in the horizontal and vertical directions. The gradient magnitude map G is used to reflect the spatial change intensity at each position in the feature map. intermediate feature map The input is fed into the second convolutional layer for mapping to generate the original score map. Attention weights are then generated using the Sigmoid activation function to obtain the final attention weight map. The attention weight map is used to represent the probability that the location belongs to a waterlogged area. The original input feature map X is multiplied element-wise with the attention weight map to enhance features and generate an attention-weighted feature map.
[0018] Furthermore, the Sobel operator is used to compute intermediate feature maps. The gradients are calculated in both the horizontal and vertical directions. The gradients from multiple channels are averaged across the channel dimension to obtain a single-channel gradient magnitude map. The gradient map G is compared with the feature map after the first layer of convolution for dimensionality reduction. By stitching along the channel dimension, the fused features are obtained. , will integrate features The input to the second convolutional layer is mapped to generate the original score map. Attention weights are then generated using a sigmoid activation function, and an auxiliary loss function is introduced to measure the attention weight map. With gradient magnitude plot The linear correlation between them.
[0019] Furthermore, in S22, the dimensions of the 5-dimensional tensor are B×2×T×H×W, where B is the batch size, T is the temporal length, and H and W are the height and width of the image; The 5-dimensional tensor is input into a stacked 3D convolutional layer, wherein all convolutional kernels in the 3D convolutional layer are 1×3×3 in size; The first convolutional layer of the 3D convolutional layer uses a stride of 2 to expand the number of channels to 64, while halving the spatial size, and the output dimension becomes B×64×T×H / 2×W / 2; the second convolutional layer continues to perform convolution with a stride of 2, increasing the number of channels to 128, and further reducing the spatial size to H / 4×W / 4, with the output being B×128×T×H / 4×W / 4; the third convolutional layer compresses the spatial feature map to 1×1, resulting in a feature map of B×256×T×1×1. The temporal pooling layer is used to average the time dimension T, and the information at different times is aggregated into a global motion feature vector with a dimension of B×256. The fully connected layer maps this 256-dimensional vector to a 128-dimensional vector with the same spatial features, and finally outputs a temporal feature vector with a dimension of B×128.
[0020] Furthermore, in S23, a multilayer perceptron (MLP) is used to process spatial features. and time series characteristics Mapping to the same dimensional space yields the processed spatial features. and time series characteristics ; Will and The features are concatenated to form a joint feature vector, which is then input into the weight generation network. Spatial feature fusion weights are adaptively calculated using fully connected layers and nonlinear activation functions. Weights for fusion with temporal features ; Based on the weighted dynamic fusion of spatial and temporal characteristics, a fusion is generated. ; The fused features Directly used as the final fusion feature Input to a multi-task prediction network.
[0021] Furthermore, in S3, the multi-task prediction network includes a shared feature transformation layer and parallel output layers for the following tasks: water accumulation stage classification, water accumulation area ratio regression, runoff direction prediction, water loss rate estimation, and runoff state judgment. In the shared feature transformation layer, features are fused. The input is fed into a first-layer fully connected network for dimensionality upscaling, and then the dimensionality-upgraded features are fed into a second-layer fully connected network for dimensionality reduction to obtain shared features. ; Will Simultaneously, the output layers of the water accumulation stage classification head, water accumulation area ratio regression head, runoff direction prediction head, water receding rate estimation head, and runoff state judgment head are input, and the prediction results of water accumulation stage, water accumulation area ratio, runoff direction, water receding rate, and runoff state are obtained in parallel.
[0022] Furthermore, in S3, corresponding task weights and loss functions are configured for the output layers of the water accumulation stage classification task, the water accumulation area ratio regression task, the runoff direction prediction task, the water receding rate estimation task, and the runoff state judgment task, respectively, and the weights for the next round are adaptively adjusted based on the loss calculated in the previous round.
[0023] Furthermore, a cross-entropy loss function is configured for the output layer of the water accumulation stage classification head task and the output layer of the runoff state judgment head task; Configure the Huber loss function for the output layers of the water accumulation area ratio regression head task, the runoff direction prediction head task, and the water receding rate estimation head task.
[0024] Furthermore, in S4, the physical perception loss function includes a runoff direction deviation constraint term, a water accumulation area rationality constraint term, a water receding rate non-negativity constraint term, and a runoff state and direction consistency constraint term; By constraining the corresponding prediction results using runoff direction deviation, water accumulation area rationality, drainage rate non-negativity, and runoff state and direction consistency, the runoff direction deviation penalty is obtained. Unreasonable penalty for water accumulation area Negative rate penalty for water discharge Penalty for inconsistency between runoff state and direction The weighted summation yields the physical perception loss. Physical perception loss With mission loss Together they constitute the total loss .
[0025] Compared with the prior art, the advantages and beneficial effects of the present invention are as follows: This invention proposes an intelligent detection method for the dynamic process of water accumulation on highway pavements. It constructs a dual-flow fusion neural network architecture comprising a spatial flow network, a temporal flow network, and a dynamic feature fusion module. It integrates a watershed attention mechanism to extract spatial features, uses a temporal flow network to process optical flow sequences to capture dynamic information, and adaptively fuses multimodal features through the dynamic feature fusion module. A multi-task learning framework is employed to simultaneously predict the water accumulation stage, area ratio, runoff direction, and receding rate. A physical perception loss function is used to constrain the prediction results to conform to fluid dynamics laws. This invention can detect the dynamic process of water accumulation on highway pavements in real time and accurately, providing important technical support for traffic safety.
[0026] 1. To address the issues of spatial focus deviation and difficulty in focusing on water accumulation areas in existing technologies, this paper first applies the watershed attention mechanism to water accumulation detection. By applying the watershed attention mechanism to the spatial flow, the neural network can automatically focus on the water accumulation area and suppress background interference.
[0027] In highway pavement water detection, while convolutional neural networks (CNNs) can learn rich semantic information through hierarchical feature extraction, their inherent global receptive field makes it difficult for the network to actively focus on specific target areas. Waterlogged areas often exhibit complex visual characteristics such as reflectivity, translucency, and blurred boundaries, and are highly susceptible to interference from background factors such as lighting changes, road surface shadows, and lane line textures. Conventional CNNs, lacking prior guidance on waterlogged areas, are prone to misclassifying background noise as valid features during feature extraction, thus reducing detection accuracy and increasing the false alarm rate.
[0028] This invention embeds a watershed attention mechanism into the last few feature maps of ResNet, utilizing this mechanism to calculate the gradient information of the feature maps. Because the edges of puddles often correspond to drastic changes in image brightness and texture (high gradient values), the watershed attention mechanism learns to focus on these high-gradient regions and generates an attention weight map, instructing the network to pay attention to areas like the edges and interiors of puddles. Introducing the watershed attention mechanism into the spatial flow solves the problem that conventional convolutional networks often struggle to accurately focus on puddles when extracting features due to variations in lighting, shadow interference, or complex road textures, leading to insufficient feature discriminability. Experiments demonstrate that applying the watershed attention mechanism to the spatial flow significantly improves the performance. After introducing the watershed attention mechanism, the detection precision of puddles improved by 15.3%, and the recall improved by 12.7%. The heatmap shows that the network's focus indeed shifts from the cluttered road surface to the clearly defined puddles.
[0029] 2. To address the issues of existing dual-stream network fusion methods being too simple and unable to dynamically adjust spatial and temporal weights, a dynamic feature fusion algorithm is designed. This algorithm, combined with a dual-stream fusion architecture, enables multimodal feature fusion, dynamically fusing spatial appearance information and temporal dynamic information according to the scenario.
[0030] This invention employs a lightweight weight generation network that analyzes extracted spatial and temporal features in real time, automatically determining which information is more critical and generating two weights between 0 and 1. For example, when water has just formed and static features are prominent, the weight of spatial features is automatically increased; when water begins to flow rapidly, the weight of temporal features increases accordingly. Finally, the two features are weighted and fused based on this dynamic weight. This dynamic feature fusion method yields better results than simple concatenation or fixed-weight fusion. Ablation experiments show that dynamic fusion improves the average accuracy of multi-task prediction by more than 8%, and the generated weights are highly correlated with the characteristics of the actual scene.
[0031] 3. To address the issue of pure data-driven model outputs violating physical laws, a physical perception loss function is introduced to ensure that the prediction results conform to the basic laws of fluid mechanics (such as runoff along the direction of gravity and non-negative drainage rate), thus guaranteeing the rationality of the prediction results.
[0032] Traditional data-driven deep learning models, while capable of learning the input-output mapping from a large number of samples, often lack an understanding of the fundamental laws of the physical world, potentially outputting results that violate common sense in fluid mechanics, such as runoff against gravity or negative drainage rates. To address these issues, this invention significantly improves the reasonableness of prediction results by introducing a physical perception loss. The proportion of samples with predictions violating physical laws (such as anti-gravity runoff and negative drainage rates) is reduced from 12.5% in traditional methods to 0.8%, meaning that the model's analytical results truly possess engineering reference value, achieving physical consistency and reliability.
[0033] This invention incorporates multiple physical penalty terms into the traditional training loss function. For example, if the network predicts a runoff direction that significantly deviates from the actual road slope, or if the predicted drainage rate is negative (meaning water is increasing), or if it forcibly predicts a direction even when there is no runoff, the loss function will add a large penalty value, forcing the network to correct its behavior in subsequent learning. By adding these physical constraints, the reasonableness and accuracy of the prediction results are ensured. The prediction error of the runoff direction was reduced by 23.4%, and the occurrence rate of the anomalous negative drainage rate dropped sharply from 12.5% to 0.8%, significantly improving the reliability of the prediction results.
[0034] 4. To address the issues of traditional methods having single output parameters and ignoring inter-task correlations, a multi-task learning framework is built to improve the model's generalization ability and enable simultaneous and accurate prediction of multiple relevant parameters such as water accumulation stage, area, runoff direction, and water receding rate.
[0035] Traditional single-task learning methods train multiple models separately, which not only wastes computational resources but, more importantly, ignores the correlation between tasks, leading to decreased model generalization ability and potentially contradictory predictions (e.g., predicting a clear runoff direction in the absence of runoff). To address these issues, this invention uses the final fused features of the network as a common knowledge base. Starting from this knowledge base, five parallel task heads are derived to learn water accumulation stage classification, area regression, direction prediction, rate estimation, and runoff state judgment, respectively. In this way, knowledge learned by one task (e.g., large area often corresponds to severe water accumulation) can be shared by other tasks. Multi-task learning not only improves the prediction accuracy of individual tasks (average accuracy improvement of 12.3%) but also reduces the number of parameters in the entire model by 35.6% due to feature sharing, resulting in higher training efficiency—a win-win situation.
[0036] The multi-task learning framework yielded significant benefits for each sub-task: the accuracy of water accumulation stage classification improved by 15.4%; the mean absolute error (MAE) of water accumulation area proportion regression decreased by 22.3%; the MAE of runoff direction prediction decreased by 23.4%; the MAE of receding rate estimation decreased by 18.9%; and the accuracy of runoff state judgment improved by 11.2%. These data demonstrate that this invention can not only accurately determine the presence of water accumulation but also quantitatively describe the dynamic parameters of the entire process of water accumulation from formation and development to receding, providing refined data support for road reconstruction decisions that was previously unavailable through manual inspections or simple image processing. By combining deep learning with prior knowledge of fluid mechanics, this invention significantly improves the accuracy and reliability of dynamic water accumulation monitoring while ensuring real-time performance, demonstrating the technological maturity for practical application.
[0037] 5. To address the issue of low efficiency in standard 3D convolutional temporal modeling, the 3D convolutional design of temporal flows is simplified to improve the accuracy of temporal feature extraction.
[0038] Conventional 3D convolutional kernels often use symmetrical sizes (such as 3×3×3) to model changes in both spatial and temporal dimensions. However, in highway flood detection tasks, the optical flow sequence itself already contains motion information between adjacent frames, and the temporal changes are relatively gradual and have a certain inertia. Using excessively large convolutional kernels in the temporal dimension not only increases computational cost but may also lead to overfitting to short-term motion noise. The most important information in the optical flow map is actually distributed in space (the direction of water flow and the distribution of velocity on the plane). To solve the above problems, this invention uses a lighter 1×3×3 convolutional kernel. This means that the convolution operation is mainly performed in the spatial dimension (3×3), while the temporal dimension simply passes information down without complex cross-frame scanning.
[0039] Through the above improvements, the computational cost of the time-series flow was reduced by 42.3%, and the inference speed was improved by 38.7%. Even more surprisingly, due to the design being more tailored to the task, the accuracy of extracting time-series features actually improved by 5.2%.
[0040] 6. Introduce a data balancing machine to prevent the model from overfitting to cameras with a large sample size due to data imbalance.
[0041] This invention introduces a data balancing mechanism during the training phase, supporting both equal sampling and weighted sampling strategies. Equal sampling uses truncation and padding to ensure each camera receives the same number of samples for training, suitable for scenarios where equal weighting of different scenes is desired. Weighted sampling, on the other hand, allocates sampling weights according to the proportion of original samples from each camera, preserving the true distribution. In practical applications, the choice can be flexibly made based on specific needs. This processing ensures that the model can learn the water accumulation characteristics under different installation angles and lighting conditions in a balanced manner, further improving generalization ability.
[0042] 7. The Farneback algorithm is adopted as the basic framework for optical flow calculation to improve the accuracy and robustness of optical flow calculation.
[0043] Traditional Farneback algorithms have significant shortcomings when directly applied to water accumulation detection: they lack specific parameter settings, are sensitive to water surface reflection and noise, and lack temporal consistency constraints. To address these issues, this invention selects the Farneback algorithm as the basic framework for optical flow calculation in water accumulation scenarios. This algorithm, based on a polynomial expansion model, can output pixel-level motion vector fields, making it suitable for capturing subtle changes in water flow. Furthermore, this invention systematically optimizes the standard Farneback algorithm to address the specific characteristics of highway water accumulation scenarios (such as strong water surface reflection, multi-scale water accumulation areas, and rain / snow noise interference), improving the accuracy and robustness of optical flow calculation and adapting to detection needs under different environmental conditions.
[0044] 8. A sliding window mechanism is employed to segment the continuous video stream into a series of overlapping temporal segments. This preserves the continuity of the water accumulation dynamics while providing a stable data supply for real-time inference of the model. The sliding window mechanism has the following advantages: Real-time performance: Sliding window-based streaming processing does not require waiting for the entire video to finish. The window can be updated and inference can be triggered as soon as a frame is received (when the window is full), which meets the real-time processing requirement of 30fps.
[0045] Temporal continuity: The high overlap ratio ensures that the input sequences of adjacent inference times are highly correlated, so that the output water accumulation parameters transition smoothly on the time axis, avoiding the jump caused by independent detection frame by frame.
[0046] Memory efficiency: It uses a fixed-size buffer, and memory usage is only related to the window size and does not increase with the video duration, making it suitable for long-term edge deployments.
[0047] 9. Improve overall detection accuracy and efficiency: On the standard test set, the overall detection accuracy of this method (i.e., the weighted average accuracy of each task) is improved by 28.6% compared with the original dual-stream network, while the processing speed reaches 30fps, which helps meet the needs of video processing and analysis of a large area of highways across the country.
[0048] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0049] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1A flowchart of an intelligent detection method for dynamic water accumulation on highway pavement according to an embodiment of the present invention; Figure 2 This is an overall architecture diagram of the intelligent detection method for dynamic process of water accumulation on highway pavement according to an embodiment of the present invention; Figure 3 This is a diagram of a dual-stream fusion neural network structure according to an embodiment of the present invention; Figure 4 This is a flowchart of the dynamic feature fusion algorithm according to an embodiment of the present invention; Figure 5 This is a structural diagram of a multi-task learning framework according to an embodiment of the present invention; Figure 6 This is a flowchart of the physical constraint loss function according to an embodiment of the present invention; Figure 7 This is a system deployment architecture diagram according to an embodiment of the present invention; Figure 8 This is a training flowchart according to an embodiment of the present invention; Figure 9 This is a real-time detection timing diagram according to an embodiment of the present invention; Figure 10a and Figure 10b These are attention maps with and without gradient guidance, respectively. Figure 11 This is a network structure diagram of a multi-task learning framework according to an embodiment of the present invention. Detailed Implementation
[0050] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0051] This invention proposes an intelligent detection method for the dynamic process of water accumulation on highways. Utilizing a deep neural network, it monitors the entire process of water accumulation, development, and receding on highways in real time, outputting key parameters such as water accumulation area, runoff direction, and receding rate, serving as a decision-making reference for the upgrading and reconstruction of road sections. This method integrates watershed attention, dynamic feature fusion, multi-task learning, and physical perception loss to achieve high-precision, multi-parameter, and physically consistent real-time monitoring.
[0052] like Figure 1 and Figure 2 As shown in the figure, the intelligent detection method for dynamic process of water accumulation on highway pavement according to an embodiment of the present invention includes the following steps: S1: Collect videos from multiple sections of the highway, preprocess the video frames of each video, and calculate the dense optical flow of adjacent frames to obtain the optical flow sequence.
[0053] Specifically, this step involves data preprocessing and optical flow calculation. Videos from multiple sections of the highway are collected, with training data sourced from surveillance videos deployed across these sections. Each video segment is configured with a frame-level annotation file. The annotation file includes the stage of water accumulation (five categories), water accumulation area percentage (continuous values from 0 to 1), runoff direction (0 to 360° or invalid value -1), receding rate (non-negative real number), and runoff state (binary category).
[0054] Based on the configuration file settings for the temporal sequence length (default 5 frames) and input image size (e.g., uniformly scaled to a fixed resolution), all videos are traversed. Preprocessing is performed on each video frame, including: pairing each video file with its corresponding annotation file; normalizing the size, converting the color space, and standardizing each video frame; adjusting to the target size; and storing the adjusted frames in a frame sequence list. Optical flow calculation is then performed on the preprocessed videos, including using an improved Farneback algorithm to calculate the dense optical flow between adjacent frames, resulting in an optical flow sequence (length equal to the frame number minus 1). This optical flow sequence represents motion information.
[0055] A sliding window (window size equal to the temporal length, step size determined based on an 80% overlap rate) is used to extract training samples from the frame sequence and optical flow sequence. Each sample is encapsulated into a triplet, including: frame sequence, optical flow sequence, and corresponding multi-task annotation.
[0056] S2, construct a dual-stream fusion neural network architecture, which includes a spatial stream network, a temporal stream network, and a dynamic feature fusion mechanism.
[0057] In this step, a watershed attention mechanism is integrated into the spatial flow network to extract spatial features of the image; a temporal flow network is used to process the optical flow sequence to capture temporal dynamic information; and a dynamic feature fusion module adaptively fuses spatial and temporal features.
[0058] To achieve accurate perception of the dynamic process of water accumulation, this invention constructs a dual-stream fusion neural network. The core idea of this network is to simulate how the human visual system perceives the world: it must see both what the water is (i.e., its spatial appearance) and how the water moves (i.e., its sequential motion). Its overall processing flow can be abstracted into the following mathematical model, expressed mathematically as follows: (1) Where X is the input image, Flow is the optical flow sequence, and Y is the multi-task output.
[0059] This model aims to define the entire logical chain from input to output. First, for any frame of image X, its spatial features... Spatial Flow Network Responsible for extraction. Simultaneously, to capture the dynamics of water accumulation, this invention calculates the optical flow field (Flow) between consecutive frames and inputs it into the temporal network (TemporalNet) to obtain temporal features characterizing the motion patterns. Based on spatial characteristics and time series characteristics The inherent connection between the two adaptively determines how to fuse them into a more discriminative joint feature. Finally, feature fusion. The data is fed into the MultiTaskHead prediction head, which outputs all key parameters Y in parallel, including the stage of water accumulation, area proportion, runoff direction, and receding rate. The entire architecture design ensures that the network can both identify water accumulation areas and understand their dynamic evolution and flow direction.
[0060] The following is for reference. Figure 3 The structure of the dual-stream fusion neural network is explained.
[0061] S21 integrates a watershed attention mechanism into a spatial flow network to extract spatial features.
[0062] Specifically, the preprocessed image undergoes initial convolution and spatial size halving, then sequentially passes through each residual block group of the ResNet34 backbone network. A watershed attention mechanism is integrated onto the feature map of the last residual block group. The gradient information of the feature map calculated using the watershed attention mechanism automatically identifies the boundaries and center of the water accumulation region, generating an attention weight map. This attention weight map is then multiplied element-wise with the original features to generate an attention-weighted feature map. Global average pooling is then performed to obtain the spatial features related to the water accumulation. .
[0063] Spatial Flow Networks (SNNs) use ResNet34 as their backbone, and their core building block is the residual block. By introducing skip connections, the residual block enables the network to learn the residual mapping from input to output, effectively mitigating the vanishing gradient problem in deep networks and providing a stable gradient propagation path for extracting high-level features of water accumulation regions. A typical residual block is defined as follows: (2) in: is the output feature of the residual block, and x is the input feature (identity mapping); The residual function to be learned is composed of stacked convolutional layers, batch normalization layers, and activation functions. Here are the weight parameters for these layers. This structure allows the network to maintain optimization efficiency as it deepens, laying a solid feature foundation for the subsequent watershed attention mechanism, where i is the layer index.
[0064] The core task of spatial flow networks is to extract spatial features related to the height of water accumulation from a single frame image. Their design revolves around focusing on the water accumulation and suppressing the background. This invention uses the classic ResNet34 as the backbone network and innovatively embeds a watershed attention module after it. Specifically, the network receives a preprocessed RGB image as input, with a tensor dimension of B×3×H×W (B is the batch size, and H and W are the image height and width). The data first passes through an initial convolutional layer, which uses a convolutional kernel with a stride of 2 to expand the number of channels to 64 while halving the spatial size (output B×64×H / 2×W / 2), where H and W are the original height and width of the input image. This design effectively reduces the subsequent computational load while retaining sufficient feature information. Subsequently, the features are extracted hierarchically through multiple residual block groups of ResNet34.
[0065] In this invention, features are extracted hierarchically through four residual block groups of ResNet34. Each residual block group consists of multiple stacked residual units, and its identity mapping structure ensures efficient gradient propagation in deeper layers of the network, making it possible to train deeper networks. The output dimensions of the four residual block groups are as follows: ResBlock1: Maintain B×64×H / 2×W / 2, extract shallow texture and edge information; ResBlock2: The number of channels is increased to 128, and the size is reduced to H / 4×W / 4, starting to capture the local shape of the water accumulation area; ResBlock3: The number of channels has been increased to 256, the size has been reduced to H / 8×W / 8, and the features are more semantic; ResBlock4: The number of channels is increased to 512, and the size is reduced to H / 16×W / 16, thus obtaining high-level semantic features.
[0066] ResNet's hierarchical structure naturally possesses a feature hierarchy, with shallow layers focusing on details and deep layers focusing on semantics, which is crucial for distinguishing between puddles and wet roads. Meanwhile, the translation invariance of convolution operations ensures that puddles are treated equally regardless of their location in the image; while the scale invariance introduced by pooling operations helps the network adapt to puddles of varying sizes.
[0067] To further enhance the response to waterlogged areas, this invention integrates a watershed attention mechanism onto the feature map output by ResBlock4. This mechanism mimics the classic watershed algorithm, automatically identifying the boundaries and center of the waterlogged area using the gradient information of the feature map calculated by the watershed attention mechanism. It then generates an attention weight map (maintaining dimensions B×512×H / 16×W / 16) and multiplies it element-wise with the original feature map. The watershed attention mechanism allows subsequent processing to focus on the waterlogged area, effectively suppressing background interference such as road textures and shadows, thus enhancing the response to the waterlogged area.
[0068] Finally, the attention-weighted feature map is subjected to global average pooling to compress the spatial dimension, resulting in a 512-dimensional feature vector. ∈ ×512. This vector encapsulates the spatial information most relevant to water accumulation in the entire image and serves as the final output of the spatial flow network. The entire network consists of differentiable convolution, pooling, and activation operations, supporting end-to-end gradient backpropagation to ensure training feasibility.
[0069] The watershed attention mechanism is explained below. This invention introduces a watershed attention mechanism in the last layer of the spatial flow network (after ResBlock4). This mechanism draws on the idea of the watershed algorithm in classic image segmentation, using the gradient information of the feature map to automatically identify the boundary and core of the water accumulation region, generating spatial attention weights, thereby guiding the network to focus on the discriminative region and suppressing the background response.
[0070] The core of the watershed algorithm in this invention lies in utilizing gradient information to locate region boundaries—regions with high gradient values often correspond to the boundaries between different regions. This characteristic aligns with the needs of water accumulation detection: the edges of water accumulation areas typically exhibit drastic changes in image brightness and texture, serving as a key point for distinguishing between water accumulation and non-water accumulation areas. The watershed attention mechanism proposed in this invention aims to simulate the edge-finding process of the watershed algorithm, enabling the neural network to automatically identify regions with high gradients in the feature map (i.e., potential water accumulation edges), and guide the network to focus on these regions and their interiors in subsequent calculations by generating attention weights. This mechanism uses the gradient magnitude of the feature map as an explicit spatial prior, transforming it into an attention weight map between 0 and 1 through differentiable operations, and multiplying it element-wise with the original features, thereby enhancing the response of water accumulation areas and suppressing background interference. This design, which integrates classic image processing algorithm ideas into deep networks, not only endows the model with geometric interpretability but also significantly improves its robustness and discriminative ability under complex road conditions.
[0071] Through the above design, the watershed attention mechanism enables the network to spontaneously learn the spatial distribution characteristics of the water accumulation area without additional annotation, providing a purer and more discriminative spatial feature representation for subsequent temporal feature fusion and multi-task prediction.
[0072] The watershed attention mechanism is an image segmentation method based on topological features. This invention transforms the region delimitation idea of this algorithm into a learnable attention generation paradigm, enabling the network to adaptively focus on the water accumulation edge region with drastic gradient changes. The attention mechanism of this invention aims to allow the neural network to simulate this edge-finding process: automatically identifying regions with high gradients in the feature map and assigning them higher weights, thereby strengthening the representation of the water accumulation edge.
[0073] The watershed attention mechanism is embedded in a lightweight subnetwork, and the computation process is as follows: 1. Feature Dimensionality Reduction and Local Pattern Extraction: First, in order to reduce computational complexity and extract more discriminative local features, this invention uses a convolutional layer with a kernel size of 3×3. The input X is transformed to halve the number of channels. Then, intermediate feature maps are obtained by applying batch normalization (BN) and ReLU activation functions. .
[0074] Specifically, for the feature map output by the spatial stream The first convolutional layer (3×3) transforms the input feature map by halving the number of channels. Specifically, the number of channels is halved to C / 2 to reduce computational cost and extract local structural information. Subsequently, a batch normalization layer and ReLU activation are applied to obtain the intermediate feature map. =ReLU(BN( (X))), where This process can be viewed as a nonlinear compression of the original features, while preserving crucial gradient change information.
[0075] 2. Gradient information perception: Calculate intermediate feature maps The gradient magnitude map G is obtained by calculating the gradients in the horizontal and vertical directions. The gradient magnitude map G is used to reflect the spatial variation intensity at each location in the feature map. This invention utilizes the feature map... The spatial gradient is explicitly calculated to simulate the detection of terrain ridgelines in traditional algorithms.
[0076] Gradients in the horizontal and vertical directions The gradient magnitude map G can be obtained efficiently through the difference method or the Sobel operator. ,in The gradient magnitude G reflects the intensity of spatial change at each location in the feature map. High response regions correspond precisely to potential target boundaries, which perfectly aligns with the logic of the watershed algorithm in finding "ridgelines".
[0077] 3. Attention Weight Generation: This involves generating intermediate feature maps... The input is fed into the second convolutional layer for mapping to generate the original score map. Attention weights are then generated through the Sigmoid activation function to obtain the final attention weight map. The attention weight map is used to represent the probability that the location belongs to a water accumulation area. Specifically, will A second convolutional layer, consisting of a 1×1 convolutional layer, is input to compress the number of channels to 1, generating a single-channel raw attention response map. The response value at each spatial location is then normalized to the [0,1] interval using the Sigmoid function, resulting in the final attention weight map A: A = σ( ( )),in Attention weight map A reflects the importance of different pixel locations for water accumulation detection; a higher value indicates that the location is more likely to belong to a water accumulation area or its boundary.
[0078] 4. Feature Enhancement: The original input feature map X is element-wise multiplied (⊙) with the attention weight map A to enhance features, strengthen important regions, and suppress background noise, generating the attention-weighted feature map X' as: X' = X⊙A, where After multiplication, the feature response of the water accumulation area is enhanced, while the features of the background area are suppressed, thereby improving the discriminative power of the feature representation.
[0079] In summary, the watershed attention mechanism ensures its stability and effectiveness in actual training. First, the output of the sigmoid function is bounded to [0,1], ensuring the boundedness and monotonicity of the attention weights. Second, the sigmoid function and the preceding convolutional operations are continuously differentiable, guaranteeing the differentiability of the entire module, allowing it to be seamlessly embedded into the entire network and trained end-to-end through backpropagation.
[0080] Regarding convergence, let the total loss function be L and the parameters of the attention module be θ. Its gradient can be obtained using the chain rule: (3) in, The term involves the derivative σ'(x) of the sigmoid function. Since σ'(x) ≤ 1 / 4, meaning its derivative has a clear upper bound, it effectively suppresses the over-amplification of gradients during backpropagation, thus avoiding the gradient explosion problem and ensuring the training stability of deep networks. This property enables the watershed attention mechanism to stably converge to the optimal solution when dealing with complex road scenarios.
[0081] The entire watershed attention mechanism initializes the convolutional layer weights using the Kaiming normal distribution, and initializes the batch normalization layer weights to 1 with a bias of 0 to ensure training stability. Since all operations are differentiable, this module can be trained end-to-end with the entire network, adaptively learning the optimal attention distribution without any post-processing steps.
[0082] Through the above design, the watershed attention mechanism achieves two key objectives: first, it utilizes gradient information to simulate the region segmentation concept of the watershed algorithm, enabling the network to perceive the gradient differences between the water accumulation edge and the interior, resulting in a geometrically interpretable attention map; second, it specifically enhances water accumulation features, significantly improving the model's robustness in complex environments. Through this mechanism, the network can focus on regions with drastic gradient changes and the most likely water accumulation boundaries during forward propagation, thereby extracting more discriminative spatial features.
[0083] Furthermore, this invention proposes an enhanced version based on the aforementioned basic watershed attention mechanism. By explicitly introducing gradient guidance, it further improves performance and strengthens the intrinsic connection between the watershed attention mechanism and the classic watershed algorithm. The classic watershed algorithm uses image gradients as the core basis for region segmentation, with high gradient values often corresponding to region boundaries. This invention allows the attention module to directly utilize gradient information when generating weights, thereby more accurately focusing on the edges of water accumulation.
[0084] (1) Gradient map calculation: The intermediate feature map is calculated using the Sobel operator. The gradients are calculated in both the horizontal and vertical directions. The gradients from multiple channels are averaged across the channel dimension to obtain a single-channel gradient magnitude map. .
[0085] Specifically, for the feature map after the first layer of convolution dimensionality reduction (from input feature map) through (Obtained through convolution, batch normalization, and ReLU activation), this invention first uses the Sobel operator (3×3 convolution kernel) to calculate its spatial gradient. The horizontal gradient maps are then obtained. and vertical gradient map Then, the gradient maps of multiple channels are averaged along the channel dimension to obtain a single-channel gradient magnitude map. : .
[0086] (2) Gradient feature fusion: The gradient map G is fused with the feature map after the first layer of convolution for dimensionality reduction. By stitching along the channel dimension, the fused features are obtained. , will integrate features The input to the second convolutional layer is mapped to generate the original score map, and attention weights are generated through the Sigmoid activation function.
[0087] Specifically, the gradient map G is compared with the feature map after the first layer of convolutional dimensionality reduction. By stitching along the channel dimension, the fused features are obtained. This fused feature serves as input for subsequent attention weight generation, enabling the calculation of weights to directly perceive gradient information, thus simulating the idea in the watershed algorithm that high gradient values correspond to boundaries.
[0088] (3) Gradient correlation loss: An auxiliary loss function is introduced to measure the attention weight graph. With gradient magnitude plot The linear correlation between them.
[0089] Specifically, to further guide the attention weights A towards the region of high gradient values, this invention introduces an auxiliary loss function: (4) in The Pearson correlation coefficient is... Used to measure attention maps With gradient magnitude plot The linear correlation between them.
[0090] Specifically, and Flatten each into a one-dimensional vector and The formula for calculating the correlation coefficient is: Minimizing the negative correlation coefficient is equivalent to maximizing and The correlation between the attention weights and the gradient magnitude is encouraged, thus aligning the spatial distribution of the attention weights with the gradient magnitude. This auxiliary loss is added to the total loss with a small weight (λgrad=0.1). (See Equation 20 in step S4), along with the task loss and physical perception loss, participate in network optimization, encouraging the attention weights to maintain spatial distribution consistent with the gradient magnitude. This ensures that the optimization of the main task is not affected.
[0091] Effect verification: This invention randomly selected 100 water accumulation samples on the test set and compared the intersection-union ratio (IoU) of the attention map A before and after the introduction of gradient guidance with the actual water accumulation area mask M. Figure 10a and Figure 10b These are attention maps with and without gradient guidance, respectively. Figure 10a and Figure 10bThe comparison shows that after adding gradient guidance, the IoU increased from 0.52 to 0.68, and the high attention value region closely matched the edge of the water accumulation, proving that the watershed-like edge focusing ability was learned.
[0092] S22, the temporal flow network uses a 3D convolutional network to process optical flow sequences, extract temporal features, and capture the spatiotemporal information of water movement.
[0093] The temporal flow network is responsible for capturing the dynamic changes of water accumulation, and its input is an optical flow sequence calculated between consecutive frames. To simultaneously encode spatial structure and motion patterns, this invention employs 3D convolution as the basic computational unit of the temporal flow network. Specifically, to effectively capture the dynamic changes of water accumulation in the temporal dimension, this invention designs a lightweight temporal flow network specifically for processing optical flow sequences calculated from consecutive video frames. The core of this network uses stacked 3D convolutional layers to finely analyze motion patterns in the spatial dimension while maintaining information coherence in the temporal dimension.
[0094] This invention designs the 3D convolutional kernel size in temporal flow networks by fixing the temporal dimension of all 3D convolutional kernels to 1 and setting the spatial dimension to 3×3, i.e., the convolutional kernel size is 1×3×3. This design can achieve the following effects: Focusing on spatial patterns: The optical flow map of each frame (i.e. each time step) in the optical flow sequence has encoded the motion information at that moment. The 3D convolutional kernel does not expand in the temporal dimension, which is equivalent to extracting spatial features independently for each frame, thereby focusing on learning the spatial motion patterns of the water accumulation area (such as water flow direction, diffusion range, etc.).
[0095] Maintaining temporal integrity: Although the convolutional kernel does not slide in the temporal dimension, the entire temporal flow network can still aggregate information from different time steps and preserve the temporal context by stacking multiple 3D convolutional layers and temporal pooling operations.
[0096] Improved computational efficiency: The number of parameters in a 1×3×3 convolution kernel is much smaller than that in a 3×3×3 kernel, which reduces model complexity and facilitates real-time processing.
[0097] Experiments show that the 1×3×3 kernel design reduces the computational cost of the temporal flow network by about 40% while ensuring the dynamic capture capability of water accumulation, and improves the inference speed by more than 35%, without incurring any additional loss of accuracy.
[0098] Furthermore, to achieve real-time monitoring of the dynamic process of water accumulation on highways, it is necessary to construct a fixed-length time-series window using time segments of fixed length as input to capture the evolution of water accumulation over time. This invention designs a time-series data processing mechanism based on a sliding window to ensure the efficient and continuous construction of an input sequence that meets the model requirements from a continuous video stream. The core idea of the sliding window is to maintain a fixed-capacity first-in-first-out (FIFO) buffer to cache the most recent historical frames and their corresponding optical flow information. Whenever a new frame arrives, the system adds it to the buffer while removing the oldest frame, thus always maintaining the timeliness and continuity of the data within the window. When the window is full, a model inference is triggered, outputting the water accumulation detection result at the current moment.
[0099] Considering that the formation and receding of water is a relatively continuous process, and to balance computational overhead with the integrity of temporal information, this invention sets the window size (i.e., the number of input frames) to 5 frames by default. Simultaneously, to improve the temporal resolution of detection, a window overlap mechanism is introduced, with a default overlap ratio of 80%. This means that the window slides forward 1 frame each time (step size = 5 × (1 - 0.8) = 1 frame), resulting in an overlap of 4 frames between adjacent inference input sequences. This high overlap rate ensures smooth capture of temporal changes while avoiding detection jitter caused by frequent context switching.
[0100] The data management process for the sliding window is as follows: 1) Frame buffer: Responsible for storing raw image frames. Each new image frame is immediately added to the end of the buffer upon receipt; if the buffer length exceeds the window size (5 frames), the oldest frame at the beginning is discarded.
[0101] 2) Optical Flow Buffer: Optical flow is motion information calculated based on adjacent frames, so its number is always one less than the number of frames. After calculating the optical flow of each pair of adjacent frames, the system stores it in the optical flow buffer and updates it according to the FIFO principle.
[0102] 3) Ready state: The window data is considered complete and ready for inference only when the frame buffer contains 5 frames of images and the optical flow buffer contains 4 frames of optical flow. This checking mechanism ensures the correctness of the input data.
[0103] 4) Sequence Acquisition and Inference: Once the window is ready, the frame sequence and optical flow sequence in the current buffer are copied out to form a tensor conforming to the model input format (after preprocessing), which is then fed into the dual-stream fusion network for forward computation. After inference is completed, the system waits for the next frame to arrive and repeats the above process.
[0104] Through the above design, the sliding window mechanism cuts the continuous video stream into a series of overlapping temporal segments, which not only preserves the continuity of the water accumulation dynamics, but also provides a stable data supply for the model's real-time inference.
[0105] Based on the aforementioned 3D convolution and sliding window design, the temporal flow network constructed in this invention organizes the optical flow sequence into a 5-dimensional tensor and inputs it into a multi-layered stacked 1×3×3 convolutional layer, progressively transforming the input 5-dimensional tensor (dimensions B×2×T×H×W) into a high-order motion feature representation. Each convolutional operation performs sliding window calculations along the spatial dimension (H, W) to extract local motion features; the temporal dimension T is retained as an independent dimension in the output feature map of each layer until compression and aggregation in subsequent temporal pooling layers. The temporal pooling layer averages the temporal dimension T, aggregating information from different times into a global motion feature vector. A fully connected layer maps this global motion feature vector to the same dimension as the spatial features, yielding the temporal features related to water accumulation. This design ensures that the network can independently maintain time step information at each layer, enabling lower-layer networks to capture instantaneous motion details, while higher-layer networks integrate long-term motion trends by expanding the receptive field.
[0106] Specifically, the 5-dimensional tensor has dimensions B×2×T×H×W, where B is the batch size, 2 corresponds to the horizontal and vertical components of the optical flow, T is the temporal length, and H and W are the height and width of the image. This optical flow data visually reflects the motion trajectories of pixels between adjacent frames. The 5-dimensional tensor is input into stacked 3D convolutional layers, where all convolutional kernels in the 3D convolutional layers are 1×3×3 in size.
[0107] To extract higher-order motion features step by step, the network stacks three 3D convolutional layers. The first convolutional layer uses a stride of 2, expanding the number of channels to 64 while halving the spatial size, resulting in an output dimension of B×64×T×H / 2×W / 2, achieving initial capture of local motion details. The second convolutional layer continues with a stride of 2, increasing the number of channels to 128 and further reducing the spatial size to H / 4×W / 4, resulting in an output of B×128×T×H / 4×W / 4, thus obtaining motion patterns with a larger receptive field. The third convolutional layer, through appropriate design (combining global pooling and a larger stride), compresses the spatial feature map to 1×1, resulting in a feature map of B×256×T×1×1. At this point, the motion information of the entire image has been aggregated in each time slice.
[0108] It should be noted that the 3D convolution kernel used in this invention has a size of 1×3×3. This design is based on the specific consideration of water accumulation detection tasks: optical flow itself is already a condensation of temporal information, so the size of the convolution kernel in the time dimension is set to 1, which aims to focus on the analysis of motion patterns in the spatial neighborhood, while avoiding the computational burden caused by overly complex temporal modeling, thus achieving effective separation of space and time.
[0109] Then, a temporal pooling layer is used to average the time dimension T, aggregating information from different times into a global motion feature vector of dimension B×256. This ensures the model's robustness to the length of the input sequence and enhances the consistency of temporal features. Finally, a fully connected layer maps this 256-dimensional vector to the same dimension (128-dimensional) as the spatial features to facilitate subsequent fusion operations, ultimately outputting a temporal feature vector of dimension B×128.
[0110] Through this layered architecture, the temporal flow network not only has the ability to extract features at multiple scales from local to global, but also effectively captures dynamic information such as the direction and speed of water movement, laying the foundation for accurately judging runoff trends and receding rates.
[0111] In this invention, the motion information required by the temporal flow network is obtained by calculating the dense optical flow field between video frames. Considering the unique characteristics of highway flooding scenarios (such as strong water surface reflection, multi-scale flooded areas, and rain / snow noise interference), this invention employs an improved Farneback algorithm as the basic framework for optical flow calculation. This algorithm, based on a polynomial expansion model, can output pixel-level motion vector fields, making it suitable for capturing subtle changes in water flow. Furthermore, the improved Farneback algorithm enhances the accuracy and robustness of optical flow calculation. Specifically, for flooded scenarios, this invention uses an improved Farneback algorithm as follows: 1. Parameter Set Adaptation and Optimization: By analyzing the multi-scale distribution characteristics of the water accumulation area, the algorithm parameters were adjusted to better suit the water accumulation scenario. Specifically, the number of pyramid layers was set to 3 to balance large-scale water accumulation with local details; the window size was increased to 15 pixels to suppress noise by utilizing the spatial smoothness of optical flow in the water accumulation area; the number of iterations was increased to 3 to gradually correct the initial estimation error; and the polynomial order was increased to 5 to better fit the complex brightness distribution of the water surface caused by reflection and illumination changes. Experiments show that this parameter optimization reduced the average optical flow angle error by 18.3% and the abnormal optical flow value by 32.5%.
[0112] 2. Adaptive Multi-Scale Processing: Significant scale differences exist between various water accumulation scenarios (e.g., water accumulation on roads versus water accumulation along lane lines). To address this, this invention designs an adaptive multi-scale processing strategy: based on the distribution characteristics of water accumulation areas in the image, the number of pyramid layers and scaling factor are dynamically selected. For large-scale water accumulation, a scaling factor of 0.5 and a 3-layer pyramid are used, while for localized water accumulation, a scaling factor of 0.7 and a 2-layer pyramid are used. Simultaneously, the optical flow transfer between scales is upgraded from nearest-neighbor interpolation to bilinear interpolation, and the transfer results are smoothed, effectively reducing the discontinuities caused by scale transformation. This strategy improves the accuracy of large-scale water accumulation estimation by 22.1% and the ability to capture local details by 15.8%.
[0113] 3. Optical Flow Field Post-processing: The optical flow field directly output by standard algorithms often contains outliers caused by reflection and occlusion. This invention introduces a targeted post-processing procedure: First, abnormal optical flow points (such as abrupt amplitude changes or directional deviations) are identified through neighborhood consistency detection and corrected using median filtering or interpolation; then, a smoothing constraint (Gaussian filtering or bilateral filtering) is applied to the optical flow field to suppress noise while preserving moving edges; finally, mirror filling is applied to the image boundary regions to eliminate boundary effects. Post-processing reduces the proportion of abnormal optical flow values by 45.2% and improves the accuracy of boundary region estimation by 19.6%.
[0114] 4. Enhanced Robustness to Outliers: Specular reflections on water surfaces can violate the assumption of constant brightness, leading to optical flow estimation failure. This invention designs an outlier handling mechanism: Reflective regions are detected through brightness thresholding and gradient analysis; in these regions, the weight of optical flow estimation is reduced or neighboring confidence values are directly borrowed; Gaussian filtering is performed on the input image to suppress sensor noise; simultaneously, confidence levels for optical flow estimation are calculated for each pixel (based on gradient strength, neighborhood consistency, etc.), and conservative strategies are adopted for low-confidence regions. These measures improve the optical flow accuracy in reflective regions by 35.8% and the stability in noisy environments by 28.3%.
[0115] 5. Temporal Consistency Constraint: While the motion of water accumulation is continuous in time, the standard Farneback algorithm calculates it independently frame by frame, easily leading to abrupt changes in optical flow between frames. This invention introduces a temporal consistency constraint: using the optical flow field of the previous frame as the initial value for estimation in the current frame to provide a priori motion inertia; performing temporal filtering (such as moving average) on the optical flow field of consecutive frames to suppress abrupt changes; and adding a temporal consistency loss term to the optical flow energy function to guide the algorithm to output a temporally smooth optical flow field. After the improvement, the temporal similarity of optical flow between adjacent frames is increased by 38.6%, and the estimation accuracy of dynamic water accumulation regions is improved by 24.7%.
[0116] The five improvements mentioned above are not isolated additions, but rather synergistic, collectively enhancing the performance of optical flow computation in water accumulation scenarios. On a test set covering various weather conditions, lighting, and water accumulation patterns, the optimized optical flow algorithm, compared to the standard Farneback algorithm, reduced the average angular error by 26.8%, decreased the proportion of anomalous optical flow values by 52.3%, while increasing computation time by only 18.5% (still within the acceptable range for real-time processing). These improvements provide more accurate and reliable motion feature inputs for subsequent temporal flow networks, forming a crucial foundation for the overall solution to achieve high-precision dynamic water accumulation detection.
[0117] Furthermore, in practical deployments, the system typically needs to connect to cameras on multiple road sections, and the number of samples collected by different cameras may vary significantly (e.g., main roads and ramps). To avoid overfitting the model to cameras with large sample sizes due to data imbalance, this invention introduces a multi-camera data balancing mechanism during the training phase: supporting both equal sampling and weighted sampling strategies. Equal sampling uses truncation to ensure that each camera has the same number of samples participating in training, suitable for scenarios where equal weights are desired for each scene; weighted sampling allocates sampling weights according to the proportion of original samples from each camera, preserving the true distribution. In practical applications, the appropriate strategy can be flexibly chosen based on specific needs. This processing ensures that the model can learn the water accumulation characteristics under different installation angles and lighting conditions in a balanced manner, further improving generalization ability. This invention ensures balanced training of data from different cameras through the aforementioned multi-camera data balancing.
[0118] S23, Initiate the dynamic feature fusion mechanism based on spatial features. and time series characteristics The system adaptively calculates the fusion weights of spatial and temporal flows, and dynamically fuses spatial and temporal features based on the fusion weights to generate fused features.
[0119] The contribution of static appearance features extracted by spatial flow networks (such as the reflectivity of water accumulation areas) and motion information (such as water flow velocity) captured by temporal flow networks to water accumulation assessment varies dynamically across different scenarios. For example, appearance features are more critical in the early stages of water accumulation, while motion information dominates during runoff. To adaptively fuse features from these two modalities, this invention proposes a dynamic feature fusion mechanism. Its core idea is to calculate fusion weights in real time based on the relevance of the features themselves. This mechanism can adaptively evaluate the contribution of spatial and temporal features according to the input content, achieving the optimal combination of information.
[0120] Dynamic feature fusion utilizes a lightweight weight generation network to adaptively calculate the fusion weights of spatial and temporal streams based on input features, achieving an optimal combination of multimodal information. The dynamic feature fusion module includes: a fully connected layer for spatial features, mapping spatial features to a fixed dimension; a fully connected layer for temporal features, mapping temporal features to a fixed dimension; a weight generation network, generating adaptive weights based on the fused features; and a weighted fusion layer, dynamically fusing spatial and temporal features according to the weights.
[0121] Specifically, before fusion, this invention needs to clearly define the objects to be fused. When extracting image features, the spatial flow network, after multiple convolutional layers and a watershed attention mechanism, outputs a feature vector representing the appearance of the water accumulation area, denoted as... Simultaneously, after processing the optical flow sequence, the temporal flow network outputs a feature vector representing the water accumulation movement pattern, denoted as... These two feature vectors carry information from different modalities and are the input to the dynamic fusion module.
[0122] like Figure 4 As shown, the original spatial features are first mapped through two independent mapping networks. and time series characteristics Each is mapped to the same dimension through a multilayer perceptron (MLP). From the feature space, we obtain the transformed features. and For example, features from two sources can be processed into a comparable space. Features output by a spatial flow network. High-dimensional (e.g., 512-dimensional) features contain rich static details; while the features output by temporal streaming networks... Lower dimensionality (e.g., 128 dimensions) provides a compressed representation of motion patterns. Therefore, this invention first uses two different multilayer perceptrons (MLPs) to respectively... and Mapping to the same dimensional space (e.g., 128 dimensions), we get and This unifies the feature scale and achieves preliminary dimensionality reduction and noise reduction, thus aligning the two heterogeneous features and facilitating subsequent comparison and fusion.
[0123] (5) Then, the transformed spatial features and The two modalities are concatenated to form a joint feature vector containing information from both modalities. , ], will combine the feature vectors [ , Input to a lightweight weight generation network Weight generation network The core task is analysis and The correlation under the current input is calculated, and two scalar weights are output. and , representing the importance of spatial and temporal features, respectively. This network employs a three-layer fully connected structure, capturing the complex nonlinear relationships between features through layer-by-layer dimensionality reduction. It learns the complex relationship between the two types of features, and the final layer outputs two original logical values, which are then normalized using the Softmax function. The spatial feature fusion weights are then adaptively calculated. Weights for fusion with temporal features These two weights satisfy... And all of them are non-negative, that is ∈[0,1], forming a probability distribution. Thus, the generated weights naturally possess the physical meaning of importance coefficients: when the information of a certain modality is more discriminative, its corresponding weight will approach 1. Spatial feature fusion weights Weights for fusion with temporal features These represent the importance of spatial information and temporal information under the current input, respectively.
[0124] (6) Subsequently, spatial and temporal features are dynamically fused based on weights, that is, the generated weights are used to perform a weighted summation of the mapped features to generate a fused feature vector. This fused feature vector integrates spatial and temporal information, and the ratio between the two is adaptively adjusted according to the input scenario. When When the value is close to 1, it indicates that the network considers the static image information of the current frame (such as the area of water accumulation) to play a decisive role in the judgment; when... When the dominant factor is a dynamic weighting, it indicates that motion information (such as runoff velocity) is more critical. This dynamic weighting allows the fused feature F_fused to flexibly prioritize the most effective information source according to different scenarios, thus making it more robust and expressive than a fixed-pattern fusion method. Mathematically, this fusion method forms a convex combination, ensuring that gradients can be stably backpropagated, which is beneficial for the end-to-end training convergence of the entire network.
[0125] During training, the entire module (including the mapping network and the weight generation network) learns end-to-end through backpropagation, automatically learning how to generate optimal fusion weights based on the inherent relationships of the input features. This enables the model to flexibly handle various complex road conditions, from initial water accumulation to rapid runoff. This process achieves dynamic combination of the two features, with the weights directly reflecting the contribution of the corresponding modal information in the current scenario.
[0126] Finally, to further enhance the expressive power of the features, the fused features... Directly used as the final fusion feature = The input is fed into the multi-task prediction network for use by the subsequent multi-task prediction head.
[0127] Through this end-to-end learning-based dynamic weight generation mechanism, the network can automatically adjust its dependence on different information sources based on the characteristics of the input data, thereby obtaining robust and discriminative fusion features under various complex road conditions. The entire module is differentiable and can be seamlessly integrated into the entire network for joint training.
[0128] S3. Construct a multi-task prediction network and use a multi-task learning framework to simultaneously predict the water accumulation stage, water accumulation area ratio, runoff direction and water receding rate, and generate corresponding prediction results.
[0129] In the dynamic process of water accumulation, various parameters do not exist in isolation. Output parameters such as water accumulation stage, area ratio, runoff direction, and receding rate are not isolated but rather different dimensions describing the same physical process. For example, the occurrence of runoff is inevitably accompanied by dynamic changes in the water accumulation area, and the receding rate is also closely related to the water accumulation stage; the size of the water accumulation area is strongly correlated with the stage (formation, runoff, receding). Furthermore, an effective interpretation of the runoff direction must be based on the premise of confirming the existence of runoff. The core idea of the multi-task learning framework is to utilize the inherent physical relationships between water accumulation-related parameters (such as area, stage, flow direction, and rate) and, through shared feature representations, enable the model to simultaneously learn and predict multiple tasks, thereby improving the accuracy, efficiency, and logical consistency of predictions.
[0130] Multi-task learning frameworks force the model to learn a universal feature representation that can be compatible with and explain all relevant phenomena by requiring all tasks to share the underlying feature extraction network. This design enhances the robustness of features due to the mutual constraints between tasks, and also significantly improves parameter and computational efficiency, making real-time multi-parameter quantization analysis possible on embedded platforms or servers.
[0131] Specifically, generating shared and integrated features Then, five task networks were branched out to predict the water accumulation stage (5 categories), water accumulation area ratio (0~1), runoff direction (0~360°), water receding rate (≥0), and whether runoff exists (binary classification).
[0132] like Figure 5 and Figure 11As shown, the multi-task prediction network of the present invention includes a shared feature transformation layer and five parallel task-specific output layers. The five parallel task-specific output layers include: a water accumulation stage classification head task output layer, a water accumulation area ratio regression head task output layer, a runoff direction prediction head task output layer, a water receding rate estimation head task output layer, and a runoff state judgment head task output layer.
[0133] (1) Shared feature transformation layer In the shared feature transformation layer, features are fused. The input is fed into a first-layer fully connected network for dimensionality upscaling, and then the dimensionality-upgraded features are fed into a second-layer fully connected network for dimensionality reduction to obtain shared features. .
[0134] First, the 128-dimensional fusion features A two-layer fully connected network is then used to further refine higher-order shared features. The network design is as follows: The first fully connected layer maps the input dimension from 128 to 256, introducing more parameters to learn complex feature interactions. It then passes through a ReLU activation function and Dropout with a scale of 0.3 to enhance non-linearity while preventing overfitting.
[0135] The second fully connected layer compresses the 256-dimensional features back to 128 dimensions, forming the final shared features. The ReLU activation function is also used, but the Dropout ratio is reduced to 0.2 to retain more useful information.
[0136] This invention adopts a structure of first increasing dimensionality and then decreasing dimensionality, aiming to allow the network to reorganize and abstract features in a higher-dimensional space, and then compress them into a compact and expressive shared representation for use by all downstream tasks.
[0137] (2) Task-specific branches Will The tasks are distributed in parallel to five independent lightweight fully connected networks, each responsible for a specific prediction task. Specifically, the tasks will be distributed to... Simultaneously, the output layers of the water accumulation stage classification task, water accumulation area ratio regression task, runoff direction prediction task, drainage rate estimation task, and runoff state judgment task are input, and the prediction results of water accumulation stage, water accumulation area ratio, runoff direction, drainage rate, and runoff state are obtained in parallel.
[0138] The water accumulation stage classification head outputs a 5-dimensional vector, which is converted into a probability distribution using the Softmax function, corresponding to the five stages of drying, water accumulation, runoff, water receding, and water dissipation. Its structure is: fully connected layer (128→64) + ReLU + fully connected layer (64→5).
[0139] Water accumulation area ratio regression head: Outputs a scalar representing the proportion of the water accumulation area in the image (0~1). Considering the physical range of the area, the last layer uses the Sigmoid activation function to constrain the output to the [0,1] interval. Its structure is: fully connected layer (128→64) + ReLU + fully connected layer (64→1) + Sigmoid.
[0140] Runoff Direction Prediction Head: Outputs a scalar representing the angle of water flow direction (0~360°). Since the angle is periodic, direct regression is difficult. This invention first extracts features through a fully connected layer (128→64) + ReLU, then outputs a value through a fully connected layer (64→1), finally maps it to the range [-1,1] using the Tanh activation function, and then converts it to the actual angle through a linear transformation θ=(x+1)×180.
[0141] The water receding rate estimation head outputs a non-negative scalar representing the rate at which the water recedes. Considering physical meaning, the last layer uses the ReLU activation function to ensure the output is non-negative. Its structure is: fully connected layer (128→64) + ReLU + fully connected layer (64→1) + ReLU.
[0142] Runoff state determination head: Outputs a 2D vector, which, after passing through the Softmax function, yields probabilities for both non-runoff and runoff. This branch assists in determining the validity of runoff direction. Its structure is: fully connected layer (128→64) + ReLU + Dropout (0.3) + fully connected layer (64→2) + Softmax.
[0143] To ensure physical consistency of the prediction results, the final output value of the runoff direction in this invention will be adjusted based on the results of the runoff state judgment branch. If the probability of the runoff state is greater than 0.5, it is assumed that there is runoff, and the angle output by the runoff direction prediction head is used directly; otherwise, it is assumed that there is no runoff, and the runoff direction is forcibly set to -1 (indicating an invalid value).
[0144] The raw outputs, processed results, and corresponding confidence levels (probabilities) of all tasks are integrated into a structured output dictionary for use by subsequent analysis and visualization modules.
[0145] Through the above design, the multi-task learning framework of this invention can not only efficiently output multiple key parameters, but more importantly, it ensures the consistency of the internal logic among these parameters, providing a reliable data foundation for subsequent traffic improvement decisions.
[0146] In this invention, corresponding task weights and loss functions are configured for the water accumulation stage classification head task output layer, water accumulation area ratio regression head task output layer, runoff direction prediction head task output layer, water receding rate estimation head task output layer, and runoff state judgment head task output layer, respectively, and the weights for the next round are adaptively adjusted based on the loss calculated in the previous round.
[0147] Specifically, the core of multi-task learning lies in balancing the extraction of common features with the adaptation to individual tasks. Its optimization objective function is: (7) Among them, here The total task loss of the multi-task learning framework. The 128-dimensional shared feature vector, further extracted from the fused features, carries general information applicable to all tasks; This is a feature vector unique to the i-th task, used to capture the specificity of that task. The loss function for the corresponding task. These are used as weighting coefficients to balance the contribution of each task to the total loss. Regularization term. (e.g., L2 norm) is used to suppress overfitting, and λ controls the regularization strength.
[0148] The objective function is designed to take into account both the commonalities and individual characteristics of the tasks: the shared feature layer is responsible for learning a general water accumulation representation from the data, while the task-specific network branches are fine-tuned on this basis, ultimately achieving efficient joint learning of multiple tasks.
[0149] This invention quantifies the correlation between tasks, using the outputs of each task (such as predicted values or task-specific features) as random variables, and their correlation can be described by the covariance matrix: (8) in, and Let represent the outputs of the i-th and j-th tasks, respectively. The covariance matrix C is symmetric, and its elements are... This reflects the degree of correlation between task i and task j. If If the value is significantly non-zero, it indicates that there is a correlation between the two tasks that can be utilized by joint learning. In practical applications, this invention estimates the matrix through statistics of training data, verifying that there is indeed a strong positive correlation between the water accumulation-related tasks.
[0150] To balance the differences in scale and learning difficulty among the tasks, this invention assigns weights to each task: stage classification has a weight of 1.0, area regression has a weight of 2.0, runoff direction has a weight of 1.5, recession rate has a weight of 1.0, runoff state has a weight of 1.0, and physical constraints have a weight of 0.5. Furthermore, this invention introduces a dynamic adjustment mechanism: during training, if the loss of a certain task decreases slowly, its weight can be appropriately increased; conversely, it can be decreased, to maintain the balance of multi-task learning. The adaptive adjustment of task weights is explained below.
[0151] In multi-task learning, the convergence speed and difficulty of each task often differ. Using fixed weights may lead to some tasks converging prematurely while others remain underfitting, or a single task dominating training due to excessively large gradient magnitudes. Therefore, this invention introduces a weight adaptive adjustment mechanism based on task difficulty to dynamically balance the importance of each task during training.
[0152] Specifically, the weight of the i-th task in round t+1 Based on its losses in round t Adjustments will be made: (9) Here, α is the adjustment rate (default value is 0.05), which controls the sensitivity of the weights to changes in loss. The intuitive meaning of this formula is: if the current loss for a task is large (i.e., the learning difficulty is high or it has not yet converged), its weight will be appropriately reduced to avoid excessively skewing the overall gradient; conversely, if the loss is small, the weight will remain the same or slightly increase, allowing the model to continue focusing on that task. Through this mechanism of "penalizing difficult tasks and rewarding easy tasks," the network can adaptively allocate learning capacity to tasks that require more attention, thereby achieving a balance in multi-task training.
[0153] Since the weights of each task are updated independently, the sum of the weights may no longer be 1. Therefore, all weights need to be normalized after each update. (10) At the same time, to prevent the weight of some tasks from decaying to zero due to excessive losses (causing the task to be completely ignored), a lower limit for the weight can be set. (For example, 0.1), when the updated weight is lower than this value, it is fixed to 0.1. Then it participates in normalization. In actual training, this invention usually selects an appropriate α based on the scale of the task loss: for regression tasks with large loss values (such as area regression), α should be small (such as 0.01) to avoid drastic fluctuations in weights; for classification tasks with small loss values, α can be appropriately increased (such as 0.1). This mechanism has been experimentally proven to effectively balance the learning process of each task and improve the generalization ability of the overall model.
[0154] This invention selects an appropriate loss function based on the output properties of each task. In this invention, the cross-entropy loss function is configured for the output layers of the water accumulation stage classification head task and the runoff state judgment head task; the Huber loss function is configured for the output layers of the water accumulation area ratio regression head task, the runoff direction prediction head task, and the water receding rate estimation head task.
[0155] Specifically, for classification tasks (flooding stage, runoff status): cross-entropy loss is used to measure the difference between the predicted probability distribution and the true label (one-hot encoding), which is suitable for discrete category prediction.
[0156] Regression tasks (flood area, runoff direction, and drainage rate): Huber loss is used, which is defined as: (11) Where x is the prediction error and δ (default value 1.0) is the threshold. The Huber loss combines the advantages of mean squared error (MSE) and mean absolute error (MAE): when the error is small, squared loss is used to provide a smooth gradient; when the error is large, linear loss is switched to avoid outliers dominating the gradient, thereby improving the robustness of training.
[0157] For the runoff direction, considering the periodicity of angles (0° and 360° are equivalent), the minimum angle difference is taken when calculating the error. Furthermore, this loss is only calculated when the runoff state is true, avoiding the introduction of invalid gradients when there is no runoff.
[0158] Summing all the weighted task losses with the regularization term yields the final total loss. It is used to drive backpropagation and parameter updates for the entire network.
[0159] From the perspective of optimization theory, both the cross-entropy loss and Huber loss selected in this invention satisfy the Lipschitz continuity condition, and their gradient magnitudes have an upper bound. This means that under reasonable parameter initialization and learning rate settings, the gradient of the total loss function will not explode, ensuring the stable convergence of stochastic gradient descent (SGD) optimization algorithms. In actual training, this invention further enhances the robustness of the training process through gradient pruning (max_norm=1.0), ensuring that the multi-task learning framework can stably converge to an effective local optimum.
[0160] S4 uses a physical perception loss function to constrain the prediction results to conform to the laws of fluid mechanics.
[0161] This invention introduces a physics-aware loss function, integrating prior knowledge from fluid mechanics into the training process as soft constraints. This guides the model's predictions to both fit the data distribution and conform to natural laws. Specifically, the physics-aware loss function introduces fluid mechanics constraint loss during the training phase, penalizing predictions that violate physical laws and guiding the model to learn reasonable outputs. The core of the physics-aware loss function lies in transforming fundamental principles of fluid mechanics into differentiable mathematical constraints, guiding the model to output predictions that conform to physical laws. The mathematical expressions for each constraint are given below.
[0162] The physics-aware loss function consists of multiple independent constraint terms, each corresponding to a specific physical plausibility requirement. Its core idea is that when the model's predictions violate physical laws, the loss function generates a penalty term, with the penalty increasing as the violation worsens. All constraint terms are differentiable functions, ensuring that the entire loss function can participate in backpropagation end-to-end.
[0163] Specifically, the physical perception loss function includes runoff direction deviation constraint terms, water accumulation area rationality constraint terms, drainage rate non-negativity constraint terms, and runoff state and direction consistency constraint terms. Among them, the runoff direction deviation constraint is used to limit the deviation between the predicted direction and the physical constraints; the water accumulation area rationality constraint is used to ensure the physical rationality of the area prediction; and the drainage rate non-negativity constraint is used to ensure the physical meaning of the rate prediction.
[0164] like Figure 6 As shown, the corresponding prediction results are constrained by runoff direction deviation constraints, water accumulation area rationality constraints, drainage rate non-negativity constraints, and runoff state and direction consistency constraints, respectively, to obtain the runoff direction deviation penalty amount. Unreasonable penalty for water accumulation area Negative rate penalty for water discharge Penalty for inconsistency between runoff state and direction And the physical perception loss is obtained after weighted summation. Physical perception loss With mission loss Together they constitute the total loss .
[0165] 1. Runoff direction deviation constraint The flow direction of water on the road surface is primarily governed by gravity and should generally follow the transverse or longitudinal slope of the road without significant deviation. However, pure data models may predict physically impossible directions due to lighting interference or annotation noise. To avoid models predicting directions deviating from the gravitational field, this invention introduces constraints based on the principle of minimum gravitational potential energy. The optimal value for the runoff direction... Theoretically, the gravitational potential energy along this direction should be minimized: (12) Where h(x,y,θ) represents the water depth distribution along direction θ. In actual supervised learning, this invention uses the labeled true direction. As a baseline, a certain deviation is allowed, but penalties are imposed when it exceeds the tolerance range: (13) in, Take 15°. . It predicts the direction and angle. It is the actual direction and angle. It is the minimum angular difference between the predicted direction and the true direction (considering the periodicity from 0° to 360°). This is the maximum permissible deviation angle (15° in this example). This constraint only applies when the actual runoff condition is true; when... Exceed When the excess portion is reached, it will be multiplied by a weighting factor. The total physical loss is taken into account. This linear penalty form allows for a certain degree of error while penalizing excessive deviations, avoiding the oversensitivity problem that may arise from L2 penalty.
[0166] 2. Constraints on the reasonableness of water accumulation area The change in the area of water accumulation satisfies the continuity equation: (14) Physically, when water accumulation is detected in an image, its coverage area cannot be infinitely small; it must occupy at least several pixels to form a continuous region. However, in static single-frame prediction, this invention is more concerned with the numerical reasonableness of the area. A minimum physically reasonable area is set. (1% of the image area). If the model predicts the proportion of water accumulation area... If the value is too small (e.g., less than 0.01, which is 1% of the total image area), it may be due to false detection or noise. That is, when the predicted area... Below that At that time, if the prediction results are deemed to lack physical meaning, a linear penalty is imposed: (15) in The minimum reasonable area ratio (0.01 in this example) is used. This is the weighting coefficient (set to 0.2). When the predicted area is lower than this threshold, the difference between the predicted area and the threshold is penalized, encouraging the model to output a physically meaningful area value.
[0167] 3. Non-negativity constraint on water discharge rate The rate of water receding, R, is defined as the decrease in the area of accumulated water per unit time. According to the law of conservation of mass, its relationship with the rate of change of water depth is as follows: (16) Physically, the receding rate R should be non-negative (the area decreases as the water recedes, and a negative receding rate would be necessary for an increase, but here receding specifically refers to the process of water receding). If the model predicts a negative receding rate, it means the area of the water actually increases during the receding process, which clearly violates physical facts. Therefore, a penalty is imposed on the predicted negative rate: (17) in, The predicted water receding rate (unit: cm / min). Set the value to 0.1. This penalty term applies a linear penalty to negative values, ensuring that the drainage rate is always non-negative.
[0168] 4. Consistency constraints on runoff state and direction Runoff status There is a logical relationship between (whether runoff exists) and the runoff direction θ: when the model determines that the state is non-runoff ( When the runoff direction is not in a runoff state, it should be an invalid value (set to -1 in this invention). If a valid direction angle is predicted under non-runoff conditions, an inconsistency penalty is applied. (18) in This represents the runoff status (1 indicates runoff, 0 indicates no runoff). Take 0.2. When At that time, if If the deviation from -1 is penalized, the state is forced to maintain consistency with the direction.
[0169] The weighted sum of the above constraints yields the final physical perception loss: (19) This loss is similar to the task loss in a multi-task learning framework. Together they constitute the total loss, and the final total loss Loss due to multi-task (See Equation 7 in step S3) and physical perception loss The weighted summation yields the following formula: (20) Here, β is the balancing coefficient (0.5 in this example), used to adjust the strength of the physical constraints. Since all constraint terms are composed of linear or ReLU-like functions, the gradients are easy to compute and their norms are bounded, thus the total loss function can be stably used for end-to-end training. By introducing these physical constraints, the model gradually learns to avoid producing anti-physical predictions during training, significantly improving the reliability and interpretability of the output parameters. The total loss function can stably optimize the network parameters during backpropagation, guiding the model to gradually converge to a solution space that satisfies physical laws.
[0170] S5 involves a cloud platform storing, analyzing, and assessing the constrained prediction results, triggering an alert when the detected risk level exceeds a threshold. This invention supports multi-camera deployment and cloud-based analysis, offering scalability.
[0171] refer to Figure 7 The forms of early warning include SMS notifications, email notifications, and system alarms. This invention provides a visual interface to enable real-time monitoring, historical data display, and statistical analysis.
[0172] Example 1: Model Training Process This embodiment provides a training method for a road surface water detection model based on a dual-flow fusion neural network, covering the entire process from data preparation to model convergence.
[0173] 1. Data preparation and preprocessing refer to Figure 9 The training data comes from surveillance videos deployed on multiple sections of the highway. Each video is accompanied by a frame-level annotation file. The annotation content includes: water accumulation stage (five categories), water accumulation area ratio (0~1 continuous value), runoff direction (0~360° or invalid value-1), water receding rate (non-negative real number), and runoff state (binary category).
[0174] The data preparation process is as follows: First, the temporal sequence length (default 5 frames) and input image size are set according to the configuration file (e.g., uniformly scaled to a fixed resolution). Then, all video files are traversed and paired with their corresponding annotation files. For each video, images are read frame by frame, adjusted to the target size, and stored in a frame sequence list; simultaneously, the improved Farneback optical flow algorithm is used to calculate the dense optical flow between adjacent frames, obtaining an optical flow sequence (length equal to the frame number minus 1). Finally, a sliding window (window size equal to the temporal sequence length, step size determined based on an 80% overlap rate) is used to extract training samples from the frame and optical flow sequences, ensuring temporal alignment of frames, optical flow, and annotations. Each sample is encapsulated as a triple: frame sequence, optical flow sequence, and corresponding multi-task annotation.
[0175] 2. Data Augmentation Strategies To improve the model's generalization ability, data augmentation is applied to the image sequences during training. Considering the specific characteristics of the water accumulation detection task, the augmentation strategy must satisfy two constraints: it should not affect the numerical meaning of physical quantities such as the proportion of water accumulation area; and consistent augmentation parameters should be used for each frame within the same time window to maintain the continuity of motion information.
[0176] Based on this, the present invention constructs the following enhanced pipeline and applies it randomly with a certain probability: Geometric transformations: random 90° rotations and transposes (10% probability each). These transformations do not change the area ratio.
[0177] Color transformation: Randomly adjust brightness and contrast (brightness / contrast offset ±0.2, probability 30%); randomly adjust hue, saturation, and lightness (offsets are set to ±20, ±30, and ±20 respectively, probability 20%).
[0178] Noise addition: Gaussian noise (variance 10~50, probability 10%) and ISO noise simulation (probability 10%).
[0179] Blur processing: motion blur and Gaussian blur (blur kernel size limited to 3, probability 10% each).
[0180] Standardization: Pixel values are normalized to the [0,1] interval and standardized using the statistical mean (0.485, 0.456, 0.406) and standard deviation (0.229, 0.224, 0.225) of the ImageNet dataset, and finally converted into the tensor format required for network input.
[0181] During enhancement, the same random seed is used for all frames within the same time window to ensure consistency of the enhancement operation; optical flow and annotation data remain unchanged, and only the image participates in the enhancement.
[0182] 3. Model Training Implementation Model training employs an end-to-end approach, utilizing spatial flow, temporal flow, dynamic fusion, and multi-task head joint optimization. The specific implementation steps are as follows: (1) Training environment configuration First, available computing devices are automatically detected, prioritizing GPUs (such as NVIDIA Tesla series), otherwise reverting to CPUs. A dual-stream fusion model is instantiated according to the configuration file (the classification head output dimension is set to 5, corresponding to the number of categories in the water accumulation stage). The optimizer is AdamW, with an initial learning rate of 1e-4 and weight decay of 1e-5; a cosine annealing learning rate scheduler is also used to dynamically adjust the learning rate based on the total number of training epochs. The loss function is constructed as a composite function including multi-task loss and physical constraint loss, where the maximum angular deviation of the physical constraints is set to 15° and the minimum reasonable water accumulation area is set to 0.01.
[0183] (2) Training cycle In each training epoch, switch the model to training mode and enable Dropout and BatchNorm training behaviors. Obtain batch data from the data loader, transfer it to the computing device, and perform the following operations: Forward propagation: Input the image sequence and optical flow sequence into the model to obtain the prediction outputs for five tasks.
[0184] Loss Calculation: Based on the multi-task loss function, calculate the stage classification cross-entropy loss, area / direction / rate Huber loss, and runoff state cross-entropy loss respectively, and sum them with the physical constraint loss to obtain the total loss.
[0185] Backpropagation and optimization: The backpropagation of the loss function is called to calculate the gradient and perform gradient clipping (the maximum gradient norm is set to 1.0) to prevent gradient explosion. The model parameters are then updated by the AdamW optimizer.
[0186] Log recording: Records the total loss and the loss value of each task for monitoring the training process.
[0187] After each training round, evaluate the model performance on the validation set. During evaluation, gradient calculation is disabled, the model is switched to evaluation mode, and metrics for each task are calculated: stage classification accuracy, mean absolute error (MAE) of area regression, runoff direction MAE (calculated only under runoff conditions), and recession rate MAE. Hyperparameters are adjusted or training is stopped early based on the validation metrics.
[0188] (3) Training stability assurance To ensure the stable and efficient convergence of the aforementioned two-stream network during actual training, this invention incorporates a targeted design in its training strategy. The entire network employs an end-to-end multi-task joint optimization approach, with a total loss function... It is composed of a weighted average of the losses from each task and the losses from physical constraints.
[0189] During backpropagation, gradients flow through the spatial flow network, the temporal flow network, and the dynamic fusion module simultaneously. To avoid gradient explosion or instability caused by complex network structures or diverse task objectives, this invention introduces a gradient pruning mechanism during training to limit the norm of the gradient within a reasonable range, ensuring the smoothness of parameter updates. Simultaneously, this invention employs the AdamW optimizer combined with a cosine annealing learning rate scheduling strategy, enabling rapid descent in the early stages of training and fine-tuning in the later stages, effectively improving the model's convergence speed and final accuracy. Practical experience shows that, with the above strategies in place, the model can stably converge to satisfactory performance levels on various datasets.
[0190] In actual training, this invention iteratively updates the network parameters using gradient descent to optimize the total loss function. The loss function of deep neural networks is gradually reduced. Since the loss function is typically non-convex, this invention does not pursue a theoretically global optimum, but rather aims for the parameters to converge to a local optimum that effectively fits the training data. This process is guaranteed by the convergence of optimization algorithms (such as AdamW), and training stability is ensured through techniques such as learning rate scheduling and gradient pruning. The resulting model parameters enable low losses for each task while satisfying physical perception constraints, thus achieving accurate detection of the dynamic process of water accumulation. Finally, the optimal model weights on the validation set are saved for subsequent real-time detection deployment.
[0191] Example 2: Real-time Detection Process This embodiment provides an implementation method for real-time road surface water detection based on a trained dual-flow fusion model, which is suitable for deployment on roadside computing units or central servers.
[0192] 1. System initialization and video stream processing Upon system startup, the pre-trained model weight file is first loaded, the model is deployed to the specified computing device (GPU preferred), and the system switches to evaluation mode. Simultaneously, the video preprocessing module, result post-processing module, and visualization module are initialized.
[0193] The video source can be a real-time camera stream or an offline video file. The system uses a sliding window mechanism to maintain a fixed-length frame buffer sequence (the length is the same as during training, with a default of 5 frames) and a corresponding optical flow buffer sequence. The processing flow is as follows: video is read frame by frame, the current frame is preprocessed (size adjustment, color space conversion, normalization), and stored in the frame buffer; simultaneously, the improved Farneback optical flow algorithm is used to calculate the dense optical flow between the current frame and the previous frame, and stored in the optical flow buffer. When the buffer sequence reaches the preset length, model inference is triggered.
[0194] 2. Model Inference and Result Post-processing When inference is triggered, the cached frame sequence and optical flow sequence are concatenated into the network input tensor, and the dimensional order is adjusted to match the model requirements (images are adjusted to [B,C,T,H,W], and optical flow is adjusted to [B,2,T,H,W]). Forward propagation is performed in the torch.no_grad() context to obtain the raw output of the multi-task head.
[0195] The post-processing module is responsible for parsing the raw output into readable detection results: Water accumulation stage: Take the category corresponding to the maximum value in the classification logits and calculate the Softmax probability distribution.
[0196] Water accumulation area: Directly extract the area ratio value (0~1) output by Sigmoid and convert it into the actual number of pixels.
[0197] Runoff direction: Extract the angle value after Tanh activation and map it to 0~360°, and judge its validity according to the runoff status (valid when the runoff probability is >0.5, otherwise set to -1).
[0198] Drainage rate: Extract the non-negative rate value from the ReLU output, with units labeled in cm / min.
[0199] Runoff status: Determine whether runoff exists based on the binary classification Softmax output and provide the confidence level.
[0200] The processed results can be overlaid on video frames in real time and simultaneously uploaded to an analysis platform or local storage. Then, a sliding window removes the oldest frame and its optical flow, waiting for the next frame to arrive, and the above process is repeated.
[0201] Example 3: System Deployment Architecture for Road Reconstruction Decisions This embodiment presents a system deployment architecture based on the method of the present invention, which aims to provide long-term data accumulation and decision support for highway reconstruction and upgrading, rather than daily real-time monitoring.
[0202] 1. Deployment of roadside computing nodes refer to Figure 7 and Figure 9In each road section requiring assessment of renovation needs, computing server nodes (i.e., edge computing nodes) are deployed. Each node is responsible for processing the video stream from its corresponding camera. During node initialization, a pre-trained dual-stream fusion model is loaded onto the GPU (or CPU if no GPU is available) and set to evaluation mode. Simultaneously, the real-time detection module and data transmission module are initialized. The node continuously receives the video stream, calls the real-time detection system to process it frame by frame, and obtains parameters such as the water accumulation stage, area ratio, runoff direction, receding rate, and runoff status for each frame. The detection results are compressed and uploaded to the central cloud analysis platform periodically via wired network (e.g., batch uploads per hour), while also being backed up locally as files named with the node ID, camera ID, and timestamp.
[0203] 2. Central Data Aggregation and Statistical Analysis Platform The center's cloud-based analytics platform aggregates historical monitoring data from all roadside nodes, providing data storage, statistical analysis, and report generation functions for road reconstruction decisions. During platform initialization, the platform loads the analysis strategy configuration (such as statistical period, road segment grouping, etc.) and starts the data receiving service. Upon receiving compressed data, it decompresses, verifies, and stores it in a time-series database, associating it with the node ID and timestamp.
[0204] Based on the data accumulated over a long period of time, the platform can perform the following statistical analyses: Waterlogging frequency statistics: Statistically analyze the number of times and duration of waterlogging (area > threshold) occurs on each road section in different seasons and at different times to identify road sections prone to waterlogging.
[0205] Water receding rate analysis: Calculate the average rate and distribution of water receding in each road section, assess the effectiveness of drainage facilities, and identify bottleneck sections with slow water receding.
[0206] Runoff direction consistency analysis: Statistically analyze the degree of deviation between the runoff direction and the road design slope direction of each road segment to determine whether the drainage design is reasonable.
[0207] Lateral comparison of road sections: The water accumulation characteristics (frequency, area, duration, receding rate, etc.) of different road sections are comprehensively scored and ranked to provide a quantitative basis for the priority of renovation.
[0208] Trend Forecast: Based on historical data over many years, we analyze the changing trends of water accumulation characteristics with the age of roads to predict future renovation needs.
[0209] The analysis results can generate periodic reports (such as quarterly / annual road section waterlogging assessment reports), including waterlogging heat maps, drainage rate distribution maps, runoff direction rose diagrams, and renovation priority ranking tables for each road section. These reports can be exported in PDF or Excel format for reference by maintenance decision-making departments.
[0210] 3. Visual analysis interface The platform provides a visual interface based on a B / S architecture, supporting multi-dimensional data exploration and decision support, including: Road segment overview view: Displays the location of each monitored road segment in map form. Clicking on a segment will show key indicators such as its overall score, frequency of water accumulation, and average rate of water receding.
[0211] Historical trend view: This line graph shows the changes in the frequency of water accumulation and the average rate of water receding over many years for a selected road section, helping to determine the aging trend of the road.
[0212] Comparative analysis view: The view compares the water accumulation characteristics of multiple road sections horizontally in the form of bar charts or radar charts. It supports custom scoring weights (such as frequency weight 0.4, water receding rate weight 0.3, and area weight 0.3) and automatically generates a priority ranking for renovation.
[0213] Raw data backtracking: Supports querying raw detection data and corresponding video clips by time period, road segment, and camera, for manual review or in-depth analysis.
[0214] This deployment architecture has been applied in a pilot project for the renovation and evaluation of a highway management department. Through a year-long data collection and analysis of three typical road sections, it was successfully identified that the K102+300~K102+800 section had a problem of high frequency of water accumulation and slow water receding rate. On-site survey confirmed that the problem was due to aging drainage facilities, and it has been included in the renovation plan for the following year.
[0215] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0216] It will be readily understood by those skilled in the art that this invention includes any combination of the inventive description and specific embodiments outlined in the foregoing specification, as well as the various parts shown in the accompanying drawings. Due to space limitations and for the sake of brevity, not all of these combinations have been described in detail. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for intelligent detection of dynamic water accumulation on highway pavement, characterized in that, Includes the following steps: S1: Acquire videos of multiple sections of the highway, preprocess the video frames of each video, and calculate the dense optical flow of adjacent frames to obtain the optical flow sequence; S2, Construct a dual-stream fusion neural network architecture, which includes a spatial stream network, a temporal stream network, and a dynamic feature fusion mechanism, wherein: S21, Integrating a watershed attention mechanism into the spatial flow network to extract spatial features includes: performing initial convolution and halving the spatial size of the preprocessed image, sequentially passing it through each residual block group of the ResNet34 backbone network, and integrating the watershed attention mechanism on the feature map of the last residual block group; automatically identifying the boundary and center of the water accumulation area using the gradient information of the feature map calculated by the watershed attention mechanism, generating an attention weight map, multiplying it element-wise with the original features to generate an attention-weighted feature map, and performing global average pooling to obtain the spatial features related to water accumulation. ; S22, the temporal flow network uses a 3D convolutional network to process the optical flow sequence and extract temporal features, including: organizing the optical flow sequence into a 5-dimensional tensor and inputting it into stacked 3D convolutional layers; performing sliding window calculations along the spatial dimension in each convolutional operation to extract local motion features; retaining the temporal dimension T as an independent dimension in the output feature map of each layer; averaging the temporal dimension T using a temporal pooling layer to aggregate information from different times into a global motion feature vector; and mapping the global motion feature vector to the same dimension as the spatial features using a fully connected layer to obtain the water accumulation-related temporal features. ; S23, initiate the dynamic feature fusion mechanism based on the spatial features. and time series characteristics The fusion weights of spatial flow and temporal flow are adaptively calculated, and the spatial features and temporal features are dynamically fused according to the fusion weights to generate fused features. S3. Construct a multi-task prediction network and use a multi-task learning framework to simultaneously predict the water accumulation stage, water accumulation area ratio, runoff direction and water receding rate, and generate corresponding prediction results. S4, The prediction results are constrained by the physical perception loss function to conform to the laws of fluid mechanics; S5 uses a cloud platform to perform data analysis and risk assessment on the constrained prediction results, and triggers an early warning when the risk level is detected to be higher than the threshold.
2. The intelligent detection method for dynamic process of water accumulation on highway pavement according to claim 1, characterized in that, In S1, each video segment is configured with a frame-level annotation file. The temporal sequence length and input image size are set according to the configuration file. All videos are traversed, and each video file is paired with its corresponding annotation file. The video frames of each video are normalized in size, converted in color space, and standardized. Dense optical flow between adjacent frames is calculated to obtain an optical flow sequence. A sliding window is used to extract training samples from the frame sequence and optical flow sequence. Each sample is encapsulated as a triplet consisting of a frame sequence, an optical flow sequence, and a corresponding multi-task annotation. The annotation file includes the water accumulation stage, water accumulation area ratio, runoff direction, water receding rate, and runoff state.
3. The intelligent detection method for dynamic process of water accumulation on highway pavement according to claim 1, characterized in that, In S21, the watershed attention mechanism includes: The feature map X is input into the first convolutional layer for transformation, which halves the number of channels in the input feature map to obtain an intermediate feature map. ; Calculate intermediate feature maps The gradient magnitude map G is obtained by measuring the gradient in the horizontal and vertical directions. The gradient magnitude map G is used to reflect the spatial change intensity at each position in the feature map. intermediate feature map The input is fed into the second convolutional layer for mapping to generate the original score map. Attention weights are then generated using the Sigmoid activation function to obtain the final attention weight map. The attention weight map is used to represent the probability that the location belongs to a waterlogged area. The original input feature map X is multiplied element-wise with the attention weight map to enhance features and generate an attention-weighted feature map.
4. The intelligent detection method for dynamic process of water accumulation on highway pavement according to claim 3, characterized in that, The intermediate feature map is calculated using the Sobel operator. The gradients in the horizontal and vertical directions are averaged along the channel dimension. The gradient maps of multiple channels are averaged to obtain a single-channel gradient magnitude map. The gradient map G is compared with the feature map after the first layer of convolution for dimensionality reduction. By stitching along the channel dimension, the fused features are obtained. , will integrate features The input to the second convolutional layer is mapped to generate the original score map. Attention weights are then generated using a sigmoid activation function, and an auxiliary loss function is introduced to measure the attention weight map. With gradient magnitude plot The linear correlation between them.
5. The intelligent detection method for dynamic process of water accumulation on highway pavement according to claim 1, characterized in that, In S22, the dimensions of the 5-dimensional tensor are B×2×T×H×W, where B is the batch size, T is the temporal length, and H and W are the height and width of the image. The 5-dimensional tensor is input into a stacked 3D convolutional layer, wherein all convolutional kernels in the 3D convolutional layer are 1×3×3 in size; The first convolutional layer of the 3D convolutional layer uses a stride of 2 to expand the number of channels to 64, while halving the spatial size, and the output dimension becomes B×64×T×H / 2×W / 2; the second convolutional layer continues to perform convolution with a stride of 2, increasing the number of channels to 128, and further reducing the spatial size to H / 4×W / 4, with the output being B×128×T×H / 4×W / 4; the third convolutional layer compresses the spatial feature map to 1×1, resulting in a feature map of B×256×T×1×1. The temporal pooling layer is used to average the time dimension T, and the information at different times is aggregated into a global motion feature vector with a dimension of B×256. The fully connected layer maps this 256-dimensional vector to a 128-dimensional vector with the same spatial features, and finally outputs a temporal feature vector with a dimension of B×128.
6. The intelligent detection method for dynamic process of water accumulation on highway pavement according to claim 1, characterized in that, In S23, a multilayer perceptron (MLP) is used to separate spatial features. and time series characteristics Mapping to the same dimensional space yields the processed spatial features. and time series characteristics ; Will and The features are concatenated to form a joint feature vector, which is then input into the weight generation network. Spatial feature fusion weights are adaptively calculated using fully connected layers and nonlinear activation functions. Weights for fusion with temporal features ; Based on the weighted dynamic fusion of spatial and temporal characteristics, a fusion is generated. ; The fused features Directly used as the final fusion feature Input to a multi-task prediction network.
7. The intelligent detection method for dynamic process of water accumulation on highway pavement according to claim 1, characterized in that, In S3, the multi-task prediction network includes a shared feature transformation layer and parallel output layers for water accumulation stage classification, water accumulation area ratio regression, runoff direction prediction, water loss rate estimation, and runoff state judgment. In the shared feature transformation layer, features are fused. The input is fed into a first-layer fully connected network for dimensionality upscaling, and then the dimensionality-upgraded features are fed into a second-layer fully connected network for dimensionality reduction to obtain shared features. ; Will Simultaneously, the output layers of the water accumulation stage classification head, water accumulation area ratio regression head, runoff direction prediction head, water receding rate estimation head, and runoff state judgment head are input, and the prediction results of water accumulation stage, water accumulation area ratio, runoff direction, water receding rate, and runoff state are obtained in parallel.
8. The intelligent detection method for dynamic process of water accumulation on highway pavement according to claim 7, characterized in that, In S3, corresponding task weights and loss functions are configured for the output layers of the water accumulation stage classification task, the water accumulation area ratio regression task, the runoff direction prediction task, the water receding rate estimation task, and the runoff state judgment task, respectively, and the weights for the next round are adaptively adjusted based on the loss calculated in the previous round.
9. The intelligent detection method for dynamic process of water accumulation on highway pavement according to claim 8, characterized in that, Configure cross-entropy loss functions for the output layers of the water accumulation stage classification head task and the runoff state judgment head task; Configure the Huber loss function for the output layers of the water accumulation area ratio regression head task, the runoff direction prediction head task, and the water receding rate estimation head task.
10. The intelligent detection method for dynamic process of water accumulation on highway pavement according to claim 1, characterized in that, In S4, the physical perception loss function includes a runoff direction deviation constraint term, a water accumulation area rationality constraint term, a water receding rate non-negativity constraint term, and a runoff state and direction consistency constraint term. By constraining the corresponding prediction results using runoff direction deviation, water accumulation area rationality, drainage rate non-negativity, and runoff state and direction consistency, the runoff direction deviation penalty is obtained. Unreasonable penalty for water accumulation area Negative rate penalty for water discharge Penalty for inconsistency between runoff state and direction The weighted summation yields the physical perception loss. Physical perception loss With mission loss Together they constitute the total loss .