Water body segmentation optimization method based on transfer learning
By using a water segmentation optimization method based on transfer learning, the problem of data scarcity in water remote sensing image segmentation is solved, the training efficiency and segmentation accuracy of the model are optimized, and it is applicable to different water remote sensing image tasks.
Patent Information
- Application Number
- CN202411734326.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-11-29
AI Technical Summary
In water remote sensing image segmentation, water image data in the target domain is scarce, the training model has insufficient generalization performance in feature learning, and the computational resource requirements are high, which limits the application of the model in resource-constrained environments.
A water segmentation optimization method based on transfer learning is adopted, including data preprocessing, constructing an initial image dataset, calculating the normalized water index NDWI, designing the U-Net model architecture, data augmentation and gradient descent optimization. The U-Net model is trained and tuned by combining three transfer learning methods to optimize model performance.
This improved the training efficiency and water segmentation accuracy of the model in resource-constrained environments, reduced the need for data sample size, and enhanced the applicability and segmentation effect of the model.
Smart Images

Figure CN119723578B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a water body segmentation optimization method based on transfer learning, belonging to the field of remote sensing image processing. Background Technology
[0002] In the field of remote sensing image processing, water segmentation is a crucial task with significant applications in environmental monitoring, urban planning, and disaster management. However, the complexity of remote sensing images and the variability of water regions, especially with small sample datasets, often lead to unsatisfactory results for deep learning-based methods in water segmentation. Although training on large-scale datasets has proven to significantly improve model performance, the scarcity of data in practical applications poses a challenge to the implementation of this method. Therefore, optimizing the performance of water segmentation models under limited data sample conditions has become a key technical challenge that urgently needs to be overcome in this field.
[0003] Transfer learning, as a method that leverages existing knowledge to accelerate learning for new tasks, can effectively address the problem of insufficient samples in the target domain. Therefore, it demonstrates great potential in water segmentation tasks. By borrowing knowledge from the source domain, it can significantly improve the training efficiency and effectiveness 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 this invention is that in the practical application of water remote sensing image segmentation, water image data in the target domain is scarce, the generalization performance of the training model in feature learning is insufficient, and the computational resource requirements during training and inference are relatively high, which limits the application of the training model in resource-constrained environments.
[0005] To address the aforementioned technical problems, this 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 area, preprocess the image data, and construct an initial image dataset;
[0007] Step 2: Based on the standardized initial image dataset, calculate the Normalized Water Index (NDWI) to generate the corresponding mask image and form the initial mask dataset.
[0008] Step 3: Based on the characteristics of the initial dataset and the task requirements, select a pre-trained model and use the pre-trained model to design a U-Net model architecture suitable for transfer learning;
[0009] Step 4: Divide the initial dataset into a training set and a validation set, and perform data augmentation on the training set to expand it;
[0010] Step 5: Train the U-Net model pre-designed in Step 3) using the enhanced training set, and optimize the U-Net model by using gradient descent and combining it with three transfer learning methods to obtain three adjusted models;
[0011] Step 6: Evaluate the performance of the three tuned models on independent validation sets, compare them using key metrics, select the best-performing model as the tuned deep learning model, and further optimize the tuned deep learning model through multiple rounds of iterative training and parameter tuning.
[0012] Step 7: Input the original image data from the validation set into the optimized neural network model to obtain the segmented image after water body prediction optimization.
[0013] The aforementioned water segmentation optimization method based on transfer learning includes, in step 1:
[0014] 11) Acquire a dataset of visible light water images of a specific area using satellite imagery acquired through remote sensing technology;
[0015] 12) Use the standard score Z-score to detect outliers in the water body image dataset and remove them;
[0016] 13) Standardize the image data after cleaning in step 12) to a specific range.
[0017] The aforementioned water segmentation optimization method based on transfer learning includes, in step 12), the following:
[0018] 121) Given a set of water body image data of total number N, the pixel values of all images are combined into a one-dimensional array. The mean μ and standard deviation σ of the water body image dataset are calculated according to formula (1):
[0019] (1)
[0020] (2)
[0021] Where M is the total number of pixels in all images, It is the value of the j-th pixel. It is the square of the difference between each pixel value and the mean;
[0022] 122) Calculate the Z-Score for each image observation in the image dataset:
[0023] (3)
[0024] in, It is the Z-Score value of the j-th pixel. It is the original value of the j-th pixel. σ is the mean of all pixel values, and σ is the standard deviation of all pixel values.
[0025] 123) Set a threshold, 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 the threshold, mark the corresponding observation as an outlier and remove the outlier. After removing the outlier, re-evaluate the statistical characteristics of the data.
[0026] In the aforementioned water segmentation optimization method based on transfer learning, in step 13), for a given image data I, a two-dimensional array of grayscale images... and color image three-dimensional array The image data is normalized to the range [0, 1] using formula (4):
[0027] (4)
[0028] in It is normalized image data. It is the smallest pixel value in the original image data. It is the maximum pixel value in the original image data.
[0029] The aforementioned water segmentation optimization method based on transfer learning includes, in step 2:
[0030] 21) For a given original image, extract pixel values from the green and near-infrared bands of the original image, and scale each pixel value to between 0 and 1 using equation (5):
[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) Calculate the Normalized Difference Water Index (NDWI) using the normalized Green band and the normalized Near Infrared band (NIR), mapping pixel values to a range of -1 to 1 to generate an NDWI image within the range of -1 to 1. The formula is as follows:
[0034] (6)
[0035] Green indicates the green band, and NIR indicates the near-infrared band;
[0036] 23) Set a threshold. Based on the pixel values in the NDWI image, the parts of the NDWI image with pixel values greater than the threshold are regarded as water bodies, and the parts with pixel values less than the threshold are regarded as non-water bodies. Generate the corresponding mask image and form a mask dataset.
[0037] The aforementioned water segmentation optimization method based on transfer learning includes, in step 3:
[0038] 31) Based on the water image features of the initial dataset, ResNet-18 was selected as the pre-trained model. ResNet-18 consists of multiple residual blocks, including convolutional layers, batch normalization layers, and the sigmoid activation function. In ResNet-18, each residual block consists of two convolutional layers and one skip connection. Given an input x and the corresponding output H(x), the residual network learns the residual function F(x) and outputs it, as shown in the following formula:
[0039] (7)
[0040] 32) Construct a U-Net model architecture suitable for transfer learning, using ResNet-18 as the backbone network of the encoder part, and creating a decoder network that is 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. Skip connections are added to each layer of the decoder to fuse the feature maps of the encoder with the corresponding layers of the decoder. An output layer is added at the end of the decoder, and a binary or binary segmentation mask is generated using the Sigmoid activation function.
[0041] 33) Load all parameters of the ResNet18 pre-trained model trained on ImageNet into the encoder part of U-Net to obtain a general feature extractor. Initialize the encoder part of U-Net using the pre-trained weights of ResNet-18 to extract high-level features, as shown in the following formula:
[0042] (8)
[0043] in These are the parameters of the pre-trained model. These are the initial parameters that the target model inherits from the pre-trained model.
[0044] The aforementioned water segmentation optimization method based on transfer learning includes, in step 4:
[0045] 41) Divide the image dataset obtained after preprocessing in step 1 and the mask dataset obtained in step 2 into training set and test set respectively according to the set ratio;
[0046] 42) Data augmentation methods are used to augment the training set. There are four data augmentation methods, including 15-degree and 30-degree angle rotation, horizontal flip, vertical flip, and scaling.
[0047] In the aforementioned water segmentation optimization method based on transfer learning, in step 5, during the training of 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 is SGD.
[0048] The loss function used is Binary Cross-Entropy with LogitsLoss, which is a binary cross-entropy loss for a single data point. Defined as:
[0049] (17)
[0050]
[0051] Where y is the true label, and z is the model's logits output, i.e., the predicted value before applying sigmoid activation. It is the sigmoid function.
[0052] The aforementioned water segmentation optimization method based on transfer learning, in step 5, performs optimization processing during the U-Net model training process. The entire U-Net model is trained using the target task dataset, and the loss function value is gradually reduced through multiple iterations of forward and backward propagation, thereby learning weights that can accurately predict water segmentation images. The weight formula is as follows:
[0053]
[0054] Where 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. This represents the optimal weight value corresponding to minimizing the loss function L on the target dataset.
[0055] The aforementioned water segmentation optimization method based on transfer learning includes the following steps in step 5 for optimizing the U-Net model:
[0056] 531) Three different transfer learning methods were applied to the U-Net model: 1) Adjusting the parameters of all layers to fully optimize the model, resulting in a fully adjusted +U-Net model; 2) Freezing the parameters of other layers in the model and adjusting only the parameters of the output layer, resulting in a partially adjusted +U-Net model; 3) First freezing the parameters of other layers in the model and adjusting only the parameters of the output layer; then unfreezing the parameters of all layers except the output layer and adjusting all layers, resulting in a layer-by-layer unfreezing adjusted +U-Net model.
[0057] 532) Using the data-augmented training set, forward propagation was performed on the fully adjusted + U-Net model, the partially adjusted + U-Net model, and the layer-by-layer unfrozen adjusted + U-Net model respectively, and the predicted values were calculated. The loss function L of the three adjustment models was calculated based on the predicted values and the true values of the corresponding sample data.
[0058] 533) Using the calculated loss function, the gradient of the loss function with respect to the parameters of the U-Net model is calculated through the backpropagation algorithm. The parameters of the model are then updated according to the gradient descent algorithm, so that the loss function gradually decreases.
[0059] 534) Repeat steps 532)-533) until the maximum number of training iterations is reached, resulting in three adjusted and trained neural network models.
[0060] The aforementioned water segmentation optimization method based on transfer learning includes, in step 6:
[0061] 61) Using the three trained neural network models, test the models of the three tuning strategies using independent test sets, calculate the predicted category of each model, and derive key indicators based on the number of correctly classified samples of each model and the total number of samples.
[0062] 62) After the test is completed, record the key metric 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, the hyperparameter space is explored using the grid search method, and key hyperparameters are adjusted. Key hyperparameters include learning rate, batch size, and number of training epochs. Multiple possible combinations of hyperparameter values are set, and the impact of each combination on model performance is evaluated.
[0064] In the aforementioned water segmentation optimization method based on transfer learning, step 63) involves performing the following steps for each hyperparameter combination:
[0065] 631) Train the model using the training set;
[0066] 632) At the end of each training cycle, evaluate the model performance using the validation set and record key metrics;
[0067] 633) Repeat steps 631)-632) until all hyperparameter combinations have been evaluated.
[0068] 634) Organize and record the performance results corresponding to each hyperparameter combination, compare the model performance of different combinations, and identify the best-performing hyperparameter combination.
[0069] The beneficial effects achieved by this invention are as follows: The method of this invention uses a neural network model to fit water remote sensing data and employs transfer learning to adjust the neural network model. This solves the problem of insufficient model generalization ability caused by insufficient data sample size in water remote sensing image segmentation, reduces the need for data sample size, improves the efficiency of model training, has good applicability, and can be applied to different water remote sensing image segmentation tasks. Furthermore, by optimizing the network structure and parameters, the performance and segmentation accuracy of the neural network model are improved. Attached Figure Description
[0070] Figure 1 This is a flowchart of the water body segmentation optimization method based on transfer learning in Embodiment 1 of the present invention;
[0071] Figure 2 This is the histogram after data cleaning in Embodiment 1 of the present invention;
[0072] Figure 3 This is a schematic diagram of the normalized water index (NDWI) processing in Embodiment 1 of the present invention;
[0073] Figure 4 This is a diagram of the optimized neural network model constructed in Embodiment 1 of the present invention;
[0074] Figure 5 This is a schematic diagram of the pre-training and adjustment architecture in Embodiment 1 of the present invention;
[0075] Figure 6 This is a schematic diagram of the data augmentation strategy in Embodiment 1 of the present invention;
[0076] Figure 7 This is a training loss diagram of the fully adjusted +U-Net model in Embodiment 1 of the present invention;
[0077] Figure 8 This is a partial adjustment of the training loss diagram of the U-Net model in Embodiment 1 of the present invention;
[0078] Figure 9 This is a training loss diagram of the U-Net model in Embodiment 1 of the present invention, showing the gradual unfreezing and adjustment process.
[0079] Figure 10This is a training accuracy curve of the fully adjusted +U-Net model in Embodiment 1 of the present invention;
[0080] Figure 11 This is a graph showing the training accuracy of the partially adjusted +U-Net model in Embodiment 1 of the present invention.
[0081] Figure 12 This is a graph showing the training accuracy of the U-Net model in Embodiment 1 of the present invention, where the model is gradually thawed and adjusted.
[0082] Figure 13 This is a water body prediction image output by the method applied in Embodiment 1 of the present invention. Detailed Implementation
[0083] The method of the present invention will be 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: Acquire visible light remote sensing image data of water bodies in the target area, preprocess the image data, and construct an initial image dataset, including:
[0087] 11) A dataset of visible light water images of a specific area was acquired using satellite imagery acquired through remote sensing technology, including images of scenes such as rivers, lakes, and oceans, totaling 2,800 images;
[0088] 12) Use Z-score (standard score) to detect outliers in the water body image dataset and remove them;
[0089] 121) Given a set of water body image data of total number N, the pixel values of all images are combined into a one-dimensional array. The mean μ and standard deviation σ of the water body image dataset are calculated according to formula (1):
[0090] (1)
[0091] (2)
[0092] Where M is the total number of pixels in all images, It is the value of the j-th pixel. It is the square of the difference between each pixel value and the mean;
[0093] 122) Calculate the Z-Score for each image observation in the image dataset:
[0094] (3)
[0095] in, It is the Z-Score value of the j-th pixel. It is the original value of the j-th pixel. σ is the mean of all pixel values, and σ is the standard deviation of all pixel values.
[0096] 123) Set a threshold of 3. Compare the Z-Score value of each data point with the threshold. If the absolute value of the Z-Score is greater than 3, mark the corresponding observation as an outlier and remove it. After removing the outliers, re-evaluate the statistical characteristics of the data, plot a histogram, and compare the pixel value distribution before and after outlier removal. Figure 2 As shown, the x-axis of the histogram represents pixel values, and the y-axis represents the frequency of the corresponding pixel values.
[0097] 13) Standardize the image data after cleaning in step 12) to a specific range, which in this embodiment is 0 to 1:
[0098] For a given image data I, a two-dimensional array of grayscale images and color image three-dimensional array The image data is normalized to the range [0, 1] using formula (4):
[0099] (4)
[0100] in It is normalized image data. It is the smallest pixel value in the original image data. It is the maximum pixel value in the original image data.
[0101] Step 2: Based on the standardized initial image dataset, calculate the Normalized Water Index (NDWI) to generate the corresponding mask image, forming the initial mask dataset. This includes 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 scale each pixel value to between 0 and 1 using equation (5):
[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) Calculate the Normalized Difference Water Index (NDWI) using the normalized Green band and the normalized Near Infrared band (NIR), mapping pixel values to a range of -1 to 1 to generate an NDWI image within the range of -1 to 1. The formula is as follows:
[0106] (6)
[0107] Green indicates the green band, and NIR indicates the near-infrared band;
[0108] 23) With a preset threshold of 0.5, based on the pixel values in the NDWI image, pixels with values greater than the threshold are considered water bodies, and pixels with values less than the threshold are considered non-water bodies. Figure 3 As shown, the corresponding mask image is generated, forming a mask dataset.
[0109] Step 3: Based on the characteristics of the initial dataset and task requirements, select a suitable pre-trained model and design a U-Net model architecture suitable for transfer learning using the pre-trained model, including the following steps:
[0110] 31) Based on the water image features of the initial dataset, ResNet-18 (Residual Network-18) was selected as the pre-trained model. ResNet-18 consists of multiple residual blocks, including convolutional layers, batch normalization layers, and the sigmoid activation function. In ResNet-18, each residual block consists of two convolutional layers and one skip connection. Given an input x and the corresponding output H(x), the residual network learns the residual function F(x) and outputs it, as shown in the following formula:
[0111] (7)
[0112] 32) Construct a U-Net model architecture suitable for transfer learning, such as... Figure 4 As shown, 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 gradually upsamples the image that has been downsampled by the encoder to restore the original size and details of the image. Skip connections are added to each layer of the decoder to fuse the feature maps of the encoder with the corresponding layers of the decoder. An output layer is added at the end of the decoder, and a binary or binary segmentation mask is generated using the Sigmoid activation function.
[0113] 33) Load all parameters from the pre-trained ResNet18 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, as expressed in the following formula:
[0114] (8)
[0115] in These are the parameters of the pre-trained model. These are the initial parameters that the target model inherits from the pre-trained model.
[0116] Step 4: Divide the initial dataset into a training set and a validation set, and perform data augmentation on the training set to expand it, including:
[0117] 41) Divide the image dataset obtained after preprocessing in step 1 and the mask dataset obtained in step 2 into training set and validation set respectively in an 8:2 ratio;
[0118] 42) For example Figure 6 As shown, data augmentation methods are used to augment the training set. There are four data augmentation methods in total, 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 θ, and move one pixel ( , As a rotation around the origin pixel The pixel at the corner, after rotation, is ( , By rotating the image around the center point (0, 0), the rotation formula is as follows:
[0120] (9)
[0121] (10)
[0122] in,( , ) are the original coordinates, ( , () are the rotated coordinates. It is the rotation angle, which can be set to 15 degrees or 30 degrees;
[0123] The formula for vertical flipping around the x-axis is as follows:
[0124] (11)
[0125] (12)
[0126] in,( , ) are the original coordinates, ( , () are the coordinates after vertical flipping;
[0127] To flip horizontally around the y-axis, the formula for horizontal flipping is as follows:
[0128] (13)
[0129] (14)
[0130] in,( , ) are the original coordinates, ( , () are the coordinates after horizontal flipping;
[0131] Scaling, for a point ( , ), scaled point ( , ) is calculated using the following formula:
[0132] (15)
[0133] (16)
[0134] ( , ) are the original coordinates, ( , ) are the scaled coordinates, and s is the scaling factor.
[0135] Step 5: Train the pre-designed U-Net model from Step 3) using the enhanced training set. Optimize the U-Net model using gradient descent combined with three transfer learning methods to obtain three adjusted models, including:
[0136] 51) Train the constructed U-Net model using the enhanced training set, with a batch size of 16 and 150 training epochs; the activation function of the hidden layer is ReLU, the activation function of the output layer is Sigmoid, and the optimizer is SGD.
[0137] 52) The loss function used is Binary Cross-Entropy with LogitsLoss. For a single data point, the binary cross-entropy loss is applied. Defined as:
[0138] (17)
[0139]
[0140] Where y is the true label, and z is the model's logits output, i.e., the predicted value before applying sigmoid activation. It is the sigmoid function.
[0141] 53) The entire U-Net model is trained using the dataset for the target task and three different transfer learning methods. The loss function is gradually reduced through multiple iterations of forward and backward propagation, thereby learning weights that can accurately predict water segmentation images. The weight formula is as follows:
[0142]
[0143] Where 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. This represents the optimal weight value corresponding to minimizing the loss function L on the target dataset.
[0144] 531) For example Figure 5 As shown, three different transfer learning methods were applied to the U-Net model: 1) Fully tuned: The parameters of all layers were adjusted to fully optimize the model, resulting in a fully tuned + U-Net model; 2) Partially tuned: The parameters of other layers in the model were frozen, and only the parameters of the output layer were adjusted, resulting in a partially tuned + U-Net model; 3) Layer-by-layer unfreezing tuned: The parameters of other layers in the model were first frozen, and only the parameters of the output layer were adjusted; then the parameters of all layers except the output layer were unfrozen, and all layers were tuned, resulting in a layer-by-layer unfreezing tuned + U-Net model.
[0145] 532) Using the data-augmented training set, forward propagation is performed on the fully adjusted + U-Net model, the partially adjusted + U-Net model, and the layer-by-layer unfrozen adjusted + U-Net model, respectively. The predicted values for each model are calculated, and the loss function L for the three adjustment models is calculated based on their predicted values and the corresponding true values of the sample data. The training loss diagram for the fully adjusted + U-Net model is shown below. Figure 7 As shown, the training loss graph for partial adjustment + U-Net model adjustment is as follows. Figure 8 As shown, the training loss diagram for layer-by-layer unfreezing and adjustment + U-Net model adjustment is as follows: Figure 9 As shown;
[0146] 533) Using the calculated loss function, the gradient of the loss function with respect to the U-Net model parameters is calculated through backpropagation. The model parameters are then updated using gradient descent, gradually reducing the loss function. Figure 7 , Figure 8 and Figure 9 It can be seen that during the training of the three models—fully tuned +U-net model, partially tuned +U-net model, and layer-by-layer unfrozen tuned +U-net model—the loss function values all showed a similar downward trend and eventually 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 iterations is reached, resulting in three adjusted and trained neural network models.
[0148] Step 6: Evaluate the performance of the three tuned models on independent validation sets, compare them using key metrics, select the best-performing model as the tuned deep learning model, and further optimize the tuned deep learning model through multiple rounds of iterative training and parameter tuning to improve the water segmentation effect.
[0149] 61) Using the three trained neural network models, evaluate the models of the three tuning strategies using independent validation sets, calculate the predicted category of each model, and derive key indicators based on the number of correctly classified samples and the total number of samples for each model.
[0150] 62) After the evaluation, record the key performance indicators (KPIs) for each model. The training accuracy curve for the fully tuned +U-Net model is shown in the figure below. Figure 10 As shown in the figure, the training accuracy curves of partial adjustment + U-Net model adjustment are as follows: Figure 11 As shown in the figure, the accuracy curve of the U-Net model training is as follows: (The text repeats itself here, so the translation will only include the first instance.) Figure 12 As shown, by comparing the numerical values of accuracy, the model with the best performance 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 is used to systematically explore the hyperparameter space, adjust key hyperparameters, including learning rate, batch size, and number of training epochs, set possible combinations of multiple hyperparameter values, and evaluate the impact of each combination on model performance.
[0152] For each combination of hyperparameters, perform the following steps:
[0153] 631) Train the model using the training set;
[0154] 632) At the end of each training cycle, evaluate the model performance using the validation set and record key metrics;
[0155] 633) Repeat steps 631)-632) until all hyperparameter combinations have been evaluated.
[0156] 634) Organize and record the performance results corresponding to each hyperparameter combination, compare the model performance of different combinations, and identify the best-performing hyperparameter combination.
[0157] By optimizing the key performance indicators, the water segmentation model is further adjusted to optimize model performance and segmentation effect.
[0158] Step 7: Input the original image data from the validation set into the optimized neural network model to obtain the segmented image after water body prediction optimization, such as... Figure 13 As shown.
[0159] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0160] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0161] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0162] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0163] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A water body segmentation optimization method based on transfer learning, characterized in that, Includes the following steps: Step 1: Collect visible light remote sensing water body image data of the target area, preprocess the image data, and construct a standardized initial image dataset; Step 2: Based on the standardized initial image dataset, calculate the Normalized Water Index (NDWI) to generate the corresponding mask image and form the initial mask dataset. Step 3: Based on the characteristics of the initial dataset and the task requirements, select a pre-trained model and use the pre-trained model to design a U-Net model architecture suitable for transfer learning; Step 4: Divide the initial dataset into a training set and a test set, and perform data augmentation on the training set; Step 5: Train the U-Net model designed in Step 3) using the enhanced training set. Optimize the U-Net model using gradient descent combined with three transfer learning methods to obtain three adjusted models: 1) Adjust the parameters of all layers to fully optimize the model, resulting in a fully adjusted + U-Net model; 2) Freeze the parameters of other layers in the model and adjust only the parameters of the output layer, resulting in a partially adjusted + U-Net model; 3) First, freeze the parameters of other layers in the model and adjust only the parameters of the output layer; then unfreeze the parameters of all layers except the output layer and adjust all layers, resulting in a layer-by-layer unfreezing adjusted + U-Net model. Step 6: Evaluate the performance of the three tuned models on independent test sets, compare them using key metrics, select the best-performing model as the tuned deep learning model, and further optimize the tuned deep learning model through multiple rounds of iterative training and parameter tuning. Step 7: Input the original image data from the test set into the optimized neural network model to obtain the segmented image after water body prediction optimization.
2. The water body segmentation optimization method based on transfer learning according to claim 1, characterized in that, Step 1 includes: 11) Acquire a dataset of visible light water images of a specific area using satellite imagery acquired through remote sensing technology; 12) Use the standard score Z-score to detect outliers in the water body image dataset and remove them; 13) Standardize the image data after cleaning in step 12) to a specific range; Step 12) includes: 121) Given a set of water body image data of total number N, the pixel values of all images are combined into a one-dimensional array. The mean μ and standard deviation σ of the water body image dataset are calculated according to formula (1): (1); (2); Where M is the total number of pixels in all images, It is the value of the j-th pixel. It is the square of the difference between each pixel value and the mean; 122) Calculate the Z-Score for each image observation in the image dataset: (3); in, It is the Z-Score value of the j-th pixel. It is the original value of the j-th pixel. σ is the mean of all pixel values, and σ is the standard deviation of all pixel values. 123) Set a threshold, 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 the threshold, mark the corresponding observation as an outlier and remove the outlier. After removing the outlier, re-evaluate the statistical characteristics of the data.
3. The water body segmentation optimization method based on transfer learning according to claim 2, characterized in that, In step 13), for a given image data I, a two-dimensional array of grayscale images... and color image three-dimensional array The image data is normalized to the range [0, 1] using formula (4): (4); in It is normalized image data. It is the smallest pixel value in the original image data. It is the maximum pixel value in the original image data; Step 2 includes: 21) For a given original image, extract pixel values from the green and near-infrared bands of the original image, and scale each pixel value to between 0 and 1 using equation (5): (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) Calculate the Normalized Water Index (NDWI) using the normalized Green band and the normalized Near-Infrared band (NIR), mapping pixel values to a range of -1 to 1 to produce an NDWI image within the range of -1 to 1. The formula is as follows: (6); Green indicates the green band, and NIR indicates the near-infrared band; 23) Set a threshold. Based on the pixel values in the NDWI image, the parts of the NDWI image with pixel values greater than the threshold are regarded as water bodies, and the parts with pixel values less than the threshold are regarded as non-water bodies. Generate the corresponding mask image and form a mask dataset.
4. The water body segmentation optimization method based on transfer learning according to claim 1, characterized in that, Step 3 includes: 31) Based on the water image features of the initial dataset, ResNet-18 was selected as the pre-trained model. ResNet-18 consists of multiple residual blocks, including convolutional layers, batch normalization layers, and the sigmoid activation function. In ResNet-18, each residual block consists of two convolutional layers and one skip connection. Given an input x and the corresponding output H(x), the residual network learns the residual function F(x) and outputs it, as shown in the following formula: (7); 32) Construct a U-Net model architecture suitable for transfer learning, using ResNet-18 as the backbone network of the encoder part, and creating a decoder network that is 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. Skip connections are added to each layer of the decoder to fuse the feature maps of the encoder with the corresponding layers of the decoder. An output layer is added at the end of the decoder, and a binary or binary segmentation mask is generated using the Sigmoid activation function. 33) Load all parameters of the ResNet18 pre-trained model trained on ImageNet into the encoder part of U-Net to obtain a general feature extractor. Initialize the encoder part of U-Net using the pre-trained weights of ResNet-18 to extract high-level features, as shown in the following formula: (8); in These are the parameters of the pre-trained model. These are the initial parameters that the target model inherits from the pre-trained model.
5. The water body segmentation optimization method based on transfer learning according to claim 1, characterized in that, Step 4 includes: 41) Divide the image dataset obtained after preprocessing in step 1 and the mask dataset obtained in step 2 into training set and test set respectively according to the set ratio; 42) Data augmentation methods are used to augment the training set. There are four data augmentation methods, including 15-degree and 30-degree angle rotation, horizontal flip, vertical flip and scaling.
6. The water body segmentation optimization method based on transfer learning according to claim 1, characterized in that, In step 5, during the training of 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 is SGD. The loss function used is Binary Cross-Entropy with LogitsLoss, which is a binary cross-entropy loss for a single data point. Defined as: (17); ; Where y is the true label, and z is the model's logits output, i.e., the predicted value before applying sigmoid activation. It is the sigmoid function.
7. The water body segmentation optimization method based on transfer learning according to claim 1, characterized in that, In step 5, optimization is performed during the U-Net model training process. The entire U-Net model is trained using the dataset of the target task. The loss function is gradually reduced through multiple iterations of forward and backward propagation, thereby learning the weights that can accurately predict water segmentation images. The weight formula is as follows: ; Where 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. This represents the optimal weight value corresponding to minimizing the loss function L on the target dataset.
8. The water body segmentation optimization method based on transfer learning according to claim 7, characterized in that, Step 5, optimizing the U-Net model also includes the following steps: 532) Using the data-augmented training set, forward propagation was performed on the fully adjusted + U-Net model, the partially adjusted + U-Net model, and the layer-by-layer unfrozen adjusted + U-Net model respectively, and the predicted values were calculated. The loss function L of the three adjustment models was calculated based on the predicted values and the true values of the corresponding sample data. 533) Using the calculated loss function, the gradient of the loss function with respect to the parameters of the U-Net model is calculated through the backpropagation algorithm. The parameters of the model are then updated according to the gradient descent algorithm, so that the loss function gradually decreases. 534) Repeat steps 532)-533) until the maximum number of training iterations is reached, resulting in three adjusted and trained neural network models.
9. The water body segmentation optimization method based on transfer learning according to claim 1, characterized in that, Step 6 includes: 61) Using the three trained neural network models, test the models of the three tuning strategies using independent test sets, calculate the predicted category of each model, and derive key indicators based on the number of correctly classified samples of each model and the total number of samples. 62) After the test is completed, record the key metric 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, the hyperparameter space is explored using the grid search method, and key hyperparameters are adjusted. Key hyperparameters include learning rate, batch size, and number of training epochs. Multiple possible combinations of hyperparameter values are set, and the impact of each combination on model performance is evaluated.
10. The water body segmentation optimization method based on transfer learning according to claim 9, characterized in that, In step 63), for each combination of hyperparameters, the following steps are performed: 631) Train the model using the training set; 632) At the end of each training cycle, evaluate the model performance using the test set and record key metrics; 633) Repeat steps 631)-632) until all hyperparameter combinations have been evaluated; 634) Organize and record the performance results corresponding to 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