Urban inland inundation range identification method based on YOLOv8
Through the urban flooding range identification method based on YOLOv8, the problems of high error detection rate and insufficient timeliness in the existing technology are solved, and the identification effect with higher accuracy and real-timeness is achieved.
Patent Information
- Application Number
- CN202411650899.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-03-11
AI Technical Summary
The prior art has high false detection rate and insufficient timeliness in urban flooding range identification, making it difficult to achieve accurate and rapid identification.
The urban flooding range identification method based on YOLOv8 is adopted, and the attention mechanism and multi-scale cavity convolution are introduced through data set screening and preprocessing, and the anchor box is dynamically adjusted to improve the model's feature extraction ability and detection segmentation accuracy.
It significantly improves the accuracy and real-timeness of urban flooding identification, can identify water area and boundary information more accurately, and reduce the false detection rate.
Smart Images

Figure CN119600444A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of urban waterlogging range identification, and in particular to an urban waterlogging range identification method based on YOLOv8. Background Art
[0002] Accurately and quickly identifying the inundation range of urban floods is of great significance for urban flood disaster assessment and disaster prevention and mitigation. In the past few decades, remote sensing satellite technology has been widely used in water body identification. Large-scale water body identification based on remote sensing images is limited by low spatial resolution and temporal resolution and the influence of extreme weather. It is difficult to capture small and complex street patterns and local water distribution, which further limits the accurate real-time detection of dynamic changes in water bodies at the urban road level and cannot fully meet the needs of urban waterlogging range identification.
[0003] With the rapid development of science and technology and the widespread coverage and application of mobile Internet and 5G technology, surveillance cameras with high temporal resolution are widely deployed in cities, with sufficient density and high spatial coverage, providing wide spatial coverage for flood monitoring. At the same time, citizens around the world are increasingly playing the role of "human sensors". They collect and share millions of flood image data on social media platforms to record the scale, degree of damage and social impact of flood disasters in detail. The combination of deep learning technology and urban cameras can more effectively realize the accurate and rapid identification of urban waterlogging scope. Traditional research mainly uses semantic segmentation to realize flood water body scope recognition, but compared with instance segmentation, it cannot achieve refined recognition, lacks water body boundary information, and is prone to errors. Therefore, a method for urban waterlogging scope recognition based on the YOLOv8 network model is proposed to address the above problems. Summary of the invention
[0004] Purpose of the invention: In view of the shortcomings of the prior art, the present invention provides a method for identifying the scope of urban waterlogging based on YOLOv8, which solves the problems of high false detection rate and insufficient timeliness in the current prior art for identifying the scope of urban waterlogging, and improves the accuracy of urban waterlogging identification.
[0005] The technical solution adopted by the present invention is: a method for identifying the scope of urban waterlogging based on YOLOv8, comprising the following steps:
[0006] Step 1, by using the Google search engine, filter the retrieved images on the web page to determine the dataset to be used;
[0007] Step 2, preprocess the constructed data set;
[0008] Step 3, process the constructed dataset and use the labelme annotation tool to annotate all images in the dataset;
[0009] Step 4, data set division, divide the labeled urban waterlogging data set into training set and test set in a ratio of 9:1;
[0010] Step 5, improve the YOLOv8 model;
[0011] Step 6, train the YOLOv8-seg network models with different configurations respectively;
[0012] Step 7: Test the trained YOLOv8-seg model in complex scenarios.
[0013] Step 8: Evaluate the applicability of each model for different application scenarios based on the parameter quantity and test accuracy of the YOLOv8-seg network model with different configurations.
[0014] Furthermore, the Step 1 is specifically as follows:
[0015] Step 1.1: Obtain relevant images of urban waterlogging by using web crawler method and Geogle search engine with “urban waterlogging” as the keyword;
[0016] Step 1.2: Screen the collected images to ensure that the entire dataset contains daytime, nighttime, and blurred scenes, and covers images from all perspectives, ultimately obtaining 2,400 different images of urban flooding.
[0017] Furthermore, the Step 2 is specifically as follows:
[0018] Step 2.1: Perform image enhancement operations on the input image data, including random brightness adjustment, random contrast adjustment, random saturation adjustment and random geometric transformation; among them, the brightness adjustment amplitude is randomly selected between [-0.2, 0.2], the contrast adjustment amplitude is randomly selected between [0.8, 1.2], and the saturation adjustment amplitude is randomly selected between [0.8, 1.2]; the rotation angle is randomly selected between [-15°, 15°], the scaling ratio is randomly selected between [0.8, 1.2], the translation amount is randomly selected within the range of [-5%, 5%] of the image width and height, and the flip operation is randomly performed with a probability of 0.5;
[0019] Step 2.2: Adopt an adaptive image scaling strategy. According to the aspect ratio of the image and the preset standard size, calculate the scaling ratio so that the long side is scaled to close to the standard size and the short side is scaled proportionally, while keeping the original aspect ratio of the image unchanged to avoid image distortion; the standard size is set to [640,640]; use Gaussian blur to preprocess the image with a Gaussian kernel size of 3×3 and a standard deviation of 1.5 to reduce the impact of image noise on subsequent detection and segmentation.
[0020] Furthermore, the Step 3 is specifically as follows:
[0021] Step 3.1: Use labelme to label 2,400 urban waterlogging images:
[0022] Create a folder named flood_data, and create two folders, image and labels, in the folder to store 2,400 images and their corresponding labels. Make sure that the only target in the image is water, which is defined as water.
[0023] Step 3.2: Process the annotation file generated by the labelme annotation tool and convert it into a txt format file suitable for model training.
[0024] Furthermore, the Step 4 is specifically as follows:
[0025] Step 4.1: First, the experimental dataset needs to be processed. The dataset is evenly divided into 10 independent folds; each fold serves as a test set during one round of training, while the remaining 9 folds are combined and used as training sets; each combination is divided into training sets and test sets in a ratio of 9:1;
[0026] Step 4.2: In addition, the first 800, 1600, and 2400 images of the 2400 dataset are divided; and the dataset of each size is divided into training set and test set in a ratio of 9:1.
[0027] Furthermore, the Step 5 is specifically as follows:
[0028] Step 5.1: Introduce an attention mechanism module into the backbone network of YOLOv8, specifically a hybrid attention mechanism CBAM based on channel and spatial dimensions; this module first assigns weights to each channel of the input feature map through the channel attention submodule to highlight important channel features; in the channel attention submodule, first perform global average pooling and global maximum pooling on the input feature map to obtain two 1×1×12 feature vectors, and then send these two feature vectors to a shared multi-layer perceptron MLP, which contains a hidden layer with 4 neurons. The output is two processed feature vectors, which are then added and activated by the Sigmoid function to obtain the channel attention weight vector, and finally the weight vector is multiplied by the input feature map to obtain the feature map after channel attention adjustment; then, The spatial attention submodule is used to distribute weights on the feature map after channel attention adjustment in the spatial dimension, focusing on important spatial areas. In the spatial attention submodule, the feature map after channel attention adjustment is sequentially passed through a convolution-based dimensionality reduction layer (convolution kernel size is 3×3, step size is 1, padding is 1, and the number of output channels is 1), a Sigmoid function activation layer, and a convolution-based dimensionality increase layer (convolution kernel size is 3×3, step size is 1, padding is 1, and the number of output channels is 1) to obtain a spatial attention weight map. Finally, the spatial attention weight map is multiplied with the feature map after channel attention adjustment to obtain the final feature map adjusted by the attention mechanism. In this way, the model can more effectively focus on the features of the target area, suppress the interference of irrelevant information such as background, and improve the model's feature extraction capability and detection segmentation accuracy.
[0029] Step5.2: Improve the neck structure of YOLOv8, and adopt a structure based on feature pyramid fusion and multi-scale dilated convolution. First, construct a multi-scale feature pyramid, upsample and downsample the feature maps output at different stages of the backbone network to make them have the same resolution, and then perform feature fusion. Upsampling uses the nearest neighbor interpolation method, and downsampling uses a convolution operation with a step size of 2. After feature fusion, introduce a multi-scale dilated convolution module, which contains three dilated convolution layers with different dilation rates (the dilation rates are 1, 3, and 5, the convolution kernel size is 3×3, the step size is 1, and the filling is the dilation rate). Perform convolution operations on the fused feature maps to obtain target feature information under different receptive fields and enhance the model's adaptability to targets of different scales.
[0030] Step 5.3: Improve the detection head of YOLOv8 and adopt a dynamic anchor frame generation strategy. During the training process, dynamically adjust the size and proportion of the anchor frame according to the actual size distribution of the target object in the current batch data. The specific calculation method is to first count the width and height of the target object in the current batch data, calculate its average and standard deviation, and then determine the initial size range of the anchor frame according to the average and standard deviation. On this basis, cluster the size of the target object through the K-Means++ algorithm to obtain K cluster centers (K is set to 9), each cluster center corresponds to the size and proportion of an anchor frame. The anchor frame generated in this way can better adapt to the size changes of target objects in different data sets and different scenarios, and improve the accuracy of detection.
[0031] Furthermore, the Step 6 is specifically as follows:
[0032] Step 6.1: Train YOLOv8 on the 10 independent folded data sets respectively; output the test results of urban waterlogging;
[0033] Step 6.2: Train the YOLOv8 model again according to the data sets of different sizes 800, 1600, and 2400 divided in Step 4.2.
[0034] Furthermore, the Step 7 is specifically as follows:
[0035] Step 7.1: Based on the training results of Step 6.1, perform 10-fold cross-training on YOLOv8 to find the model with the smallest test set estimation error;
[0036] Step 7.2: Collect 100 images of urban waterlogging in complex scenarios, including blurred and damaged images, decentralized flood-inundated areas, and blurred scenes at night; test the model in Step 7.1; and finally verify the model’s recognition effect on waterlogging in special scenarios.
[0037] Beneficial effects: The present invention uses instance segmentation technology to identify the scope of urban waterlogging. Through K-fold cross-validation experiments, sample size experiments, and complex scene tests, the effectiveness of our method in identifying the scope of urban waterlogging is verified. It can finely identify the area of water bodies and more easily capture the boundary information of water bodies. The accuracy and real-time performance of urban waterlogging scope identification are greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 This is a flow chart of urban waterlogging range identification based on YOLOv8 of the present invention. DETAILED DESCRIPTION
[0039] The technical solutions in the specific embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the specific embodiments of the present invention.
[0040] like Figure 1 As shown, a method for identifying urban waterlogging range based on YOLOv8 includes the following steps:
[0041] Step 1, by using the Google search engine, filter the retrieved images on the web page to determine the dataset to be used;
[0042] Specifically:
[0043] Step 1.1: Obtain relevant images of urban waterlogging by using web crawler method and Geogle search engine with “urban waterlogging” as the keyword;
[0044] Step 1.2: Screen the collected images to ensure that the entire dataset contains daytime, nighttime, and blurred scenes, and covers images from all perspectives, ultimately obtaining 2,400 different images of urban flooding.
[0045] Step 2, preprocess the constructed data set;
[0046] Specifically:
[0047] Step 2.1: Perform image enhancement operations on the input image data, including random brightness adjustment, random contrast adjustment, random saturation adjustment and random geometric transformation; among them, the brightness adjustment amplitude is randomly selected between [-0.2, 0.2], the contrast adjustment amplitude is randomly selected between [0.8, 1.2], and the saturation adjustment amplitude is randomly selected between [0.8, 1.2]; the rotation angle is randomly selected between [-15°, 15°], the scaling ratio is randomly selected between [0.8, 1.2], the translation amount is randomly selected within the range of [-5%, 5%] of the image width and height, and the flip operation is randomly performed with a probability of 0.5;
[0048] Step 2.2: Adopt an adaptive image scaling strategy. According to the aspect ratio of the image and the preset standard size, calculate the scaling ratio so that the long side is scaled to close to the standard size and the short side is scaled proportionally, while keeping the original aspect ratio of the image unchanged to avoid image distortion; the standard size is set to [640,640]; use Gaussian blur to preprocess the image with a Gaussian kernel size of 3×3 and a standard deviation of 1.5 to reduce the impact of image noise on subsequent detection and segmentation.
[0049] Step 3, process the constructed dataset and use the labelme annotation tool to annotate all images in the dataset;
[0050] Specifically:
[0051] Step 3.1: Use labelme to label 2,400 urban waterlogging images:
[0052] Create a folder named flood_data, and create two folders, image and labels, in the folder to store 2,400 images and their corresponding labels. Make sure that the only target in the image is water, which is defined as water.
[0053] Step 3.2: Process the annotation file generated by the labelme annotation tool and convert it into a txt format file suitable for model training.
[0054] Step 4, data set division, divide the labeled urban waterlogging data set into training set and test set in a ratio of 9:1;
[0055] Specifically:
[0056] Step 4.1: First, the experimental dataset needs to be processed. The dataset is evenly divided into 10 independent folds; each fold serves as a test set during one round of training, while the remaining 9 folds are combined and used as training sets; each combination is divided into training sets and test sets in a ratio of 9:1;
[0057] Step 4.2: In addition, the first 800, 1600, and 2400 images of the 2400 dataset are divided; and the dataset of each size is divided into training set and test set in a ratio of 9:1.
[0058] Step 5, improve the YOLOv8 model;
[0059] Specifically:
[0060] Step 5.1: Introduce an attention mechanism module into the backbone network of YOLOv8, specifically a hybrid attention mechanism CBAM based on channel and spatial dimensions; this module first assigns weights to each channel of the input feature map through the channel attention submodule to highlight important channel features; in the channel attention submodule, first perform global average pooling and global maximum pooling on the input feature map to obtain two 1×1×12 feature vectors, and then send these two feature vectors to a shared multi-layer perceptron MLP, which contains a hidden layer with 4 neurons. The output is two processed feature vectors, which are then added and activated by the Sigmoid function to obtain the channel attention weight vector, and finally the weight vector is multiplied by the input feature map to obtain the feature map after channel attention adjustment; then, The spatial attention submodule is used to distribute weights on the feature map after channel attention adjustment in the spatial dimension, focusing on important spatial areas. In the spatial attention submodule, the feature map after channel attention adjustment is sequentially passed through a convolution-based dimensionality reduction layer (convolution kernel size is 3×3, step size is 1, padding is 1, and the number of output channels is 1), a Sigmoid function activation layer, and a convolution-based dimensionality increase layer (convolution kernel size is 3×3, step size is 1, padding is 1, and the number of output channels is 1) to obtain a spatial attention weight map. Finally, the spatial attention weight map is multiplied with the feature map after channel attention adjustment to obtain the final feature map adjusted by the attention mechanism. In this way, the model can more effectively focus on the features of the target area, suppress the interference of irrelevant information such as background, and improve the model's feature extraction capability and detection segmentation accuracy.
[0061] Step5.2: Improve the neck structure of YOLOv8, and adopt a structure based on feature pyramid fusion and multi-scale dilated convolution. First, construct a multi-scale feature pyramid, upsample and downsample the feature maps output at different stages of the backbone network to make them have the same resolution, and then perform feature fusion. Upsampling uses the nearest neighbor interpolation method, and downsampling uses a convolution operation with a step size of 2. After feature fusion, introduce a multi-scale dilated convolution module, which contains three dilated convolution layers with different dilation rates (the dilation rates are 1, 3, and 5, the convolution kernel size is 3×3, the step size is 1, and the filling is the dilation rate). Perform convolution operations on the fused feature maps to obtain target feature information under different receptive fields and enhance the model's adaptability to targets of different scales.
[0062] Step 5.3: Improve the detection head of YOLOv8 and adopt a dynamic anchor frame generation strategy. During the training process, dynamically adjust the size and proportion of the anchor frame according to the actual size distribution of the target object in the current batch data. The specific calculation method is to first count the width and height of the target object in the current batch data, calculate its average and standard deviation, and then determine the initial size range of the anchor frame according to the average and standard deviation. On this basis, cluster the size of the target object through the K-Means++ algorithm to obtain K cluster centers (K is set to 9), each cluster center corresponds to the size and proportion of an anchor frame. The anchor frame generated in this way can better adapt to the size changes of target objects in different data sets and different scenarios, and improve the accuracy of detection.
[0063] Step 6, train the YOLOv8-seg network models with different configurations respectively;
[0064] Specifically:
[0065] Step 6.1: Train YOLOv8 on the 10 independent folded data sets respectively; output the test results of urban waterlogging;
[0066] Step 6.2: Train the YOLOv8 model again according to the data sets of different sizes 800, 1600, and 2400 divided in Step 4.2.
[0067] Step 7: Test the trained YOLOv8-seg model in complex scenarios.
[0068] Specifically:
[0069] Step 7.1: Based on the training results of Step 6.1, perform 10-fold cross-training on YOLOv8 to find the model with the smallest test set estimation error;
[0070] Step 7.2: Collect 100 images of urban waterlogging in complex scenarios, including blurred and damaged images, decentralized flood-inundated areas, and blurred scenes at night; test the model in Step 7.1; and finally verify the model’s recognition effect on waterlogging in special scenarios.
[0071] Step 8: Evaluate the applicability of each model for different application scenarios based on the parameter quantity and test accuracy of the YOLOv8-seg network model with different configurations.
[0072] Obviously, based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative work are within the scope of protection of the present invention.
Claims
1. The urban waterlogging range identification method based on YOLOv8 is characterized by: The following steps are involved: Step 1, by using the Google search engine, filter the retrieved images on the web page to determine the dataset to be used; Step 2, preprocess the constructed data set; Step 3, process the constructed dataset and use the labelme annotation tool to annotate all images in the dataset; Step 4, data set division, divide the labeled urban waterlogging data set into training set and test set in a ratio of 9:1; Step 5, improve the YOLOv8 model; Step 6, train the YOLOv8-seg network models with different configurations respectively; Step 7: Test the trained YOLOv8-seg model in complex scenarios. Step 8: Evaluate the applicability of each model for different application scenarios based on the parameter quantity and test accuracy of the YOLOv8-seg network model with different configurations.
2. The urban waterlogging range identification method based on YOLOv8 according to claim 1 is characterized in that: The Step 1 is specifically as follows: Step 1.1: Use the web crawler method and Geogle search engine to obtain relevant images of urban waterlogging using the keyword "urban waterlogging"; Step 1.2: Screen the collected images to ensure that the entire dataset contains daytime, nighttime, and blurred scenes, and covers images from all perspectives, ultimately obtaining 2,400 different images of urban flooding.
3. The urban waterlogging range identification method based on YOLOv8 according to claim 2 is characterized in that: The Step 2 is specifically as follows: Step 2.1: Perform image enhancement operations on the input image data, including random brightness adjustment, random contrast adjustment, random saturation adjustment and random geometric transformation; among them, the brightness adjustment amplitude is randomly selected between [-0.2, 0.2], the contrast adjustment amplitude is randomly selected between [0.8, 1.2], and the saturation adjustment amplitude is randomly selected between [0.8, 1.2]; the rotation angle is randomly selected between [-15°, 15°], the scaling ratio is randomly selected between [0.8, 1.2], the translation amount is randomly selected within the range of [-5%, 5%] of the image width and height, and the flip operation is randomly performed with a probability of 0.5; Step 2.2: Adopt an adaptive image scaling strategy. According to the aspect ratio of the image and the preset standard size, calculate the scaling ratio so that the long side is scaled to close to the standard size and the short side is scaled proportionally, while keeping the original aspect ratio of the image unchanged to avoid image distortion; the standard size is set to [640,640]; use Gaussian blur to preprocess the image with a Gaussian kernel size of 3×3 and a standard deviation of 1.5 to reduce the impact of image noise on subsequent detection and segmentation.
4. The urban waterlogging range identification method based on YOLOv8 according to claim 3 is characterized in that: The Step 3 is specifically as follows: Step 3.1: Use labelme to label 2,400 urban waterlogging images: Create a folder named flood_data, and create two folders, image and labels, in the folder to store 2,400 images and their corresponding labels. Make sure that the only target in the image is water, which is defined as water. Step 3.2: Process the annotation file generated by the labelme annotation tool and convert it into a txt format file suitable for model training.
5. The urban waterlogging range identification method based on YOLOv8 according to claim 4 is characterized in that: The Step 4 is specifically as follows: Step 4.1: First, the experimental dataset needs to be processed. The dataset is evenly divided into 10 independent folds; each fold serves as a test set during one round of training, while the remaining 9 folds are combined and used as training sets; each combination is divided into training sets and test sets in a ratio of 9:1; Step 4.2: In addition, the first 800, 1600, and 2400 images of the 2400 dataset are divided; and the dataset of each size is divided into training set and test set in a ratio of 9:
1.
6. The urban waterlogging range identification method based on YOLOv8 according to claim 5 is characterized in that: The Step 5 is specifically as follows: Step5.1: Introduce an attention mechanism module into the backbone network of YOLOv8, specifically a hybrid attention mechanism CBAM based on channel and spatial dimensions; this module first assigns weights to each channel of the input feature map through the channel attention submodule to highlight important channel features; in the channel attention submodule, first perform global average pooling and global maximum pooling on the input feature map to obtain two 1×1×12 feature vectors, and then send these two feature vectors to a shared multi-layer perceptron MLP, which contains a hidden layer with 4 neurons. The output is two processed feature vectors, which are then added and activated by a Sigmoid function to obtain a channel attention weight vector, and finally the weight vector is multiplied by the input feature map to obtain a feature map after channel attention adjustment; then, the spatial attention submodule is used to assign weights to the feature map after channel attention adjustment in the spatial dimension to focus on important spatial areas; In the spatial attention submodule, the feature map after channel attention adjustment is sequentially passed through a convolution-based dimensionality reduction layer, a Sigmoid function activation layer, and a convolution-based dimensionality increase layer to obtain a spatial attention weight map. Finally, the spatial attention weight map is multiplied with the feature map after channel attention adjustment to obtain the final feature map adjusted by the attention mechanism. In this way, the model can more effectively focus on the features of the target area, suppress the interference of irrelevant information such as background, and improve the model's feature extraction ability and detection segmentation accuracy. Step 5.2: Improve the neck structure of YOLOv8 and adopt a structure based on feature pyramid fusion and multi-scale dilated convolution. First, build a multi-scale feature pyramid, upsample and downsample the feature maps output by the backbone network at different stages to make them have the same resolution, and then perform feature fusion. The nearest neighbor interpolation method is used for upsampling, and the convolution operation with a step size of 2 is used for downsampling. After feature fusion, a multi-scale dilated convolution module is introduced. This module contains three dilated convolution layers with different dilation rates. Convolution operations are performed on the fused feature maps to obtain target feature information under different receptive fields, thereby enhancing the model's adaptability to targets of different scales. Step 5.3: Improve the detection head of YOLOv8 and adopt a dynamic anchor box generation strategy; During the training process, the size and proportion of the anchor box are dynamically adjusted according to the actual size distribution of the target objects in the current batch data. The specific calculation method is to first count the width and height of the target objects in the current batch data, calculate their average and standard deviation, and then determine the initial size range of the anchor box based on the average and standard deviation. On this basis, the sizes of the target objects are clustered using the K-Means++ algorithm to obtain K cluster centers, each of which corresponds to the size and proportion of an anchor box. The anchor box generated in this way can better adapt to the size changes of target objects in different data sets and different scenarios, thereby improving the accuracy of detection.
7. The urban waterlogging range identification method based on YOLOv8 according to claim 6 is characterized in that: The Step 6 is specifically as follows: Step 6.1: Train YOLOv8 on the 10 independent folded data sets respectively; output the test results of urban waterlogging; Step 6.2: Train the YOLOv8 model again according to the data sets of different sizes 800, 1600, and 2400 divided in Step 4.
2.
8. The urban waterlogging range identification method based on YOLOv8 according to claim 7 is characterized in that: The Step 7 is specifically as follows: Step 7.1: Based on the training results of Step 6.1, perform 10-fold cross-training on YOLOv8 to find the model with the smallest test set estimation error; Step 7.2: Collect 100 images of urban waterlogging in complex scenarios, including blurred and damaged images, decentralized flood-inundated areas, and blurred scenes at night; test the model in Step 7.1; and finally verify the model’s recognition effect on waterlogging in special scenarios.