Coastal high spot monitoring green tide recognition early warning method, medium and system
Through deep learning technology, the green tide semantic segmentation model is constructed, combined with the ECA attention mechanism and multi-scale feature fusion strategy, the problem of inefficient green tide monitoring in the existing technology is solved, accurate identification and early warning of green tides is achieved, and the real-time and accuracy of monitoring is improved.
Patent Information
- Application Number
- CN202510088231.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2045-01-21
AI Technical Summary
The existing visual interpretation and manual threshold setting methods are inefficient in green tide monitoring, with great artificial influence, making it difficult to achieve real-time and efficient monitoring.
Deep learning technology is used to build a green tide semantic segmentation model. By constructing a high-quality green tide image dataset, a deep learning green tide semantic segmentation algorithm model is designed, and combined with the ECA attention mechanism and multi-scale feature fusion strategy, accurate identification and early warning of green tides are achieved.
It significantly improves the accuracy and efficiency of green tide identification, reduces human intervention, realizes real-time monitoring and early warning, and improves the foresight and practicality of green tide prevention and control in coastal areas.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of green tide identification and early warning, and in particular, relates to a method, medium and system for green tide identification and early warning for coastal high point monitoring. Background Art
[0002] Green tide in coastal areas is an abnormal phenomenon in the marine environment, usually caused by the massive growth of specific algae. These algae usually release a large number of harmful biological toxins, which have a negative impact on the balance and biodiversity of the marine ecosystem. In addition, green tide may also cause excessive oxygen consumption, leading to hypoxia in the waters, affecting the survival and reproduction of fishery resources, and having a long-term adverse impact on the marine ecosystem.
[0003] In the past few decades, with the impact of global climate change and human activities, the frequency and scope of green tides have become a global problem. Traditional monitoring methods are often limited by labor costs, time delays and monitoring range. Therefore, a more intelligent, efficient and real-time monitoring method is needed to timely detect and deal with potential green tide problems.
[0004] In terms of green tide information extraction, most methods currently used are visual interpretation and manual threshold setting. This method relies on expert knowledge and is simple to operate, but it has disadvantages such as low efficiency and large human influence. These disadvantages are particularly obvious during green tide emergencies. Summary of the invention
[0005] In view of this, the present invention provides a method, medium and system for identifying and warning green tides at coastal high points, which can solve the technical problem of low efficiency of existing methods of visual interpretation and manual threshold setting.
[0006] The present invention is achieved in that: A first aspect of the present invention provides a method for identifying and warning green tides at coastal high points, comprising the following steps: S10, constructing a green tide semantic segmentation image dataset: collecting a large number of green tide images taken by high-point monitoring, and annotating the green tide contours in the green tide images with JSON data to obtain annotated image data; S20, data processing: convert the data annotations in JSON format into PNG mask images, and divide them into training set, validation set and test set in the ratio of 80%, 10% and 10% to obtain the green tide semantic segmentation image training data set; S30. Design a prototype of the deep learning green tide semantic segmentation algorithm model: select the PSPNet semantic segmentation algorithm, replace the backbone network with ShuffleNetV2, and combine the ECA attention mechanism equation group with the multi-scale feature fusion strategy, and combine the FocalLoss and BCELoss loss functions to solve the category imbalance problem and improve the generalization ability of the model; S40, training a green tide semantic segmentation model: using the green tide semantic segmentation image training data set to train the deep learning green tide semantic segmentation algorithm model prototype, and updating each weight of the deep learning green tide semantic segmentation algorithm model prototype by error back propagation; S50, model evaluation and optimization: using the validation set to evaluate the performance of the trained deep learning green tide semantic segmentation algorithm model prototype, adjusting the hyperparameters to optimize the model performance, and selecting the optimal model as the green tide semantic segmentation model; S60, obtaining an image to be identified: obtaining real-time image data from a coastal high point monitoring system as an image to be identified; S70, green tide recognition: pre-processing the image to be recognized, inputting it into the trained green tide semantic segmentation model, and obtaining the segmentation mask of the green tide; S80, early warning judgment: judging whether the green tide area exceeds a preset threshold or has abnormal changes according to the segmentation mask, and if the conditions are met, triggering the early warning system and notifying relevant management personnel.
[0007] Among them, the ECA attention mechanism equation group includes an adaptive convolution kernel size calculation equation, a global average pooling equation, a one-dimensional convolution operation equation, a Sigmoid activation function equation, and an attention weighted equation.
[0008] 1. Adaptive convolution kernel size calculation equation: used to calculate the convolution kernel size that adapts to the number of input channels.
[0009] 2. Global average pooling equation: compresses the input feature map into a one-dimensional vector.
[0010] 3. One-dimensional convolution operation equation: Use the calculated adaptive convolution kernel size to perform a one-dimensional convolution operation.
[0011] 4. Sigmoid activation function equation: Map the output of the one-dimensional convolution to between 0 and 1 to obtain the attention weight.
[0012] 5. Attention weighted equation: Apply the obtained attention weights to the original input feature map.
[0013] These five equations constitute the complete ECA attention mechanism, which can effectively capture the dependencies between channels and improve the feature extraction ability of the model.
[0014] Furthermore, the adaptive convolution kernel size calculation equation is specifically expressed as: ; Where: is the number of channels of the input feature map; is an adjustable scaling factor, optimized in the range of [0.1, 10] by grid search; is the bias term, which is optimized in the range of [-5,5] by random search; Round down to the nearest odd number.
[0015] Among them, the global average pooling equation is specifically expressed as: ; Where: For the Global average pooling result of channels; , is the height and width of the input feature map; The input feature map is Channels, positions The value of .
[0016] Among them, the one-dimensional convolution operation equation is specifically expressed as: ; Where: For the One-dimensional convolution output of channels; The convolution kernel size is calculated adaptively; The one-dimensional convolution kernel weights can be learned and optimized through back-propagation; It is the global average pooling result after loop padding.
[0017] Among them, the Sigmoid activation function equation is specifically expressed as: ; Where: For the The attention weight of each channel; is the steepness parameter of the Sigmoid function, optimized by gradient descent; is the center shift of the Sigmoid function, optimized by gradient descent.
[0018] Among them, the attention weighted equation is specifically expressed as: ; Where: The output feature map is Channels, positions The value of The input feature map is Channels, positions The value of For the The attention weight of each channel; is a small constant to prevent division by zero errors. The default setting is ; , are learnable spatial attention parameters optimized via back-propagation; is the hyperbolic tangent function, which is used to introduce spatial attention.
[0019] Among them, the formula combining the ECA attention mechanism equation group with the multi-scale feature fusion strategy is expressed as follows: Step 1: Multi-scale feature extraction, specifically expressed as: ; Where: :No. Feature map of the layer; :No. Feature extraction function of the layer; : Input image; :Total number of layers; Step 2: ECA attention mechanism is applied to each scale, specifically expressed as: ; Where: Represents the ECA attention mechanism equation set; Step 3: Multi-scale feature fusion: ; Where: : The first Layer feature map; : Upsampling function, which upsamples the feature map to the same size as the highest resolution feature map; :No. The fusion weight of the layer features is obtained through learning and satisfies ; Step 4: The final feature map is generated, which is specifically expressed as: ; in It is a learnable transformation function used to adjust the number of channels of the fused features.
[0020] Where: :No. The number of channels of the layer feature map; , :No. The height and width of the layer feature map; , :No. ECA adaptive convolution kernel size calculation parameters of the layer; :No. The one-dimensional convolution kernel weights of the layer; , :No. Sigmoid function parameters of the layer; :No. Small constants for layers to prevent division by zero errors; , :No. The spatial attention parameters of the layer.
[0021] Specifically, the step S10 includes: Step 101, using a high-point monitoring system to collect a large number of green tide images at different times and under different weather conditions, ensuring that the image resolution is not less than 1920×1080 pixels; Step 102: preprocessing the collected image, including denoising, color equalization and geometric correction; Step 103: Use a professional image annotation tool to accurately annotate the contour of the green tide area in the green tide image and generate an annotation file in JSON format; Step 104: A number of experienced experts participate in the labeling process to ensure the accuracy and consistency of the labeling; Step 105: Pair and save the original image and the corresponding JSON annotation file to form a complete annotation dataset; Step 106: Collect no less than 10,000 valid green tide images to ensure that the proportion of green tide coverage area in the image is evenly distributed, with appropriate sample distribution from 1% to 90%.
[0022] Wherein, the step S20 specifically includes: Step 201, develop a data conversion script to convert the annotation file in JSON format into a binary PNG mask image, where the green tide area is marked as 255 and the non-green tide area is marked as 0; Step 202: Use the OpenCV library to read the original image and the corresponding mask image, and adjust them to a uniform size of 512×512 pixels; Step 203: Use a stratified random sampling method to divide the data set into a training set, a validation set, and a test set in a ratio of 80%, 10%, and 10%; Step 204: using the green tide coverage as a stratification basis, the data set is divided into three levels: low coverage, medium coverage, and high coverage, and then random sampling is performed in each level; Step 205: Save the divided data set into a format suitable for reading by a deep learning framework, such as a TFRecord or HDF5 file; Step 206: compress and store the image data using a lossless compression algorithm such as PNG compression to reduce storage space and reading time while ensuring image quality.
[0023] Wherein, the step S30 specifically includes: Step 301, select PSPNet as the basic semantic segmentation algorithm, and replace the backbone network of PSPNet with the lightweight ShuffleNetV2; Step 302: Integrate the ECA mechanism into each stage of ShuffleNetV2 to enhance the model's ability to model inter-channel dependencies. Step 303: Design a multi-scale feature fusion strategy, extract feature maps from different stages of ShuffleNetV2, adjust the number of channels through 1×1 convolution, use bilinear interpolation to upsample all feature maps to the same spatial resolution, and obtain the fused feature map through weighted summation; Step 304: Design a loss function, combining FocalLoss and BCELoss to solve the class imbalance problem and improve the generalization ability of the model; Step 305: Linearly combine the two loss functions and determine the initial value of the balance factor through cross-validation.
[0024] Wherein, the step S40 specifically includes: Step 401, the ShuffleNetV2 backbone network is initialized using weights pre-trained on the ImageNet dataset, and the newly added layer is initialized using the He method; Step 402, set training hyperparameters, use Adam optimizer, set initial learning rate to 0.001, set weight decay coefficient to 0.0001, and use cosine annealing learning rate scheduling strategy; Step 403: Implement data enhancement strategies, including random horizontal flipping, random vertical flipping, random rotation, random scaling, and random brightness, contrast, and saturation adjustment; Step 404, start the iterative training process, input the enhanced training data into the model in each epoch, perform forward propagation calculation to obtain the prediction result, calculate the loss function value, use the automatic differentiation technique to calculate the gradient, and update the model parameters through the back propagation algorithm; Step 405: At the end of each epoch, evaluate the model performance on the validation set and record key indicators such as accuracy and IoU; Step 406: Implement the early stopping strategy. When the performance of the validation set does not improve for 5 consecutive epochs, terminate the training early. Step 407: Use gradient clipping technology to limit the L2 norm of the gradient to less than 5 to prevent the gradient explosion problem.
[0025] Wherein, the step S50 specifically includes: Step 501: Use the validation set to conduct a detailed evaluation of the trained model and calculate multiple evaluation indicators, including pixel-level accuracy, average intersection-over-union ratio, F1 score, precision and recall; Step 502: Perform error analysis, classify and count the erroneous prediction samples in the validation set, and identify the main error types of the model; Step 503: Analyze the attention distribution of the model through visualization technology to understand whether the image area that the model focuses on is reasonable; Step 504: Based on the error analysis results, adjust the model hyperparameters and structure, such as increasing the sampling weight of small objects, adding more fine-grained features in the feature pyramid, increasing the regularization strength, and adjusting the parameters of the ECA module; Step 505: perform 5-fold cross validation, calculate the evaluation index for each fold, and take the average value as the final performance index; Step 506: Perform ensemble learning on the best performing model configurations, use model averaging and test-time enhancement techniques, select the 3-5 best performing model configurations in cross-validation, and average the prediction results of each test sample.
[0026] Wherein, the step S60 specifically includes: Step 601: Select a suitable high point in the coastal area and install a high-resolution camera with a resolution of not less than 4K and a field of view of not less than 90 degrees; Step 602: according to the seasonal characteristics of green tide, adjust the image acquisition frequency, set a higher acquisition frequency during the high-incidence period of green tide, such as once every 5 minutes, and reduce the frequency to once every 30 minutes during other periods; Step 603: pre-process the collected original image in real time, including denoising, color correction and geometric correction, using a Gaussian filter to remove image noise, performing automatic white balance and contrast enhancement, and applying a lens distortion correction algorithm; Step 604: Use a high-speed network to transmit the pre-processed image to a central processing server in real time, and use a lossless compression algorithm to compress the image; Step 605: On the server side, the received image is stored in a high-performance distributed file system; Step 606: Develop an automated quality detection algorithm to evaluate each received image, including clarity assessment, exposure check, and cloud and fog occlusion detection; Step 607: For images that fail the quality inspection, the system automatically adjusts the camera parameters and re-captures the images. At the same time, a manual review mechanism is established to regularly spot-check automatically captured images.
[0027] Wherein, the step S70 specifically includes: Step 701: adjust the acquired image to the input size of 512×512 pixels required by the model, scale it using a bicubic interpolation algorithm, and then normalize the image; Step 702: input the preprocessed image into the selected optimal green tide semantic segmentation model, and use an inference acceleration framework such as TensorRT or ONNXRuntime to optimize the model inference speed; Step 703: During the inference process, half-precision calculation is enabled. For large-size images, the sliding window technology is used to divide the image into multiple overlapping small blocks, and predictions are performed separately. Then, the results are stitched together to restore the original size. Step 704: Apply threshold segmentation to the probability map output by the model, and use morphological operations to refine the segmentation results, eliminate small noise areas and fill small holes; Step 705: Apply the conditional random field as a post-processing step to optimize the accuracy of the segmentation boundary; Step 706: Perform time series analysis on the recognition results of multiple consecutive time points, and use a Kalman filter to smooth the green tide boundary to reduce the instability of single-frame recognition; Step 707: superimpose the recognition result on the original image to generate a vectorized green tide outline, and save the recognition result in GeoTIFF format, including geographic coordinate information.
[0028] Wherein, the step S80 specifically includes: Step 801: setting multiple levels of warning thresholds, including mild warning, moderate warning and severe warning. These thresholds are dynamically adjusted according to the characteristics of different sea areas and seasonal changes. Step 802: Use time series analysis techniques, such as an autoregressive integrated moving average model, to model the changing trend of the green tide area and predict the development trend of the green tide in the short term; Step 803: using a spatial autocorrelation analysis method, such as the Moran index, to assess the spatial aggregation degree of the green tide; Step 804: Establish a multi-factor evaluation model based on fuzzy logic, standardize various indicators, and derive a comprehensive risk level through fuzzy rule reasoning; Step 805: Use the local anomaly factor algorithm to detect abnormal patterns of green tide development, and set a local anomaly factor threshold. A situation exceeding this threshold will trigger special attention; Step 806: When the comprehensive evaluation result exceeds the preset threshold or an abnormality is detected, the early warning system is automatically triggered and early warning information is sent to relevant managers through multiple channels; Step 807: Push the warning information to the visualization platform, use geographic information system technology to visually display the green tide distribution and warning area on the electronic map, establish a warning response mechanism, and activate corresponding emergency plans according to different warning levels.
[0029] A second aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions, and when the program instructions are executed, they are used to execute the above-mentioned coastal high point monitoring green tide identification and early warning method.
[0030] A third aspect of the present invention provides a coastal high point monitoring green tide identification and early warning system, which includes the above-mentioned computer-readable storage medium.
[0031] Compared with the prior art, the beneficial effects of the coastal high point monitoring green tide identification and early warning method, medium and system provided by the present invention are: First, by constructing a highly targeted green tide semantic segmentation image dataset, this method significantly improves the model training effect. By collecting a large number of green tide images taken by high-point monitoring and accurately annotating JSON data, the quality and diversity of the dataset are ensured. This high-quality dataset provides a solid foundation for subsequent deep learning model training, enabling the model to better adapt to complex sea surface environments and different forms of green tides.
[0032] Secondly, the deep learning green tide semantic segmentation algorithm model designed by this method significantly improves the accuracy and efficiency of green tide recognition. By combining PSPNet with ShuffleNetV2 and introducing the ECA attention mechanism and multi-scale feature fusion strategy, this method effectively improves the recognition ability of small-area green tides and green tide edge areas while ensuring the lightweight of the model. In particular, the introduction of the ECA attention mechanism enables the model to better capture the dependencies between channels and improve the efficiency and accuracy of feature extraction.
[0033] Furthermore, this method makes full use of spatiotemporal information and significantly improves the stability and reliability of monitoring results. By performing time series analysis on the recognition results of multiple consecutive time points and using a Kalman filter to smooth the green tide boundary, the instability of single-frame recognition is effectively reduced, and the continuity and accuracy of green tide monitoring are improved. This method enables the system to better cope with interference factors such as sea surface fluctuations and changes in light, and provide more stable and reliable monitoring results.
[0034] Finally, this method establishes a complete early warning mechanism that can timely detect the development trend of green tides and issue early warnings. By setting multi-level early warning thresholds and combining time series analysis and spatial autocorrelation analysis, this method can comprehensively evaluate the development trend of green tides. In particular, the introduction of a multi-factor evaluation model based on fuzzy logic and a local abnormal factor algorithm enables the system to more sensitively capture abnormal patterns of green tide development and trigger early warnings in a timely manner. This early warning mechanism greatly improves the foresight and practicality of green tide monitoring, and provides strong support for green tide prevention and control in coastal areas.
[0035] In summary, the method of the present invention solves the technical problem of low efficiency in the existing methods of visual interpretation and manual threshold setting. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A flow chart of the method provided by the present invention; Figure 2 This is the flow chart of the ECA attention mechanism in Example 1. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0038] like Figure 1 As shown, it is a flow chart of a coastal high point monitoring green tide identification and early warning method provided by the present invention, and the method comprises the following steps: S10, constructing a green tide semantic segmentation image dataset: collecting a large number of green tide images taken by high-point monitoring, and annotating the green tide contours in the green tide images with JSON data to obtain annotated image data; S20, data processing: convert the data annotations in JSON format into PNG mask images, and divide them into training set, validation set and test set in the ratio of 80%, 10% and 10% to obtain the green tide semantic segmentation image training data set; S30. Design a prototype of the deep learning green tide semantic segmentation algorithm model: select the PSPNet semantic segmentation algorithm, replace the backbone network with ShuffleNetV2, and combine the improved ECA attention mechanism equation group with the multi-scale feature fusion strategy, and combine the FocalLoss and BCELoss loss functions to solve the category imbalance problem and improve the model generalization ability; S40, training a green tide semantic segmentation model: using a green tide semantic segmentation image training data set to train a prototype of a deep learning green tide semantic segmentation algorithm model, and updating each weight of the prototype of the deep learning green tide semantic segmentation algorithm model through error back propagation; S50, Model evaluation and optimization: Use the validation set to evaluate the performance of the trained deep learning green tide semantic segmentation algorithm model prototype, adjust the hyperparameters to optimize the model performance, and select the optimal model as the green tide semantic segmentation model; S60, obtaining an image to be identified: obtaining real-time image data from a coastal high point monitoring system as an image to be identified; S70, green tide recognition: pre-processing the image to be recognized, inputting it into the trained green tide semantic segmentation model, and obtaining the segmentation mask of the green tide; S80, early warning judgment: Based on the segmentation mask, determine whether the green tide area exceeds the preset threshold or has abnormal changes. If the conditions are met, the early warning system is triggered and the relevant management personnel are notified.
[0039] The specific implementation methods of the above steps are described in detail below: The specific implementation method of step S10 is: construct a green tide semantic segmentation image dataset. The purpose of this step is to create a high-quality and diverse green tide image dataset to provide a basis for subsequent deep learning model training. The specific implementation process includes: first, using a high-point monitoring system (such as a drone, a tower camera, etc.) to collect a large number of green tide images at different times and under different weather conditions to ensure the diversity and representativeness of the data. During the collection process, it should be noted that the resolution of the image is not less than 1920×1080 pixels to ensure sufficient detail information. Secondly, the collected images are preprocessed, including denoising, color equalization, and geometric correction operations to improve the image quality. Then, a professional image annotation tool (such as LabelMe or CVAT) is used to accurately annotate the contours of the green tide area in the green tide image and generate an annotation file in JSON format. During the annotation process, multiple experienced experts should participate to ensure the accuracy and consistency of the annotation. Finally, the original image and the corresponding JSON annotation file are paired and saved to form a complete annotation dataset. To ensure the scale and quality of the dataset, it is recommended to collect no less than 10,000 valid green tide images and ensure that the proportion of green tide coverage area in the image is evenly distributed, with appropriate sample distribution from 1% to 90%.
[0040] The specific implementation of step S20 is: data processing. The purpose of this step is to convert the annotated data into a format suitable for deep learning model training and to reasonably divide the data set. The specific implementation process includes: first, develop a data conversion script to convert the annotated file in JSON format into a binary PNG mask image. During the conversion process, the green tide area is marked as 255 (white) and the non-green tide area is marked as 0 (black). Secondly, use Python's OpenCV library to read the original image and the corresponding mask image, and adjust them to a uniform size (such as 512×512 pixels) to meet the input requirements of the deep learning model. Then, using the stratified random sampling method, the data set is divided into a training set, a validation set, and a test set at a ratio of 80%, 10%, and 10%. Stratified sampling can ensure that the distribution of the green tide coverage area in each subset is similar to that of the overall data set, thereby improving the representativeness of the sample. In the division process, the green tide coverage rate is used as the stratification basis to divide the data set into three levels: low coverage (0-30%), medium coverage (30-70%), and high coverage (70-100%), and then random sampling is performed in each level. Finally, save the divided dataset in a format suitable for deep learning frameworks (such as TensorFlow or PyTorch), such as TFRecord or HDF5 files. In order to improve data loading efficiency, the image data can be compressed and stored, using lossless compression algorithms such as PNG compression to reduce storage space and reading time while ensuring image quality.
[0041] The specific implementation method of step S30 is: designing a prototype of a deep learning green tide semantic segmentation algorithm model. The purpose of this step is to build an efficient and accurate green tide semantic segmentation model architecture. The specific implementation process includes: first, selecting PSPNet (Pyramid Scene Parsing Network) as the basic semantic segmentation algorithm, because PSPNet can effectively capture contextual information of different scales and is suitable for processing complex green tide scenes. Secondly, the backbone network of PSPNet is replaced with the lightweight ShuffleNetV2 to improve the computational efficiency and real-time performance of the model. ShuffleNetV2 significantly reduces the amount of calculation and the number of parameters while maintaining good performance through channel segmentation and shuffling operations. Then, the ECA (Efficient Channel Attention) mechanism is integrated into each stage of ShuffleNetV2 to enhance the model's ability to model inter-channel dependencies. The ECA mechanism achieves efficient channel attention calculation by adaptively determining the size of the one-dimensional convolution kernel. Next, a multi-scale feature fusion strategy is designed to weightedly fuse feature maps at different levels to comprehensively utilize low-level detail information and high-level semantic information. Specifically, feature maps are extracted from different stages of ShuffleNetV2, the number of channels is adjusted through 1×1 convolution, and then all feature maps are upsampled to the same spatial resolution using bilinear interpolation, and finally the fused feature map is obtained by weighted summation. The weight coefficients are learned through back propagation. Finally, the loss function is designed to combine FocalLoss and BCELoss (binary cross entropy loss) to solve the problem of class imbalance and improve the generalization ability of the model. The expression of FocalLoss is: ,in is the probability predicted by the model, is the class weight, is the focusing parameter (usually set to 2). The expression of BCELoss is: BCE ( y , y ̂ )=-[ y log ( y ̂ )+(1- y ) log ( 1- y ̂ )] ,in is the true label, is the model prediction value. Linear combination of the two loss functions: ,in is the balancing factor, determined by cross-validation, and the initial value can be set to 0.5.
[0042] The following is a complex formula representation of the improved ECA attention mechanism equation group, including detailed parameters, variable explanations, and calculation steps: 1. The adaptive convolution kernel size calculation equation is specifically expressed as: ; Where: is the number of channels of the input feature map; is an adjustable scaling factor, optimized in the range of [0.1, 10] by grid search; is the bias term, which is optimized in the range of [-5,5] by random search; Round down to the nearest odd number.
[0043] 2. The global average pooling equation is specifically expressed as: ; Where: For the Global average pooling result of channels; , is the height and width of the input feature map; The input feature map is Channels, positions The value of .
[0044] 3. One-dimensional convolution operation equation, specifically expressed as: ; Where: For the One-dimensional convolution output of channels; The convolution kernel size is calculated adaptively; The one-dimensional convolution kernel weights can be learned and optimized through back-propagation; It is the global average pooling result after loop padding.
[0045] 4. Sigmoid activation function equation, specifically expressed as: ; Where: For the The attention weight of each channel; is the steepness parameter of the Sigmoid function, optimized by gradient descent; is the center shift of the Sigmoid function, optimized by gradient descent.
[0046] 5. The attention weighted equation is specifically expressed as: ; Where: The output feature map is Channels, positions The value of The input feature map is Channels, positions The value of For the The attention weight of each channel; is a small constant to prevent division by zero errors, usually set to ; , are learnable spatial attention parameters optimized via back-propagation; is the hyperbolic tangent function, which is used to introduce spatial attention.
[0047] The following is a description of the above calculation steps: 1. Calculate using the adaptive convolution kernel size calculation equation ; 2. Input feature map Applying global average pooling, we get ; 3. Use the one-dimensional convolution operation equation to Perform convolution and get ; 4. Input Sigmoid activation function to get channel attention weight ; 5. Using the attention weighted equation, Applied to input feature map , and get the output feature map ; This ECA attention mechanism equation group introduces additional parameters and spatial attention mechanisms to improve the expressiveness and flexibility of the model. By optimizing these parameters, it can better adapt to different data distributions and task requirements.
[0048] The formula combining the ECA attention mechanism equation group with the multi-scale feature fusion strategy is expressed as follows: 1. Multi-scale feature extraction, specifically expressed as: ; Where: :No. Feature map of the layer; :No. Feature extraction function of the layer (such as convolution, pooling, etc.); : Input image; :Total number of layers.
[0049] 2. ECA attention mechanism (applied to each scale), specifically expressed as: ; in The function contains the following steps: a) Adaptive convolution kernel size calculation: ; b) Global Average Pooling: ; c) One-dimensional convolution operation: ; d) Sigmoid activation: ; e) Attention Weighting: ; 3. Multi-scale feature fusion: ; Where: : The first Layer feature map; : Upsampling function, which upsamples the feature map to the same size as the highest resolution feature map; :No. The fusion weight of the layer features is obtained through learning and satisfies .
[0050] 4. The final feature map is generated, specifically expressed as: : in It is a learnable transformation function, such as 1x1 convolution, which is used to adjust the number of channels of the fused features.
[0051] Where: :No. The number of channels of the layer feature map; , :No. The height and width of the layer feature map; , :No. ECA adaptive convolution kernel size calculation parameters of the layer; :No. The one-dimensional convolution kernel weights of the layer; , :No. Sigmoid function parameters of the layer; :No. Small constants for layers to prevent division by zero errors; , :No. The spatial attention parameters of the layer.
[0052] The following is a description of the above calculation steps: 1. For the input image Perform multi-scale feature extraction to obtain ; 2. Apply the ECA attention mechanism to the feature map of each scale, and get ; 3. Perform weighted fusion on the processed multi-scale features to obtain ; 4. Through the final transformation function Generate the final feature map ; This combined method applies the ECA attention mechanism to the feature maps of each scale, and then integrates multi-scale information through weighted fusion. This method can effectively capture features of different scales, while using the ECA attention mechanism to enhance important channel information, improving the accuracy and robustness of the model for green tide recognition.
[0053] The specific implementation method of step S40 is: training the green tide semantic segmentation model. The purpose of this step is to use the prepared data set and the designed model architecture to obtain a high-performance green tide semantic segmentation model through iterative optimization. The specific implementation process includes: first, initializing the model parameters. For the ShuffleNetV2 backbone network, use the weights pre-trained on the ImageNet dataset for initialization to accelerate convergence and improve model performance. For newly added layers (such as ECA modules, multi-scale feature fusion layers, etc.), the He initialization method is used, that is, starting from a mean of 0 and a standard deviation of Initial weights are randomly sampled from a truncated normal distribution, where is the number of input units of this layer. Secondly, set the training hyperparameters. The Adam optimizer is used, the initial learning rate is set to 0.001, and the weight decay coefficient is set to 0.0001. The cosine annealing learning rate scheduling strategy is used to dynamically adjust the learning rate during training. The batch size is set according to the GPU memory capacity, and 16 or 32 can usually be selected. Then, implement data augmentation strategies, including random horizontal flip (probability 0.5), random vertical flip (probability 0.5), random rotation (-15° to 15°), random scaling (0.8 to 1.2 times) and random brightness, contrast, and saturation adjustment (within the range of ±20%). These augmentation strategies can improve the generalization ability of the model and its adaptability to various environmental conditions. Then, start the iterative training process. In each epoch, the augmented training data is input into the model, the forward propagation calculation is performed to obtain the prediction result, and then the loss function value is calculated. The gradient is calculated using the automatic differentiation technique, and the model parameters are updated through the backpropagation algorithm. At the end of each epoch, the model performance is evaluated on the validation set, and key indicators such as accuracy, IoU (intersection over union), etc. are recorded. An early stopping strategy is implemented, and training is terminated early when the validation set performance has not improved for 5 consecutive epochs. Finally, the gradient clipping technique is used to limit the L2 norm of the gradient to less than 5 to prevent the gradient explosion problem. The entire training process continues until the preset maximum number of epochs (such as 100) is reached or the early stopping condition is triggered. During the training process, a model checkpoint is saved every 5 epochs for subsequent analysis and selection of the best model.
[0054] The specific implementation method of step S50 is: model evaluation and optimization. The purpose of this step is to comprehensively evaluate the performance of the trained model and optimize the model by adjusting the hyperparameters and model structure. The specific implementation process includes: First, use the validation set to conduct a detailed evaluation of the trained model. Calculate multiple evaluation indicators, including pixel-level accuracy (PixelAccuracy), mean intersection over union (MIoU), F1 score, precision (Precision) and recall (RECAll). For the green tide recognition task, special attention is paid to the IoU indicator, which is calculated as follows: , where TP is a true positive, FP is a false positive, and FN is a false negative. Set the IoU threshold to 0.5, and calculate the average precision (AP) under different IoU thresholds. Secondly, perform error analysis. Classify and count the incorrectly predicted samples in the validation set to identify the main error types of the model, such as over-segmentation, under-segmentation, inaccurate boundaries, etc. Analyze the attention distribution of the model through visualization techniques (such as GradCAM) to understand whether the image area that the model focuses on is reasonable. Then, based on the error analysis results, adjust the model hyperparameters and structure. For example, if it is found that the model is not effective in identifying small areas of green tides, you can increase the sampling weights of small targets or add more fine-grained features to the feature pyramid. If the model is overfitting, you can increase the regularization strength, such as increasing the weight decay coefficient or introducing a dropout layer. Adjust the parameters of the ECA module, such as changing the adaptive convolution kernel size calculation. and value to optimize the effect of the channel attention mechanism. For the PSPNet part, different pyramid pooling scales can be tried, such as {1,2,3,6} or {1,3,5,7}, to capture richer multi-scale information. Next, cross-validation is implemented. After merging the training set and the validation set, a 5-fold cross-validation is performed to more comprehensively evaluate the stability and generalization ability of the model performance. The evaluation indicators for each fold are calculated and the average is taken as the final performance indicator. Set the model selection criteria, such as MIoU not less than 0.85 and F1 score not less than 0.9. Finally, the best performing model configuration is integrated. Model averaging and test time augmentation (TTA) techniques are used. Specifically, the 3-5 best performing model configurations in cross-validation are selected, and the prediction results of each test sample are averaged. In the test phase, multiple transformations (such as flipping and scaling) are performed on each input image, and the transformed multiple prediction results are combined to obtain the final prediction. This integration strategy can further improve the stability and accuracy of the model.
[0055] The specific implementation of step S60 is: obtain the image to be identified. The purpose of this step is to obtain high-quality image data from the coastal high-point monitoring system in real time to provide input for subsequent green tide identification. The specific implementation process includes: first, configure the high-point monitoring system. Select a suitable high-point location (such as a lighthouse, a tall building or a hill) in the coastal area and install a high-resolution camera. The resolution of the camera should be no less than 4K (3840×2160 pixels) and the field of view should be no less than 90 degrees to ensure that a sufficiently large sea area is covered. Secondly, set the image acquisition parameters. According to the seasonal characteristics of the green tide, adjust the image acquisition frequency. During the high incidence period of green tide (usually from May to August), set a higher acquisition frequency, such as once every 5 minutes; in other periods, the frequency can be reduced to once every 30 minutes to balance the data volume and system load. Metadata such as timestamps, GPS coordinates, and camera orientation should be recorded synchronously during image acquisition to facilitate subsequent analysis. Then, implement image preprocessing. The collected original image is preprocessed in real time, including denoising, color correction, and geometric correction. Use a Gaussian filter to remove image noise. The filter kernel size can be set to 3×3 or 5×5 and dynamically adjusted according to image quality. Perform automatic white balance and contrast enhancement to adapt to different lighting conditions. If the camera is distorted, apply a lens distortion correction algorithm, such as the Brown-Conrady model, and the correction parameters are obtained through offline calibration. Next, implement data transmission and storage. Use a high-speed network (such as 5G or dedicated line) to transmit the preprocessed images to the central processing server in real time. Use a lossless compression algorithm (such as JPEG2000) to compress the image to reduce the transmission bandwidth requirement while ensuring image quality. On the server side, store the received images in a high-performance distributed file system, such as Hadoop Distributed File System (HDFS), to support large-scale parallel processing. Finally, optionally, establish an image quality control mechanism. Evaluate each received image. Quality inspection includes clarity assessment (using the Laplace operator to calculate the image gradient variance, with the threshold set to 100), exposure check (calculating the image histogram to ensure that the proportion of pixel values distributed in the range of 10-245 is not less than 95%), and cloud and fog occlusion detection (using the threshold segmentation method based on the HSV color space, with the cloud and fog coverage threshold set to 30%). For images that fail the quality inspection, the system automatically adjusts the camera parameters (such as exposure time, ISO sensitivity, etc.) and re-collects them. At the same time, a manual review mechanism is established to regularly check automatically collected images to ensure system stability and data quality.
[0056] The specific implementation of step S70 is: green tide identification. The purpose of this step is to use the trained deep learning model to accurately segment the green tide area of the real-time acquired image. The specific implementation process includes: First, image preprocessing. The image acquired in step S60 is adjusted to the input size required by the model (such as 512×512 pixels), and scaled using the bicubic interpolation algorithm to maintain the smoothness of the image. Then the image is normalized and the pixel value is scaled to the range of [-1,1]. The calculation formula is: ,in and are the mean and standard deviation of the training set, respectively. Secondly, model inference. The preprocessed image is input into the optimal green tide semantic segmentation model selected in step S50. Use inference acceleration frameworks such as TensorRT or ONNXRuntime to optimize the model inference speed. During the inference process, half-precision (FP16) calculations are enabled to improve computational efficiency while ensuring accuracy. For large-size images, the sliding window technique is used to divide the image into multiple overlapping small blocks (such as 256×256 pixels, with an overlap rate of 50%), and predictions are made separately, and then the results are stitched back to the original size. Then, post-processing optimization. Threshold segmentation is applied to the probability map output by the model. The threshold is determined by ROC curve analysis, and the initial value can be set to 0.5. Morphological operations (such as opening and closing operations) are used to refine the segmentation results, eliminate small noise areas, and fill small holes. The kernel size of the opening and closing operations can be set to 3×3 or 5×5, which is dynamically adjusted according to the typical size of the green tide patches. Conditional random field (CRF) is applied as a post-processing step to optimize the accuracy of the segmentation boundary. The energy function of CRF is defined as: ,in is a unary potential energy term, is the pairwise potential term. The unary potential is based on the output probability of the model, and the pairwise potential uses a Gaussian kernel to model the similarity between pixels. Next, multi-time series fusion. The recognition results of multiple consecutive time points (such as within the last hour) are analyzed in time series, and the Kalman filter is used to smooth the green tide boundary to reduce the instability of single-frame recognition. The state transition equation of the Kalman filter is: , the observation equation is: ,in is the state transition matrix, is the observation matrix, and They are process noise and observation noise respectively. Finally, the results are visualized and stored. The recognition results are superimposed on the original image, and different colors or transparency are used to represent the probability intensity of the green tide area. A vectorized green tide outline is generated to facilitate subsequent area calculation and change analysis. The recognition results are saved in GeoTIFF format, which contains geographic coordinate information, which is convenient for integration with other geographic information system (GIS) data. At the same time, key parameters (such as green tide area, center coordinates, maximum extension direction, etc.) are extracted and stored in a time series database (such as InfluxDB) to support subsequent trend analysis and early warning judgment.
[0057] The specific implementation method of step S80 is: early warning judgment. The purpose of this step is to detect abnormal situations in time and trigger the early warning mechanism based on the green tide identification results. The specific implementation process includes: First, set the early warning threshold. According to historical data and expert experience, set multiple levels of early warning thresholds. For example, the proportion of green tide area to the monitoring area can be set as the main indicator, and the preliminary threshold can be set as: mild warning 5%, moderate warning 10%, severe warning 20%. These thresholds should be dynamically adjusted according to the characteristics of different sea areas and seasonal changes. Secondly, spatiotemporal analysis. Use time series analysis techniques, such as the autoregressive integrated moving average model (ARIMA), to model the changing trend of the green tide area. The expression of the ARIMA model is: ,in is the difference order, is the number of autoregressive terms, is the number of moving average items. By fitting the ARIMA model, the development trend of the green tide in the short term (such as the next 24 hours) can be predicted. At the same time, the spatial autocorrelation analysis method, such as Moran's I, is used to evaluate the spatial aggregation degree of the green tide. The calculation formula of Moran's I is: ,in is the number of spatial units, is the spatial weight matrix, and is the attribute value of the corresponding position. A Moran index greater than 0 indicates positive correlation, and less than 0 indicates negative correlation. Then, a comprehensive evaluation of multiple factors is performed. In addition to the green tide area, other factors such as growth rate, spatial distribution, and marine meteorological conditions need to be considered. A multi-factor evaluation model based on fuzzy logic is established. After standardizing each indicator, the comprehensive risk level is obtained through fuzzy rule reasoning. The general form of fuzzy rules is: IF (condition 1) AND (condition 2) OR (condition 3) THEN (conclusion). For example, "IF (high area growth rate) AND (high spatial aggregation) OR (predicted area exceeds threshold after 24 hours) THEN (trigger moderate warning)". Next, anomaly detection. The local anomaly factor (LOF) algorithm is used to detect abnormal patterns of green tide development. The LOF algorithm calculates the local density deviation of each data point relative to its k nearest neighbors, and points with LOF values much greater than 1 are considered abnormal. The calculation of LOF is based on the concepts of k-distance and reachable distance. The specific calculation steps include: determining the k-distance neighborhood, calculating the reachable distance, calculating the local reachable density, and calculating the LOF value. Set a LOF threshold (such as 2.0), and situations exceeding this threshold will trigger special attention. Finally, early warning trigger and notification. When the comprehensive evaluation results exceed the preset threshold or an abnormality is detected, the early warning system is automatically triggered. The early warning information is sent to relevant managers through various channels, including SMS, email, mobile application push, etc. The early warning information should include: warning level, green tide area and location, development trend forecast, recommended measures, etc. At the same time, the early warning information is pushed to the visualization platform, and the distribution of green tides and early warning areas are intuitively displayed on the electronic map using geographic information system (GIS) technology. Establish an early warning response mechanism and initiate corresponding emergency plans according to different warning levels, such as increasing the monitoring frequency, deploying prevention and control equipment, and organizing personnel for on-site disposal.
[0058] Through the implementation of the above detailed steps, the present invention provides a comprehensive and efficient coastal high-point monitoring green tide identification and early warning method. The method combines advanced deep learning technology, image processing technology and spatiotemporal data analysis technology to achieve accurate identification, dynamic monitoring and timely early warning of green tides. By constructing high-quality data sets, designing optimized deep learning models, implementing real-time image acquisition and processing, and conducting multi-dimensional early warning analysis, this method can effectively support green tide monitoring and management in coastal areas, and provide important decision-making support for the prevention and control of green tide disasters.
[0059] Specifically, the principle of the present invention is: First, high-quality datasets are the key foundation for deep learning model performance. This method provides rich and diverse samples for model training by constructing a targeted green tide semantic segmentation image dataset. This dataset not only contains green tide images at different times and under different weather conditions, but also provides detailed green tide contour information through precise JSON data annotation. Such a dataset can help the model learn the characteristics of green tide in various complex environments, thereby improving the generalization ability and recognition accuracy of the model.
[0060] Secondly, the deep learning green tide semantic segmentation algorithm model designed by this method integrates a variety of advanced technologies to achieve efficient and accurate green tide recognition. PSPNet was selected as the basic semantic segmentation algorithm because it can effectively capture contextual information of different scales and is suitable for processing complex sea surface scenes. Replacing the backbone network with ShuffleNetV2 greatly reduces the computational complexity and makes the model more suitable for real-time processing. The introduction of the ECA attention mechanism enables the model to adaptively adjust the importance of different channels, effectively improving the efficiency and accuracy of feature extraction. The multi-scale feature fusion strategy can comprehensively utilize feature information at different levels, which is conducive to improving the model's ability to recognize small-area green tides and green tide edges.
[0061] Furthermore, this method makes full use of spatiotemporal information to improve the stability and reliability of monitoring results. By performing time series analysis on the recognition results of multiple consecutive time points, the system can capture the dynamic characteristics of green tide changes, rather than relying solely on single-frame images. The application of the Kalman filter is based on the modeling of the movement laws of the green tide. Through the process of prediction and correction, the recognition results are effectively smoothed and the impact of random noise is reduced. This comprehensive use of spatiotemporal information conforms to the objective laws of green tide evolution, and can therefore provide more stable and reliable monitoring results.
[0062] Finally, the early warning mechanism established by this method is based on a multi-dimensional analysis of the development trend of green tides. By setting multi-level early warning thresholds, the system can trigger different levels of early warnings according to the severity of the green tide. Time series analysis techniques (such as the ARIMA model) can capture the trend and periodic characteristics of the change in the area of green tides, providing a basis for short-term predictions. Spatial autocorrelation analysis (such as the Moran index) can assess the spatial aggregation of green tides and help identify the diffusion pattern of green tides. The multi-factor evaluation model based on fuzzy logic takes various indicators into consideration and can more comprehensively assess the risk of green tides. The introduction of the local anomaly factor algorithm increases the system's sensitivity to abnormal green tide development patterns, which is conducive to the early detection of potential large-scale green tide disasters.
[0063] In summary, the technical solution of the present invention forms a complete green tide identification and early warning system through data-driven, algorithm optimization, spatiotemporal information fusion and multi-dimensional analysis. This method meets the actual needs of green tide monitoring and the objective laws of green tide evolution, and can effectively solve the problems existing in the prior art and provide efficient, accurate and real-time green tide monitoring and early warning services.
[0064] In order to better understand and implement the present invention, a specific embodiment 1 of the present invention is provided below. Embodiment 1 completes the construction and training of the green tide semantic segmentation model: The specific implementation method of the construction of the green tide semantic segmentation model in Embodiment 1 is as follows.
[0065] S1. The method for constructing a green tide semantic segmentation model includes: constructing a green tide semantic segmentation image dataset; and training a green tide semantic segmentation model based on the green tide semantic segmentation dataset.
[0066] S1.1 Building a green tide semantic segmentation image dataset The method for constructing a green tide semantic segmentation image dataset includes: collecting green tide images taken by high-point monitoring, and annotating the green tide contours to obtain annotated image data; dividing the annotated image data into a training set, a validation set and a test set according to a preset ratio to obtain a green tide semantic segmentation image dataset.
[0067] The labelme software is used to manually annotate the green tide semantic segmentation data. The generated json annotation file contains the category and location information of each point. The annotation information of each image is matched from the original json annotation file of the dataset according to the name and converted into a mask image. Finally, all image data are divided into training set, validation set, and test set according to the ratio of 80%, 10%, and 10%, finally forming the green tide segmentation image dataset.
[0068] S1.2 Green Tide Semantic Segmentation Model Training (1) Design a deep learning green tide semantic segmentation algorithm model.
[0069] Improve the PSPNet algorithm for green tide semantic segmentation. First, make some improvements to the PSPNet algorithm. Including improvements to the backbone network, adding an attention mechanism module to achieve better recognition results, and improvements to the loss function. Then train and verify the green tide semantic segmentation model. Improve the PSPNet algorithm to form a new algorithm ECA-ShuffledPSPNet.
[0070] The green tide image in the input high-point monitoring is extracted with the ShuffleNetV2 backbone network. The obtained feature map is averaged in the sub-region. The feature pyramid based on the ECA attention mechanism is divided into four levels. The first level is the coarsest level that performs global average pooling on each feature map, and the obtained feature vector is processed by the ECA attention mechanism. The second level divides the feature map into 2×2 sub-regions, and then average pools each sub-region, and the obtained feature vector is processed by the ECA attention mechanism. The third level divides the feature map into 3×3 sub-regions, and then average pools each sub-region, and the obtained feature vector is processed by the ECA attention mechanism. The fourth level divides the feature map into the finest level of 6×6 sub-regions, and then performs pooling on each sub-region, and the obtained feature vector is processed by the ECA attention mechanism. These pyramid features processed by the ECA attention mechanism are directly upsampled to the same size as the input features, and then merged with the input features to perform concat operations to obtain global features. Finally, a convolutional layer is used to generate the final prediction map.
[0071] 1) Replace the PSPNet backbone network with ShuffleNetV2 In the green tide semantic segmentation application scenario, an efficient, stable and accurate model is needed to process a large amount of surveillance video or image data. Since this scenario requires real-time processing of input data, the model must have an efficient inference speed. At the same time, green tide semantic segmentation requires the model to accurately identify and segment the green tide area, so the model needs to have high classification accuracy and semantic segmentation accuracy. Considering the limited hardware resources in the actual application scenario, the model should reduce the amount of calculation and memory usage as much as possible to improve resource utilization.
[0072] Based on the above requirements, it is a suitable choice to replace the backbone network of PSPNet with ShuffleNetV2. As a lightweight convolutional neural network, ShuffleNetV2 has high computing efficiency and low resource usage, which can meet the real-time requirements. At the same time, it also has good feature extraction capabilities and model stability, which can ensure high classification accuracy and semantic segmentation accuracy. Therefore, replacing the backbone network of PSPNet with ShuffleNetV2 can better meet the needs of Green Tide semantic segmentation application scenarios.
[0073] In summary, replacing the backbone network of PSPNet with ShuffleNetV2 can bring benefits and significance such as improved computational efficiency, enhanced model stability, and maintained model performance. This replacement helps optimize the performance of the model, making it more efficient, stable, and reliable in practical applications.
[0074] 2) Combine the ECA attention mechanism with the multi-scale feature fusion strategy.
[0075] The ECA attention mechanism is combined with a multi-scale feature fusion strategy. By applying the ECA attention mechanism on feature maps of different scales in the PSPNet feature pyramid, the model can more effectively fuse and utilize feature information from coarse to fine. ECA combined with multi-scale fusion can help the model better handle details and global information in complex scenes.
[0076] The ECA attention mechanism is a lightweight channel attention mechanism. It learns channel attention through a 1D convolution layer and reduces computational complexity. The ECA attention mechanism avoids dimensionality reduction and instead uses 1D convolution to achieve local cross-channel interactions, thereby extracting dependencies between channels.
[0077] The implementation process of the ECA attention mechanism is shown in Figure 2: First, the input feature map is globally averaged pooled. This step compresses the original two-dimensional feature map [h, w, c] into a one-dimensional vector [1, 1, c], where h and w represent the height and width of the feature map respectively, and c represents the number of channels.
[0078] Next, the adaptive one-dimensional convolution kernel size k is calculated based on the number of channels in the feature map. This k will be used for the subsequent attention weight calculation, which is calculated as follows: , where C is the number of input channels, b=1, =2; Then, k is used for a one-dimensional convolution operation to obtain a weight for each channel. The Sigmoid activation function is used to map the weight between (0-1). This weight reflects the importance of each channel of the feature map.
[0079] Finally, the obtained normalized weights are multiplied by the original input feature map channel by channel to generate a weighted feature map. This step makes each channel of the feature map multiplied by the corresponding weight, thereby emphasizing important channels and suppressing minor channels.
[0080] Through the above steps, the ECA attention mechanism realizes the attention weighted processing of the input feature map, improving the performance and generalization ability of the model.
[0081] The computational complexity of the ECA attention mechanism is relatively low and easy to optimize. The ECA attention calculation is a natural regularization method that does not require additional regularization techniques and is not prone to overfitting.
[0082] 3) Combining FocalLoss and BCELoss loss functions to improve model performance Since the green tide data is less than the background data, the number of class samples is unbalanced, which usually affects the effect of the classification algorithm. In order to solve the class imbalance problem and improve the generalization ability of the model, the present invention combines FocalLoss with BCELoss.
[0083] FocalLoss is a loss function for dealing with class imbalance problems. It can pay more attention to samples that are difficult to classify and reduce the weight of easy-to-classify samples, thereby increasing the focus on small targets.
[0084] The formula of Focalloss is: ; in: ; It reflects the closeness to the groundtruth, i.e., category y. The larger it is, the closer it is to category y, that is, the more accurate the classification is. >0 is an adjustable factor.
[0085] BCELoss is a loss function designed specifically for binary classification problems, which can directly measure the prediction accuracy and robustness of the model. BCELoss adjusts the weights to focus on samples that are difficult to classify, thereby reducing the weights of easy-to-classify samples, which helps improve the generalization ability of the model. By minimizing the cross-entropy loss, the model can gradually adjust the weights and biases to make the predicted results as close to the true results as possible.
[0086] The formula of BCELoss is: L bce = 1 N ∑ i - [ y i log ( p i )+(1 - y i log ( 1 - p i ))] ; Where: yi represents the true value of sample i; Represents the probability that sample i is predicted to be a positive class; N is the total number of image pixels.
[0087] The disadvantage of BCELoss is that it is sensitive to category imbalance, but it can improve the generalization ability of the model, while FocalLoss is specifically designed to deal with category imbalance. Therefore, combining FocalLoss with BCELoss can consider both category imbalance and prediction accuracy.
[0088] The final loss function formula is: ; Combining FocalLoss with BCELoss can give full play to their respective advantages, while ensuring the accuracy of the model, while improving the generalization ability of the model.
[0089] (2) Green Tide Semantic Segmentation Model Training The training process of the green tide segmentation model is as follows: First, prepare an image dataset containing green tide, input the image into the improved semantic segmentation network for forward propagation, and obtain the predicted label of each pixel. Use the joint loss function to calculate the difference between the predicted label and the actual label. According to the calculated loss, the weight parameters of the network are updated by the back propagation algorithm. Error back propagation adjusts the weight parameters to reduce the loss by calculating the gradient and back propagating the gradient layer by layer. Use the Adam optimizer to update the weight parameters in the network according to the gradient. After each training cycle, the performance of the model is evaluated using the test dataset. Evaluation indicators include accuracy, precision, recall, etc. By comparing the evaluation results of different training cycles, the improvement or decline trend of the model performance can be observed. According to the model evaluation results, adjust the hyperparameters to optimize the model performance. Through iterative training, the weights and hyperparameters of the model are continuously optimized to improve the accuracy and stability of semantic segmentation.
[0090] In order to better understand and implement the present invention, Example 2 of a specific application scenario of the present invention is provided below. Unlike Example 1, this Example 2 uses an improved ECA attention mechanism: This Example 2 takes the coastal area of a certain city as the background, and describes in detail the implementation process of the coastal high point monitoring green tide identification and early warning method of the present invention. As an important coastal city in my country, the city faces a serious green tide threat every summer, which has a significant impact on the local tourism industry, fisheries and marine ecosystems. In order to better monitor and warn the occurrence and development of green tides, the local marine environment monitoring department decided to adopt the method of the present invention to establish an efficient and accurate green tide identification and early warning system.
[0091] Step S10: Constructing a green tide semantic segmentation image dataset First, 10 high-point monitoring sites were selected along the city's coast, including different types of areas such as bathing beaches, ports, and islands. Each monitoring site is equipped with a 4K ultra-high-definition camera (resolution of 3840×2160 pixels) with a field of view of 120 degrees, covering a sea area with a radius of about 5 kilometers.
[0092] During the high green tide period from May 1 to August 31, 2023, each monitoring station collected images every 10 minutes, and a total of 123,760 original images were collected. These images cover different weather conditions (sunny, cloudy, cloudy), different time periods (daytime, dusk, night) and different sea conditions (calm, light waves, big waves).
[0093] Next, five experienced marine ecology experts used the LabelMe tool to annotate these images. During the annotation process, the experts carefully outlined the green tide in each image and saved the annotation results in JSON format. To ensure the quality of the annotation, each image was independently annotated by at least two experts, and the final annotation results were determined through cross-validation.
[0094] After screening and quality control, 50,000 high-quality annotated images were finally selected as the dataset. In these images, the distribution of green tide coverage area is as follows: 1-10% coverage: 15,000 sheets; 11-30% coverage: 20,000 sheets; 31-60% coverage: 10,000 sheets; 61-90% coverage: 5,000 sheets; Step S20: data processing; A Python script was developed to convert the JSON annotation file into a binary PNG mask image. After the conversion, the green tide area was marked as 255 (white) and the non-green tide area was marked as 0 (black).
[0095] The original image and the corresponding mask image were uniformly resized to 512 × 512 pixels using the OpenCV library. In order to maintain image quality, the bicubic interpolation algorithm was used for scaling.
[0096] Then, using stratified random sampling, the dataset was divided into a training set (40,000 images), a validation set (5,000 images), and a test set (5,000 images) at a ratio of 80%, 10%, and 10%. Random sampling was performed within each coverage interval to ensure that the distribution of green tide coverage in each subset was similar to that of the overall dataset.
[0097] Finally, the divided dataset is saved in TFRecord format to improve data reading efficiency. At the same time, the PNG compression algorithm is used to compress the image losslessly, reducing the dataset size from the original 256GB to 150GB.
[0098] Step S30: Design a prototype of the deep learning green tide semantic segmentation algorithm model Based on the PSPNet architecture, the backbone network is replaced with ShuffleNetV2. The configuration of ShuffleNetV2 is as follows: Stage 1: Output channels 24, repeated 2 times; Stage 2: Output channels 116, repeated 4 times; Stage 3: Output channel number 232, repeated 8 times; Stage 4: Output channels 464, repeated 4 times; An ECA module is added after each ShuffleNetV2 unit, and the calculation parameters of the adaptive convolution kernel size are set to γ=2, β=1.
[0099] The multi-scale feature fusion strategy extracts feature maps from the four stages of ShuffleNetV2, uniformly adjusts the number of channels to 128 through 1×1 convolution, and then uses bilinear interpolation to upsample all feature maps to 1 / 4 of the input resolution. Finally, the fused feature map is obtained by weighted summation, and the initial weights are set to [0.1, 0.2, 0.3, 0.4].
[0100] The loss function uses a linear combination of FocalLoss and BCELoss, and the weight ratio is initially set to 1:1. The parameters of FocalLoss are set to α=0.25 and γ=2.
[0101] Step S40: Training the green tide semantic segmentation model The model was implemented using the PyTorch deep learning framework. Training was performed on 4 NVIDIA Tesla V100 GPUs with a batch size of 64.
[0102] The Adam optimizer is used, the initial learning rate is set to 0.001, and the weight decay coefficient is set to 0.0001. The cosine annealing learning rate scheduling strategy is used, and the total training cycle is set to 100 epochs.
[0103] Data augmentation strategies include: - Random horizontal flip (probability 0.5); - Random vertical flip (probability 0.5); - Random rotation (-15° to 15°); - Random scaling (0.8 to 1.2 times); - Random brightness adjustment (±20%); - Random contrast adjustment (±20%); - Random saturation adjustment (±20%); During the training process, the model performance is evaluated on the validation set after each epoch. The main evaluation indicators are mean intersection over union (MIoU) and pixel-level accuracy.
[0104] The early stopping strategy is implemented. When the validation set MIoU does not improve for 5 consecutive epochs, the training is terminated early. At the same time, the gradient clipping technology is used to limit the L2 norm of the gradient to less than 5.
[0105] Step S50: Model evaluation and optimization A detailed evaluation was performed on the validation set, and the following performance indicators were obtained as shown in Table 1: Table 1 Performance index table index value Mean Intersection over Union (MIoU) 0.892 Pixel-level accuracy 0.967 F1 score 0.934 Accuracy 0.941 Recall 0.927 Through error analysis, it was found that the model had some problems of missed detection when dealing with small-area green tides (coverage < 5%). To this end, the sampling weight of small targets was increased and more fine-grained features were added to the feature pyramid.
[0106] Adjust the parameters of the ECA module, adjust γ to 1.5 and β to 0.8 to improve the model's sensitivity to channel attention.
[0107] After 5-fold cross validation, the average MIoU reached 0.901 and the standard deviation was 0.008, indicating that the model performance was stable.
[0108] Finally, the three best performing model configurations in cross-validation were selected for ensemble, using model averaging and test-time augmentation techniques. Test-time augmentation includes horizontal flipping, vertical flipping, and 90-degree rotation, and the eight transformation results are averaged for each test sample.
[0109] After optimization, the final performance on the test set is shown in Table 2: Table 2 Performance indicators after optimization index value Mean Intersection over Union (MIoU) 0.915 Pixel-level accuracy 0.978 F1 score 0.952 Accuracy 0.958 Recall 0.946 Step S60: Obtaining the image to be recognized Twenty new high-point monitoring stations were selected along the coast of the city, each of which was installed with an 8K ultra-high-definition camera (with a resolution of 7680×4320 pixels) with a field of view of 135 degrees, covering a sea area with a radius of approximately 8 kilometers.
[0110] The camera parameters are set as follows: -Green tide peak period (May-August): collect images every 3 minutes; - Other periods: images were collected every 15 minutes; The image preprocessing process includes: 1. Use a 5×5 Gaussian filter to remove image noise; 2. Automatic white balance to ensure color reproduction; 3. Contrast-limited adaptive histogram equalization (CLAHE) to improve image details; 4. Use the Brown-Conrady model for lens distortion correction; Using the JPEG2000 compression algorithm, the original image (about 100MB) is compressed to about 20MB, with a compression ratio of 5:1.
[0111] The compressed images are transmitted to the central processing server in real time using the 5G private network. The server uses a distributed storage system and uses the Hadoop Distributed File System (HDFS) to store image data.
[0112] The image quality control algorithm is set as follows: - Clarity assessment: The Laplacian operator is used to calculate the image gradient variance, and the threshold is set to 120; -Exposure check: Ensure that the percentage of pixel values in the range of 15-240 is not less than 97%; -Cloud occlusion detection: Use the threshold segmentation method in the HSV color space, and the cloud coverage threshold is set to 25%.
[0113] Step S70: Green Tide Identification Image preprocessing: The image is scaled to 512 × 512 pixels using the bicubic interpolation algorithm and then normalized to scale the pixel values to the range [-1, 1].
[0114] Model inference: Use the TensorRT inference acceleration framework to run the optimized model on the NVIDIA Tesla T4 GPU. Enable FP16 half-precision calculations, and the average processing time for a single image is 15 milliseconds.
[0115] For 8K original images, the sliding window technology is used to divide the image into 25 overlapping small blocks of 512×512 pixels (overlap rate 50%), predict them separately, and then splice the results to restore them to the original size.
[0116] Post-processing optimization: 1. Apply threshold segmentation, and set the threshold to 0.5; 2. Use 5×5 structural elements to perform morphological opening and closing operations to eliminate small noise areas and fill small holes; 3. Apply conditional random field (CRF) to optimize the segmentation boundary and set the Gaussian kernel σ to 3; Time series analysis: Use Kalman filter to smooth the recognition results of 10 consecutive frames (30 minutes). The parameters of Kalman filter are set as follows: -Process noise covariance Q = 0.01*np.eye(4); -Observation noise covariance R = 0.1*np.eye(2); - Initial state covariance P = 1000*np.eye(4); Step S80: Early warning judgment To set the warning threshold: - Mild warning: The green tide area accounts for 5% of the monitoring area; - Moderate warning: The green tide area accounts for 10% of the monitored area; - Severe warning: The green tide area accounts for 20% of the monitoring area; Time series analysis: The ARIMA (2,1,2) model was used to model the green tide area data of the past 7 days and predict the development trend of the green tide in the next 24 hours.
[0117] Spatial autocorrelation analysis: The Moran index was used to assess the spatial aggregation of green tides, and the spatial weight matrix was set to inverse distance weighting.
[0118] Multi-factor evaluation model: Establish an evaluation model based on fuzzy logic, with input variables including green tide area, growth rate, spatial concentration and meteorological conditions (temperature, wind direction, wind speed). Fuzzy rule example: -IF (area IS large) AND (growth rate IS fast) AND (spatial concentration IS high) THEN (risk IS very high); -IF (area IS medium) AND (growth rate IS slow) AND (weather conditions IS unfavorable) THEN (risk IS medium); Anomaly detection: Use the local outlier factor (LOF) algorithm, set k=5, and the LOF threshold to 2.0.
[0119] Warning trigger and notification: -When the comprehensive risk assessment result exceeds 0.7 or the LOF value exceeds 2.0, the early warning system is triggered; - Send early warning information to relevant managers via SMS, email and mobile app push; - Warning information includes: warning level, green tide area and location, 24-hour development trend forecast, and recommended measures; -Use ArcGIS to build a visualization platform to display the green tide distribution and warning areas in real time on the electronic map.
[0120] System operation results: The system was put into use during the peak green tide period from May 1 to August 31, 2024. During this period, a total of 3,942,000 images were processed and 387 green tide events were identified, including: - Mild warning: 276 times; - Moderate warning: 89 times; - Severe warning: 22 times; The system’s average processing time is 0.8 seconds per image, including the entire process of image preprocessing, model inference, post-processing, and early warning judgment. The average delay in sending early warning information is 30 seconds.
[0121] Compared with traditional satellite remote sensing and offshore field survey methods, this system has shown significant advantages in early identification of green tides. In 22 severe warning events, 19 warnings were issued 24-48 hours earlier than traditional methods, buying valuable response time for emergency management departments.
[0122] The accuracy of the system has also been verified. Through random sampling and field verification, the average error of the system's green tide area estimation is within ±7%, and the average deviation of the location accuracy is less than 100 meters.
[0123] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A method for identifying and warning green tides at coastal high points, characterized in that: The following steps are involved: S10, collecting a large number of green tide images taken by high-point monitoring, and annotating the green tide contours in the green tide images with JSON data to obtain annotated image data; S20, converting the data annotations in JSON format into PNG mask images, and dividing them into a training set, a validation set, and a test set to obtain a green tide semantic segmentation image training data set; S30, select the PSPNet semantic segmentation algorithm, replace the backbone network with ShuffleNetV2, and combine the ECA attention mechanism equation group with the multi-scale feature fusion strategy, and combine the Focal Loss and BCELoss loss functions to solve the category imbalance problem and improve the generalization ability of the model; S40, using the green tide semantic segmentation image training data set to train a deep learning green tide semantic segmentation algorithm model prototype, and updating each weight of the deep learning green tide semantic segmentation algorithm model prototype by error back propagation; S50, using the validation set to evaluate the performance of the trained deep learning green tide semantic segmentation algorithm model prototype, adjusting the hyperparameters to optimize the model performance, and selecting the optimal model as the green tide semantic segmentation model; S60, acquiring real-time image data from a coastal high point monitoring system as an image to be identified; S70, preprocessing the image to be identified, inputting it into the trained green tide semantic segmentation model, and obtaining the segmentation mask of the green tide; S80, judging whether the green tide area exceeds a preset threshold or has abnormal changes according to the segmentation mask, and if the conditions are met, triggering an early warning system and notifying relevant management personnel.
2. A coastal high point monitoring green tide identification and early warning method according to claim 1, characterized in that: The ECA attention mechanism equation group includes an adaptive convolution kernel size calculation equation, a global average pooling equation, a one-dimensional convolution operation equation, a Sigmoid activation function equation, and an attention weighted equation.
3. A coastal high point monitoring green tide identification and early warning method according to claim 2, characterized in that: The adaptive convolution kernel size calculation equation is specifically expressed as: ; Where: is the number of channels of the input feature map; is an adjustable scaling factor, optimized in the range of [0.1, 10] by grid search; is the bias term, which is optimized in the range of [-5,5] by random search; Round down to the nearest odd number.
4. A coastal high point monitoring green tide identification and early warning method according to claim 3, characterized in that: The global average pooling equation is specifically expressed as: ; Where: For the Global average pooling result of channels; , is the height and width of the input feature map; The input feature map is Channels, positions The value of .
5. A coastal high point monitoring green tide identification and early warning method according to claim 4, characterized in that: The one-dimensional convolution operation equation is specifically expressed as: ; Where: For the One-dimensional convolution output of channels; The convolution kernel size is calculated adaptively; The one-dimensional convolution kernel weights can be learned and optimized through back-propagation; It is the global average pooling result after loop padding.
6. A coastal high point monitoring green tide identification and early warning method according to claim 5, characterized in that: The Sigmoid activation function equation is specifically expressed as: ; Where: For the The attention weight of each channel; is the steepness parameter of the Sigmoid function, optimized by gradient descent; is the center shift of the Sigmoid function, optimized by gradient descent.
7. A coastal high point monitoring green tide identification and early warning method according to claim 6, characterized in that: The attention weighted equation is specifically expressed as: ; Where: The output feature map is Channels, positions The value of The input feature map is Channels, positions The value of For the The attention weight of each channel; is a small constant to prevent division by zero errors. The default setting is ; , are learnable spatial attention parameters optimized via back-propagation; is the hyperbolic tangent function, which is used to introduce spatial attention.
8. A coastal high point monitoring green tide identification and early warning method according to claim 7, characterized in that: The formula combining the ECA attention mechanism equation group with the multi-scale feature fusion strategy is expressed as follows: Step 1: Multi-scale feature extraction, specifically expressed as: ; Where: :No. Feature map of the layer; :No. Feature extraction function of the layer; : Input image; :Total number of layers; Step 2: ECA attention mechanism is applied to each scale, specifically expressed as: ; Where: Represents the ECA attention mechanism equation set; Step 3: Multi-scale feature fusion: ; Where: : The first Layer feature map; : Upsampling function, which upsamples the feature map to the same size as the highest resolution feature map; :No. The fusion weight of the layer features is obtained through learning and satisfies ; Step 4: The final feature map is generated, which is specifically expressed as: ; in It is a learnable transformation function used to adjust the number of channels of the fused features; Where: :No. The number of channels of the layer feature map; , :No. The height and width of the layer feature map; , :No. ECA adaptive convolution kernel size calculation parameters of the layer; :No. The one-dimensional convolution kernel weights of the layer; , :No. Sigmoid function parameters of the layer; :No. Small constants for layers to prevent division by zero errors; , :No. The spatial attention parameters of the layer.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions, which, when executed, are used to execute the coastal high point monitoring green tide identification and early warning method described in any one of claims 1-8.
10. A coastal high point monitoring green tide identification and early warning system, characterized in that: A computer-readable storage medium comprising the computer-readable storage medium of claim 9.
Citation Information
Patent Citations
Remote sensing image green tide information extraction method based on deep learning and super-resolution
CN112966580A
Image semantic segmentation model and segmentation method
CN116468740A
Smoke segmentation method, system and device based on deep neural network, and medium
CN116612130A
Red tide detection method and system, medium, computer equipment and terminal
CN117911885A
Overhead transmission line icing form segmentation method
CN118411724A
Cited By
Seawater area eutrophication judgment and early warning method and system based on image recognition
CN120635720A
In-pipeline sewage monitoring system and method based on deep learning
CN121617042A