Water body segmentation optimization method based on transfer learning
The method leverages transfer learning and U-Net models with data preprocessing and augmentation to address the challenge of limited data samples in water body segmentation, enhancing model performance and efficiency, particularly in resource-limited environments.
Patent Information
- Application Number
- CN202411734326.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-11-29
AI Technical Summary
In the field of remote sensing image processing, water body segmentation faces challenges due to limited data samples, leading to inadequate model generalization and high computational resource requirements, especially in resource-constrained environments.
A method utilizing transfer learning with U-Net models, involving data preprocessing, normalization, and data augmentation, combined with gradient descent optimization, to enhance water body segmentation performance in scenarios with limited data.
This approach improves the efficiency and effectiveness of water body segmentation models by reducing data sample requirements and optimizing network performance, making them suitable for various water body image segmentation tasks.
Smart Images

Figure CN119723578A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a water body segmentation optimization method based on transfer learning, and belongs to the field of remote sensing image processing. Background Art
[0002] In the field of remote sensing image processing, water body segmentation is a crucial task and has important application value in environmental monitoring, urban planning, disaster management and other fields. However, the complexity of remote sensing images and the variability of water areas, especially under the condition of small sample data sets, often make deep learning-based methods in water body segmentation unsatisfactory. Although training with large-scale data sets has been proven to significantly improve the performance of the model, the problem of data scarcity makes the implementation of this method challenging in practical applications. Therefore, how to optimize the performance of water body segmentation models under the condition of limited data samples has become a key technical problem that needs to be broken through in this field.
[0003] As a method of using existing knowledge to accelerate the learning of new tasks, transfer learning can effectively solve the problem of insufficient samples in the target field. Therefore, it shows great potential in the task of water segmentation. By borrowing knowledge from the source field, it can significantly improve the training efficiency and effect of the model, thereby optimizing the performance of the water segmentation model in practical applications. Summary of the invention
[0004] The technical problem to be solved by the present invention is: in the practical application of water body remote sensing image segmentation, the water body image data in the target domain is scarce, the generalization performance of the training model in feature learning is insufficient, and the computing resources required in the training and reasoning process are relatively high, which limits the application of the training model in resource-constrained environments.
[0005] In order to solve the above technical problems, the present invention provides a water body segmentation optimization method based on transfer learning, comprising the following steps:
[0006] Step 1: collect visible light remote sensing water body image data of the target domain, preprocess the image data, and construct an initial image data set;
[0007] Step 2, based on the standardized initial image data set, calculate the normalized water index NDWI, generate the corresponding mask map, and form an initial mask data set;
[0008] Step 3: Select a pre-trained model based on the characteristics of the initial data set and task requirements, and use the pre-trained model to design a U-Net model architecture suitable for transfer learning;
[0009] Step 4: divide the initial data set into a training set and a validation set, and perform data augmentation on the training set to expand the training set;
[0010] Step 5, using the enhanced training set to train the U-Net model pre-designed in step 3), using the gradient descent method combined with three transfer learning methods to optimize the U-Net model, and obtaining three adjustment models;
[0011] Step 6: Evaluate the performance of the three adjusted models on an independent validation set, compare them using key indicators, select the best performing model as the adjusted deep learning model, and further optimize the adjusted deep learning model through multiple rounds of iterative training and parameter adjustment;
[0012] Step 7: Input the original image data in the validation set into the optimized and adjusted neural network model to obtain the segmented image after water body prediction optimization.
[0013] The aforementioned water body segmentation optimization method based on transfer learning includes, in step 1:
[0014] 11) Using satellite images through remote sensing technology to obtain visible light water image datasets in specific areas;
[0015] 12) Use the standard score Z-score to detect and remove outliers in the water image dataset;
[0016] 13) The image data cleaned in step 12) is normalized to a specific range.
[0017] The aforementioned water body segmentation optimization method based on transfer learning, in step 12), includes:
[0018] 121) For a given set of water body image data N, the pixel values of all images are combined into a one-dimensional array , calculate the mean μ and standard deviation σ of the water body image dataset according to formula (1):
[0019] (1)
[0020] (2)
[0021] Where M is the total number of pixels in all images, is the value of the jth pixel, is the square of the difference between each pixel value and the mean;
[0022] 122) Calculate the Z-Score value of each image observation in the image dataset:
[0023] (3)
[0024] in, is the Z-Score value of the j-th pixel, is the original value of the jth pixel, is the mean of all pixel values, and σ is the standard deviation of all pixel values;
[0025] 123) Set a threshold and compare the Z-Score value of each data point with the threshold. If the absolute value of the Z-Score value is greater than the threshold, the corresponding observation is marked as an outlier and the outlier is removed. After removing the outlier, the statistical characteristics of the data are re-evaluated.
[0026] In the above-mentioned water body segmentation optimization method based on transfer learning, in step 13), for a given image data I, the grayscale image two-dimensional array and a color image 3D array , use formula (4) to normalize the image data to the range [0, 1]:
[0027] (4)
[0028] in is the normalized image data, is the minimum pixel value in the original image data, is the maximum pixel value in the original image data.
[0029] The aforementioned water body segmentation optimization method based on transfer learning, in step 2, includes:
[0030] 21) For a given original image, extract pixel values from the green and near-infrared bands of the original image, and use equation (5) to scale each pixel value range to between 0 and 1:
[0031] (5)
[0032] Among them, the minimum and maximum values are the minimum and maximum values of all pixel values in the green band and near-infrared band;
[0033] 22) Use the normalized green band Green and the normalized near infrared band NIR to calculate the normalized difference water index NDWI, map the pixel value to the range of -1 to 1, and generate an NDWI image ranging from -1 to 1. The formula is as follows:
[0034] (6)
[0035] Among them, Green represents the green band, and NIR represents the near infrared band;
[0036] 23) A threshold is preset, and according to the pixel value in the NDWI image, the part with pixel value greater than the threshold is regarded as water body, and the part with pixel value less than the threshold is regarded as non-water body, and the corresponding mask map is generated to form a mask data set.
[0037] The aforementioned water body segmentation optimization method based on transfer learning, in step 3, includes:
[0038] 31) According to the water image characteristics of the initial data set, ResNet-18 is selected as the pre-training model. ResNet-18 consists of multiple residual blocks, including convolutional layers, batch normalization layers and activation functions Sigmoid; in ResNet-18, each residual block consists of two convolutional layers and a jump connection. Given the input x and the corresponding output H(x), the residual network outputs by learning the residual function F(x), and the formula is as follows:
[0039] (7)
[0040] 32) Build a U-Net model architecture suitable for transfer learning, use ResNet-18 as the backbone network of the encoder part, and create a decoder network symmetrical to the encoder part. The decoder is connected to the encoder, and gradually upsamples the image that has been downsampled by the encoder to restore the original size and details of the image; add skip connections to each layer of the decoder, fuse the feature map of the encoder with the corresponding layer of the decoder, add an output layer at the end of the decoder, and use the Sigmoid activation function to generate a binary or two-value segmentation mask;
[0041] 33) Load all the parameters of the Resnet18 pre-trained model trained in Imagenet into the encoder part of U-Net to obtain a universal feature extractor. Use the pre-trained weights of ResNet-18 to initialize the encoder part of U-Net and extract high-level features. The formula is as follows:
[0042] (8)
[0043] in are the parameters of the pre-trained model, are the initial parameters of the target model inherited from the pre-trained model.
[0044] The aforementioned water body segmentation optimization method based on transfer learning, in step 4, includes:
[0045] 41) Divide the image dataset obtained after preprocessing in step 1 and the mask dataset obtained in step 2 into a training set and a test set according to a set ratio;
[0046] 42) The data enhancement methods are used to enhance the training set. There are four data enhancement methods, including 15-degree and 30-degree rotation operations, horizontal flipping, vertical flipping and scaling.
[0047] In the above-mentioned water body segmentation optimization method based on transfer learning, in step 5, when the constructed U-Net model is trained using the enhanced training set, the batch size batch_size and the number of training epochs are set; the activation function of the hidden layer is relu, the activation function of the output layer is sigmoid, and the optimizer uses SGD;
[0048] The loss function uses BinaryCross-EntropywithLogitsLoss. For a single data point, the binary cross entropy loss Defined as:
[0049] (17)
[0050]
[0051] Where y is the true label and z is the logits output of the model, i.e. the predicted value before applying the sigmoid activation. is the sigmoid function.
[0052] In the above-mentioned water body segmentation optimization method based on transfer learning, in step 5, optimization processing is performed during the U-Net model training process, and the entire U-Net model is trained using the data set of the target task. The value of the loss function is gradually reduced through multiple iterations of forward propagation and back propagation, thereby learning the weights that can accurately predict the water body segmentation image. The weight formula is as follows:
[0053]
[0054] Among them, arg represents the weight value, min is the minimum value, L is the loss function, x is the input data of the model, y is the true label, f is the forward propagation function of the model, and f(x) is the output of the model. Represents the optimal weight value corresponding to minimizing the loss function L on the target data set.
[0055] In the above-mentioned water body segmentation optimization method based on transfer learning, in step 5, optimizing the U-Net model includes the following steps:
[0056] 531) Three different transfer learning methods are used for the U-Net model: 1) adjust the parameters of all layers and fully optimize the model to obtain a fully adjusted + U-Net model; 2) freeze the parameters of other layers in the model and only adjust the parameters of the output layer to obtain a partially adjusted + U-Net model; 3) first freeze the parameters of other layers in the model and only adjust the parameters of the output layer; then unfreeze the parameters of all layers except the output layer, and adjust all layers to obtain a layer-by-layer unfreeze adjustment + U-Net model;
[0057] 532) Use the data-enhanced training set to perform forward propagation on the fully adjusted + U-Net model, the partially adjusted + U-Net model, and the layer-by-layer unfreezing adjusted + U-Net model, calculate their respective prediction values, and calculate the loss function L of the three adjustment models based on their respective prediction values and the true values of the corresponding sample data;
[0058] 533) Using the calculated loss function, the gradient of the loss function to the U-Net model parameters is calculated through the back propagation algorithm, and the parameters of the model are updated according to the gradient descent algorithm to gradually reduce the loss function;
[0059] 534) Repeat steps 532)-533) until the maximum number of training times is reached, and three adjusted and trained neural network models are obtained.
[0060] The aforementioned water body segmentation optimization method based on transfer learning, in step 6, includes:
[0061] 61) Using the three trained neural network models, the three adjustment strategies were tested using independent test sets, and the prediction categories of each model were calculated. The key indicators were obtained based on the number of correctly classified samples and the total number of samples of each model.
[0062] 62) After the test is completed, record the key indicator values of each model and select the best performing model as the final adjusted deep learning model;
[0063] 63) After selecting the best model, based on the preliminary experimental results, a grid search method is used to explore the hyperparameter space and adjust key hyperparameters, including learning rate, batch size, and number of training rounds. Multiple possible combinations of hyperparameter values are set to evaluate the impact of each combination on model performance.
[0064] In the aforementioned water body segmentation optimization method based on transfer learning, in step 63), for each hyperparameter combination, the following steps are performed:
[0065] 631) Use the training set to train the model;
[0066] 632) At the end of each training cycle, use the validation set to evaluate model performance and record key metrics;
[0067] 633) Loop through steps 631)-632) until all hyperparameter combinations are evaluated.
[0068] 634) Organize and record the performance results for each hyperparameter combination, compare the model performance of different combinations, and identify the best performing hyperparameter combination.
[0069] The beneficial effects achieved by the present invention are as follows: the method of the present invention utilizes a neural network model to fit water body remote sensing data, and adopts a transfer learning method to adjust the neural network model, thereby solving the problem of insufficient model generalization ability caused by insufficient sample size of water body remote sensing segmentation image data, reducing the demand for data sample size, and improving the efficiency of model training. The method has good applicability and can be applied to different water body remote sensing image segmentation tasks, and by optimizing the network structure and parameters, the performance of the neural network model and the segmentation accuracy are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 This is a flow chart of the water body segmentation optimization method based on transfer learning in Example 1 of the present invention;
[0071] Figure 2 is a histogram after data cleaning in Example 1 of the present invention;
[0072] Figure 3 Schematic diagram of data normalized difference water index (NDWI) processing in Example 1 of the present invention;
[0073] Figure 4 A neural network model diagram optimized and constructed in Example 1 of the present invention;
[0074] Figure 5 Schematic diagram of the pre-training and adjustment architecture in Embodiment 1 of the present invention;
[0075] Figure 6 Schematic diagram of the data enhancement strategy in Example 1 of the present invention;
[0076] Figure 7 This is the full adjustment + U-Net model training loss graph in Example 1 of the present invention;
[0077] Figure 8 This is a partial adjustment + U-Net model training loss graph in Example 1 of the present invention;
[0078] Fig. 9 This is the gradual unfreezing adjustment + U-Net model training loss graph in Example 1 of the present invention;
[0079] Fig.10This is a curve diagram of the training accuracy of the full adjustment + U-Net model in Example 1 of the present invention;
[0080] Fig.11 This is a curve diagram of partial adjustment + U-Net model training accuracy in Example 1 of the present invention;
[0081] Fig.12 This is a curve diagram of the gradual thawing adjustment + U-Net model training accuracy in Example 1 of the present invention;
[0082] Fig.13 This is the water body prediction image output by the application method of Example 1 of the present invention. DETAILED DESCRIPTION
[0083] The method of the present invention is described in detail below with reference to the accompanying drawings.
[0084] Example 1
[0085] Reference Figure 1 , this embodiment provides a water body segmentation optimization method based on transfer learning, including the following steps:
[0086] Step 1: collect visible light remote sensing water body image data of the target domain, preprocess the image data, and construct an initial image data set, including:
[0087] 11) Using satellite images through remote sensing technology, we obtained a dataset of visible light water images in a specific area, including 2,800 images of rivers, lakes, oceans, and other scenes;
[0088] 12) Use Z-score (standard score) to detect outliers in water image datasets and remove outliers;
[0089] 121) For a given set of water body image data N, the pixel values of all images are combined into a one-dimensional array , calculate the mean μ and standard deviation σ of the water body image dataset according to formula (1):
[0090] (1)
[0091] (2)
[0092] Where M is the total number of pixels in all images, is the value of the jth pixel, is the square of the difference between each pixel value and the mean;
[0093] 122) Calculate the Z-Score value of each image observation in the image dataset:
[0094] (3)
[0095] in, is the Z-Score value of the j-th pixel, is the original value of the jth pixel, is the mean of all pixel values, and σ is the standard deviation of all pixel values;
[0096] 123) Set the threshold to 3, compare the Z-Score value of each data point with the threshold, and if the absolute value of the Z-Score value is greater than 3, mark the corresponding observation as an outlier and remove the outlier. After removing the outlier, re-evaluate the statistical characteristics of the data, draw a histogram and compare the pixel value distribution before and after the outlier is removed, as shown in Figure 123. Figure 2 As shown, the x-axis of the histogram represents the pixel value, and the y-axis represents the corresponding pixel value frequency;
[0097] 13) The image data after cleaning in step 12) is normalized to a specific range, which is 0 to 1 in this embodiment:
[0098] For a given image data I, the grayscale image two-dimensional array and a color image 3D array , use formula (4) to normalize the image data to the range [0, 1]:
[0099] (4)
[0100] in is the normalized image data, is the minimum pixel value in the original image data, is the maximum pixel value in the original image data.
[0101] Step 2, based on the standardized initial image data set, calculate the normalized water index NDWI, generate the corresponding mask map, and form the initial mask data set, including the following steps:
[0102] 21) For a given original image, extract pixel values from the green and near-infrared bands of the original image, and use equation (5) to scale each pixel value range to between 0 and 1:
[0103] (5)
[0104] Among them, the minimum and maximum values are the minimum and maximum values of all pixel values in the green band and near-infrared band;
[0105] 22) Use the normalized green band Green and the normalized near infrared band NIR to calculate the normalized difference water index NDWI, map the pixel value to the range of -1 to 1, and generate an NDWI image ranging from -1 to 1. The formula is as follows:
[0106] (6)
[0107] Among them, Green represents the green band, and NIR represents the near infrared band;
[0108] 23) The preset threshold is 0.5. According to the pixel value in the NDWI image, the part with pixel value greater than the threshold is regarded as water body, and the part with pixel value less than the threshold is regarded as non-water body. Figure 3 As shown, the corresponding mask map is generated to form a mask data set.
[0109] Step 3: Select a suitable pre-trained model based on the characteristics of the initial data set and task requirements, and use the pre-trained model to design a U-Net model architecture suitable for transfer learning, including the following steps:
[0110] 31) According to the water image characteristics of the initial dataset, ResNet-18 (Residual Network-18) was selected as the pre-training model. ResNet-18 consists of multiple residual blocks, including convolutional layers, batch normalization layers and activation functions Sigmoid; in ResNet-18, each residual block consists of two convolutional layers and a skip connection. Given the input x and the corresponding output H(x), the residual network outputs by learning the residual function F(x), and the formula is as follows:
[0111] (7)
[0112] 32) Build a U-Net model architecture suitable for transfer learning, such as Figure 4 As shown in the figure, ResNet-18 is used as the backbone network of the encoder part, and a decoder network symmetrical to the encoder part is created. The decoder is connected to the encoder, and the image with reduced size after downsampling by the encoder is gradually upsampled to restore the original size and details of the image; a jump connection is added to each layer of the decoder, the feature map of the encoder is fused with the corresponding layer of the decoder, an output layer is added at the end of the decoder, and a sigmoid activation function is used to generate a binary or two-value segmentation mask;
[0113] 33) Load all the parameters of the Resnet18 pre-trained model trained on Imagenet into the encoder part of U-Net to obtain a general feature extractor, such as Figure 5As shown, the encoder part of U-Net is initialized using the pre-trained weights of ResNet-18 to extract high-level features. The formula is as follows:
[0114] (8)
[0115] in are the parameters of the pre-trained model, are the initial parameters of the target model inherited from the pre-trained model.
[0116] Step 4: Divide the initial data set into a training set and a validation set, and perform data augmentation on the training set to expand the training set, including:
[0117] 41) Divide the image dataset obtained after preprocessing in step 1 and the mask dataset obtained in step 2 into a training set and a validation set in a ratio of 8:2 respectively;
[0118] 42) Figure 6 As shown, the training set is enhanced using a data enhancement method, and there are four data enhancement methods, including 15-degree and 30-degree angle rotation operations, horizontal flipping, vertical flipping, and scaling.
[0119] Rotate the image around the center point by an angle of θ, and move a pixel point ( , ) as a rotation around the origin pixel The pixel point of the angle is rotated to ( , ), by rotating the image around the center point (0, 0), the rotation formula is as follows:
[0120] (9)
[0121] (10)
[0122] in,( , ) is the original coordinate, ( , ) is the rotated coordinate, is the rotation angle, which can be set to 15 degrees or 30 degrees;
[0123] Flip vertically around the x-axis. The formula for vertical flip is as follows:
[0124] (11)
[0125] (12)
[0126] in,( , ) is the original coordinate, ( , ) is the coordinate after vertical flip;
[0127] Flip horizontally around the y-axis. The formula for horizontal flip is as follows:
[0128] (13)
[0129] (14)
[0130] in,( , ) is the original coordinate, ( , ) is the coordinate after horizontal flipping;
[0131] Scaling, for a point ( , ), the scaled point ( , ) is calculated by the following formula:
[0132] (15)
[0133] (16)
[0134] ( , ) is the original coordinate, ( , ) are the scaled coordinates and s is the scaling factor.
[0135] Step 5: Use the enhanced training set to train the U-Net model designed in step 3), and use the gradient descent method combined with three transfer learning methods to optimize the U-Net model to obtain three adjustment models, including:
[0136] 51) Use the enhanced training set to train the constructed U-Net model, set the batch size batch_size to 16, the number of training epochs to 150; the activation function of the hidden layer is relu, the activation function of the output layer is sigmoid, and the optimizer uses SGD;
[0137] 52) The loss function uses BinaryCross-EntropywithLogitsLoss. For a single data point, the binary cross entropy loss Defined as:
[0138] (17)
[0139]
[0140] Where y is the true label and z is the logits output of the model, i.e. the predicted value before applying the sigmoid activation. is the sigmoid function.
[0141] 53) Use the dataset of the target task and combine three different transfer learning methods to train the entire U-Net model. Through multiple iterations of forward propagation and back propagation, the value of the loss function is gradually reduced, so as to learn the weights that can accurately predict the water body segmentation image. The weight formula is as follows:
[0142]
[0143] Among them, arg represents the weight value, min is the minimum value, L is the loss function, x is the input data of the model, y is the true label, f is the forward propagation function of the model, and f(x) is the output of the model. Represents the optimal weight value corresponding to minimizing the loss function L on the target data set.
[0144] 531) Figure 5 As shown in the figure, three different transfer learning methods are used for the U-Net model: 1) Full adjustment: adjust the parameters of all layers, comprehensively optimize the model, and obtain the full adjustment + U-Net model; 2) Partial adjustment: freeze the parameters of other layers in the model, and only adjust the parameters of the output layer, and obtain the partial adjustment + U-Net model; 3) Layer-by-layer unfreeze adjustment: first freeze the parameters of other layers in the model, and only adjust the parameters of the output layer; then unfreeze the parameters of other layers except the output layer, adjust all layers, and obtain the layer-by-layer unfreeze adjustment + U-Net model;
[0145] 532) The training set after data enhancement is used to perform forward propagation on the fully adjusted + U-Net model, the partially adjusted + U-Net model, and the layer-by-layer unfreezing adjusted + U-Net model, and their respective predicted values are calculated. The loss function L of the three adjusted models is calculated based on their respective predicted values and the true values of the corresponding sample data. Among them, the training loss graph of the fully adjusted + U-Net model is shown in Figure 7 As shown, the training loss diagram of partial adjustment + U-Net model adjustment is as follows Figure 8 As shown, the training loss graph of layer-by-layer unfreezing adjustment + U-Net model adjustment is as follows Fig. 9 As shown;
[0146] 533) Using the calculated loss function, the gradient of the loss function to the U-Net model parameters is calculated through the back propagation algorithm, and the model parameters are updated according to the gradient descent algorithm to gradually reduce the loss function. Figure 7 , Figure 8 and Fig. 9 It can be seen that during the training process of the three models, namely, the full adjustment + U-net model, the partial adjustment + U-net model, and the layer-by-layer unfreezing adjustment + U-net model, the loss function values all showed a similar downward trend and finally oscillated around a stable value, indicating that the neural network model has achieved a good fitting effect;
[0147] 534) Repeat steps 532)-533) until the maximum number of training times is reached, and three adjusted and trained neural network models are obtained.
[0148] Step 6: Evaluate the performance of the three adjusted models on an independent validation set, use key indicators for comparison, select the best performing model as the adjusted deep learning model, and further optimize the adjusted deep learning model through multiple rounds of iterative training and parameter adjustment to improve the effect of water body segmentation;
[0149] 61) Using the three trained neural network models, the three adjustment strategies were evaluated using independent validation sets, and the prediction categories of each model were calculated. The key indicators were obtained based on the number of correctly classified samples and the total number of samples of each model.
[0150] 62) After the evaluation is completed, record the key indicator values of each model. The training accuracy curve of the fully adjusted + U-Net model is as follows Fig.10 As shown, the training accuracy curve of partial adjustment + U-Net model adjustment is as follows Fig.11 As shown, the layer-by-layer unfreezing adjustment + U-Net model training accuracy curve is as follows Fig.12 As shown, by comparing the accuracy values, the best performing model is selected as the final adjusted deep learning model;
[0151] 63) After selecting the best model, based on the preliminary experimental results, the grid search method was used to systematically explore the hyperparameter space, adjust key hyperparameters, including learning rate, batch size, and number of training rounds, set multiple possible combinations of hyperparameter values, and evaluate the impact of each combination on model performance;
[0152] For each hyperparameter combination, perform the following steps:
[0153] 631) Use the training set to train the model;
[0154] 632) At the end of each training cycle, use the validation set to evaluate model performance and record key metrics;
[0155] 633) Loop through steps 631)-632) until all hyperparameter combinations are evaluated.
[0156] 634) Organize and record the performance results for each hyperparameter combination, compare the model performance of different combinations, and identify the best performing hyperparameter combination;
[0157] Through the optimized key performance indicators, the water body segmentation model is further adjusted to achieve the optimization of model performance and segmentation effect;
[0158] Step 7: Input the original image data in the validation set into the optimized and adjusted neural network model to obtain the segmented image after water body prediction optimization, such as Fig.13 shown.
[0159] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0160] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0161] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0162] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0163] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A water body segmentation optimization method based on transfer learning, characterized in that: The following steps are involved: Step 1: collect visible light remote sensing water body image data of the target domain, preprocess the image data, and construct an initial image data set; Step 2, based on the standardized initial image data set, calculate the normalized water index NDWI, generate the corresponding mask map, and form an initial mask data set; Step 3: Select a pre-trained model based on the characteristics of the initial data set and task requirements, and use the pre-trained model to design a U-Net model architecture suitable for transfer learning; Step 4: Divide the initial data set into a training set and a validation set, and perform data augmentation on the training set; Step 5, using the enhanced training set to train the U-Net model designed in step 3), using the gradient descent method combined with three transfer learning methods to optimize the U-Net model, and obtaining three adjustment models; Step 6: Evaluate the performance of the three adjusted models on an independent validation set, compare them using key indicators, select the best performing model as the adjusted deep learning model, and further optimize the adjusted deep learning model through multiple rounds of iterative training and parameter adjustment; Step 7: Input the original image data in the validation set into the optimized and adjusted neural network model to obtain the segmented image after water body prediction optimization.
2. According to the water body segmentation optimization method based on transfer learning in claim 1, it is characterized in that: In step 1, include: 11) Using satellite images through remote sensing technology to obtain visible light water image datasets in specific areas; 12) Use the standard score Z-score to detect and remove outliers in the water image dataset; 13) performing standardization processing on the cleaned image data in step 12) to standardize the image data to a specific range; In step 12), including: 121) For a given set of water body image data N, the pixel values of all images are combined into a one-dimensional array , calculate the mean μ and standard deviation σ of the water body image dataset according to formula (1): (1) (2) Where M is the total number of pixels in all images, is the value of the jth pixel, is the square of the difference between each pixel value and the mean; 122) Calculate the Z-Score value of each image observation in the image dataset: (3) in, is the Z-Score value of the j-th pixel, is the original value of the jth pixel, is the mean of all pixel values, and σ is the standard deviation of all pixel values; 123) Set a threshold and compare the Z-Score value of each data point with the threshold. If the absolute value of the Z-Score value is greater than the threshold, the corresponding observation is marked as an outlier and the outlier is removed. After removing the outlier, the statistical characteristics of the data are re-evaluated.
3. The water body segmentation optimization method based on transfer learning according to claim 2 is characterized in that: In step 13), for a given image data I, the grayscale image two-dimensional array and a color image 3D array , use formula (4) to normalize the image data to the range [0, 1]: (4) in is the normalized image data, is the minimum pixel value in the original image data, is the maximum pixel value in the original image data; In step 2, include: 21) For a given original image, extract pixel values from the green and near-infrared bands of the original image, and use equation (5) to scale each pixel value range to between 0 and 1: (5) Among them, the minimum and maximum values are the minimum and maximum values of all pixel values in the green band and near-infrared band; 22) Use the normalized green band Green and the normalized near infrared band NIR to calculate the normalized difference water index NDWI, map the pixel value to the range of -1 to 1, and generate an NDWI image ranging from -1 to 1. The formula is as follows: (6) Among them, Green represents the green band, and NIR represents the near infrared band; 23) A threshold is preset, and according to the pixel value in the NDWI image, the part with pixel value greater than the threshold is regarded as water body, and the part with pixel value less than the threshold is regarded as non-water body, and the corresponding mask map is generated to form a mask data set.
4. The water body segmentation optimization method based on transfer learning according to claim 1 is characterized in that: In step 3, include: 31) According to the water image characteristics of the initial data set, ResNet-18 is selected as the pre-training model. ResNet-18 consists of multiple residual blocks, including convolutional layers, batch normalization layers and activation functions Sigmoid; in ResNet-18, each residual block consists of two convolutional layers and a jump connection. Given the input x and the corresponding output H(x), the residual network outputs by learning the residual function F(x), and the formula is as follows: (7) 32) Build a U-Net model architecture suitable for transfer learning, use ResNet-18 as the backbone network of the encoder part, and create a decoder network symmetrical to the encoder part. The decoder is connected to the encoder, and gradually upsamples the image that has been downsampled by the encoder to restore the original size and details of the image; add skip connections to each layer of the decoder, fuse the feature map of the encoder with the corresponding layer of the decoder, add an output layer at the end of the decoder, and use the Sigmoid activation function to generate a binary or two-value segmentation mask; 33) Load all the parameters of the Resnet18 pre-trained model trained in Imagenet into the encoder part of U-Net to obtain a universal feature extractor. Use the pre-trained weights of ResNet-18 to initialize the encoder part of U-Net and extract high-level features. The formula is as follows: (8) in are the parameters of the pre-trained model, are the initial parameters of the target model inherited from the pre-trained model.
5. The water body segmentation optimization method based on transfer learning according to claim 1 is characterized in that: In step 4, include: 41) Divide the image dataset obtained after preprocessing in step 1 and the mask dataset obtained in step 2 into a training set and a test set according to a set ratio; 42) The data enhancement methods are used to enhance the training set. There are four data enhancement methods, including 15-degree and 30-degree rotation operations, horizontal flipping, vertical flipping and scaling.
6. The water body segmentation optimization method based on transfer learning according to claim 1 is characterized in that: In step 5, when training the constructed U-Net model using the enhanced training set, the batch size batch_size and the number of training epochs are set; the activation function of the hidden layer is relu, the activation function of the output layer is sigmoid, and the optimizer uses SGD; The loss function uses BinaryCross-EntropywithLogitsLoss. For a single data point, the binary cross entropy loss Defined as: (17) ; Where y is the true label and z is the logits output of the model, i.e. the predicted value before applying the sigmoid activation. is the sigmoid function.
7. The water body segmentation optimization method based on transfer learning according to claim 1 is characterized in that: In step 5, optimization processing is performed during the U-Net model training process. The entire U-Net model is trained using the target task dataset. The value of the loss function is gradually reduced through multiple iterations of forward propagation and back propagation, thereby learning the weights that can accurately predict the water body segmentation image. The weight formula is as follows: ; Among them, arg represents the weight value, min is the minimum value, L is the loss function, x is the input data of the model, y is the true label, f is the forward propagation function of the model, and f(x) is the output of the model. Represents the optimal weight value corresponding to minimizing the loss function L on the target data set.
8. The water body segmentation optimization method based on transfer learning according to claim 7 is characterized in that: In step 5, the optimization of the U-Net model includes the following steps: 531) Three different transfer learning methods are used for the U-Net model: 1) adjust the parameters of all layers and fully optimize the model to obtain a fully adjusted + U-Net model; 2) freeze the parameters of other layers in the model and only adjust the parameters of the output layer to obtain a partially adjusted + U-Net model; 3) first freeze the parameters of other layers in the model and only adjust the parameters of the output layer; then unfreeze the parameters of all layers except the output layer, and adjust all layers to obtain a layer-by-layer unfreeze adjustment + U-Net model; 532) Use the data-enhanced training set to perform forward propagation on the fully adjusted + U-Net model, the partially adjusted + U-Net model, and the layer-by-layer unfreezing adjusted + U-Net model, calculate their respective prediction values, and calculate the loss function L of the three adjustment models based on their respective prediction values and the true values of the corresponding sample data; 533) Using the calculated loss function, the gradient of the loss function to the U-Net model parameters is calculated through the back propagation algorithm, and the parameters of the model are updated according to the gradient descent algorithm to gradually reduce the loss function; 534) Repeat steps 532)-533) until the maximum number of training times is reached, and three adjusted and trained neural network models are obtained.
9. The water body segmentation optimization method based on transfer learning according to claim 1 is characterized in that: In step 6, include: 61) Using the three trained neural network models, the three adjustment strategies were tested using independent test sets, and the prediction categories of each model were calculated. The key indicators were obtained based on the number of correctly classified samples and the total number of samples of each model. 62) After the test is completed, record the key indicator values of each model and select the best performing model as the final adjusted deep learning model; 63) After selecting the best model, based on the preliminary experimental results, a grid search method is used to explore the hyperparameter space and adjust key hyperparameters, including learning rate, batch size, and number of training rounds. Multiple possible combinations of hyperparameter values are set to evaluate the impact of each combination on model performance.
10. The water body segmentation optimization method based on transfer learning according to claim 9, characterized in that: In step 63), for each hyperparameter combination, perform the following steps: 631) Use the training set to train the model; 632) At the end of each training cycle, use the validation set to evaluate model performance and record key metrics; 633) looping steps 631)-632) until all hyperparameter combinations are evaluated; 634) Organize and record the performance results for each hyperparameter combination, compare the model performance of different combinations, and identify the best performing hyperparameter combination.
Citation Information
Patent Citations
Ship segmentation method and system for remote sensing image based on transfer learning
CN109377501A
Image recognition method and system based on transfer learning and ResNet50 neural network
CN116824239A
Cardiac medicine image segmentation method and system for atrial septal occlusion patient
WO2021129234A1
Cited By
Image recognition transfer reinforcement learning method and device based on parameter fine tuning
CN122761130A