Night flood scene water level grade automatic estimation method based on bus wading image and improved YOLOv8 algorithm

By improving the YOLOv8 algorithm and combining the Retinex-based framework and lighting guide converter, the accuracy of flood risk level assessment in low-light environments at night is solved, efficient and robust target detection capabilities are achieved, and intelligent support for urban flood prevention and control is provided.

CN119964100APending Publication Date: 2025-05-09HOHAI UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510015832.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-06
Publication Date
2025-05-09

AI Technical Summary

Technical Problem

The prior art is difficult to achieve accurate flood risk level assessment in low-light environments at night, and the robustness and efficiency of the object detection algorithm under low-light conditions are insufficient.

Method used

The improved YOLOv8 algorithm based on bus wading images is adopted, combined with a one-stage Retinex-based framework, lighting guide converter and lighting guide multi-head self-attention mechanism, and the object detection model is optimized to improve detection capabilities in low-light environments.

Benefits of technology

It realizes the rapid and accurate identification of bus wading status in low-light environments at night, improves the accuracy and robustness of flood risk level assessment, and provides a reliable and intelligent solution for urban flood disaster prevention and control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119964100A_ABST
    Figure CN119964100A_ABST
Patent Text Reader

Abstract

The invention discloses a night flood scene water level grade automatic estimation method based on a bus wading image and an improved YOLOv8 algorithm. The method comprises the specific steps that a receipt library is acquired; the collected data is preprocessed; a picture data enhancement strategy is adopted for the night flood scene images meeting the requirements; labeling all the images by using Label and storing the images as a YOLO format file; a proper YOLOv8 model is selected for improvement and optimization; setting reasonable training parameters, and training the constructed comprehensive data set by using the improved grid structure; and performing urban flood water level identification estimation by using the trained optimal weight file. By means of social media big data and the improved YOLOv8 algorithm, low-cost, rapid-detection and high-accuracy urban flood water level automatic estimation is achieved, meanwhile, the detection performance of the model in a night scene is improved, and reliable technical support is provided for real-time flood risk assessment and emergency management of a night urban traffic system; the important application potential is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to an automatic estimation method for water level in a nighttime flood scene based on a bus wading image and an improved YOLOv8 algorithm, and belongs to the field of disaster risk assessment and analysis. Background Art

[0002] With the intensification of global climate change, urban flood disasters caused by extreme rainfall events are becoming more and more frequent, seriously threatening the normal operation of cities and the safety of life and property of residents. Rapid and accurate assessment of flood risk levels is of great practical significance for formulating flood prevention and disaster reduction measures and carrying out emergency rescue. In this context, the use of new data sources provided by social media and mobile Internet for flood monitoring and risk assessment has gradually become a research hotspot. User-generated content (UGC) on social media platforms (such as Weibo and Douyin) can record flood-related information in real time, which contains rich images and geographic information, providing a wide range of possibilities for urban flood water level detection research.

[0003] Buses are ideal reference objects for flood level monitoring due to their standardized height and structure, as well as small differences in vehicle models. The operating range of buses usually covers the core areas of cities or busy traffic areas. Their wading status not only reflects the real-time depth of floods, but also affects the normal operation of urban public transportation systems. However, current research focuses on daytime scenes, and technical solutions for nighttime flood level monitoring are extremely scarce. Insufficient light in nighttime scenes causes the shape, color, and texture features of target objects to be blurred or missing, greatly increasing the difficulty of detection. In addition, although low-light image enhancement technology has made certain progress in the field of computer vision, how to combine target detection algorithms to achieve accurate assessment of flood risk levels in low-light environments at night is still an unsolved problem. Insufficient light in nighttime scenes causes the shape, color, and texture of target objects to be blurred or missing, greatly increasing the difficulty of detection. In addition, although low-light image enhancement technology has made certain progress in the field of computer vision, how to simultaneously achieve accuracy and robustness of target detection in low-light environments is still a challenge. Therefore, it is of great practical significance to develop a method that can automatically assess the urban flood risk level based on the wading status of buses in nighttime environments.

[0004] The estimation capabilities of existing technologies in night scenes are limited in many aspects. Traditional image enhancement methods, such as histogram equalization and gamma correction, can improve brightness, but do not fully consider the illumination characteristics of the image, and are prone to introduce artifacts, overexposure, or color distortion. Methods based on Retinex theory usually assume that the image is lossless and ignore the noise and color distortion in the actual scene, resulting in the amplification of noise and reduction of visual authenticity during the enhancement process. Although deep learning methods have made some progress, convolutional neural networks (CNNs) are difficult to capture long-range dependencies, and most of them use multi-stage training processes, which increases complexity and computational cost. Although the Transformer model has excellent global modeling capabilities, its high computational complexity limits its application in low-light image enhancement. In summary, the image enhancement and target detection capabilities of existing technologies in low-light environments at night are still imperfect and cannot meet the needs of flood risk level assessment. Therefore, it is necessary to develop a technology that can effectively cope with low-light environments and combine target detection algorithms. Summary of the invention

[0005] Purpose of the invention: In order to overcome the shortcomings of the prior art, the present invention provides a method for automatically estimating nighttime flood water level based on bus wading image data and an improved YOLOv8 algorithm. The method optimizes the target detection capability in low-light environments through an improved YOLOv8s network, and can quickly and accurately identify bus objects in nighttime images. Combined with the visual characteristics of the bus wading state and the corresponding algorithm model, the method realizes the automatic assessment of nighttime urban flood risks, provides reliable technical support for the safe and stable operation of urban public transportation systems at night under rainfall environments, and provides an important basis for urban traffic emergency management and flood prevention and disaster reduction decision-making.

[0006] Technical solution: To solve the above technical problems, the method for automatically estimating the water level of nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm of the present invention comprises the following steps:

[0007] Step S1: on social media platforms such as TikTok, Weibo, WeChat public accounts, and The Paper, search for specific keywords to obtain image data related to the target disaster;

[0008] Step S2: preprocessing the collected data;

[0009] Step S3: Use image data enhancement technology to process and expand data samples for images that meet the requirements;

[0010] Step S4: Use the Labelimg tool to label all images and store them in YOLO format;

[0011] Step S5: Select the target detection model for improvement and optimization, select the training parameters, and use the processed nighttime comprehensive data set to train the improved YOLOv8s model;

[0012] Step S6: Use the trained optimal model to detect the image to be tested and obtain the result of nighttime urban flood water level recognition.

[0013] Preferably, in step S1, the search social media platforms should include Weibo, Tik Tok, WeChat public accounts, The Paper, etc., the specific keywords should include "urban floods" and "flooded buses", the collected data should include both flood information and bus flooding conditions, and the collection method should use Python code crawling and manual storage.

[0014] Preferably, in step S2, data preprocessing includes cleaning, screening, and image data format conversion of the collected data.

[0015] Preferably, in step S3: using image data augmentation technology, a series of random transformations (such as flipping, cropping, rotating, scaling, color adjustment, translation, etc.) are performed on each image to generate a large number of new samples with different viewpoints, sizes, lighting conditions and backgrounds. This can obtain large-scale, high-quality training data set samples in a short time and at a low cost, alleviate the sample imbalance problem, and at the same time greatly improve the generalization ability of the model and enhance the robustness of the model.

[0016] Preferably, in step S4: all images are labeled using Labelimg, the most commonly used annotation tool in target detection model training. Labelimg can be installed through pip in Python. The tool page is concise and easy to operate. The stored YOLO format can be directly used for model training later, reducing the work of file format conversion.

[0017] Preferably, in step S5: improving and optimizing the target detection model includes:

[0018] (1) Introducing a one-stage Retinex-based framework (ORF);

[0019] (2) Design an illumination-guided transformer (IGT);

[0020] (3) Add a new self-attention mechanism (IG-MSA);

[0021] ① A one-stage Retinex-based framework (ORF) is introduced to decompose the low-light image into a reflection image and an illumination map, and a perturbation term is introduced to simulate the noise, artifacts, and illumination distortion problems that may exist in actual scenes. The illumination-enhanced image I is generated through the illumination estimator (ε) luand illumination feature F lu , and then use the disturbance recovery module Suppress the noise, artifacts, overexposure or color distortion caused by light enhancement in the image, and finally output the enhanced image I en The illumination estimator extracts and enhances the features of the input image and illumination prior through convolution operations, and outputs the enhanced illumination. To avoid the numerical overflow problem in the traditional Retinex method. Finally, ORF not only improves the visual quality of low-light images through end-to-end integrated design, but also significantly reduces the complexity of multi-stage training, thereby achieving efficient and robust image enhancement. The specific expression of the framework is as follows:

[0022]

[0023] ② An illumination-guided transformer is designed, which adopts a three-scale U-shaped architecture and guides the illumination features to achieve efficient feature modeling and target recovery in low-light environments. The downsampling branch of IGT extracts hierarchical features through convolution and illumination-guided attention block (IGAB), combined with the illumination feature F lu Capture the illumination interaction between regions; the upsampling branch gradually restores the features through deconvolution and jump connection, and outputs the residual image I re Finally, the enhanced image I en =I lu +I re It is generated by superimposing the illumination enhancement map and the residual map. The core illumination-guided multi-head self-attention mechanism (IG-MSA) combines illumination features to guide the self-attention distribution, effectively improving the restoration quality of dark areas. While reducing computational complexity, IGT fully taps the potential of Transformer in low-light image enhancement tasks, and can efficiently process multi-scale features to improve image quality and visual effects in low-light environments.

[0024] ③Added a lighting-guided multi-head self-attention mechanism, by lu Incorporating self-attention calculations enhances the feature interaction of regions under different lighting conditions. IG-MSA first transforms the input feature F in and illumination feature F lu Reshape into multiple tokens and decompose into multi-head attention units. In each head, the query (Q), key (K) and value (V) are calculated and then combined with the illumination feature F lu Generate enhanced attention distribution. Finally, the output feature F is calculated through matrix multiplication and position information encoding outThis mechanism can introduce more illumination information in dark areas and improve the model's ability to recover from damage in low-light scenes. Compared with traditional global self-attention, IG-MSA significantly reduces the computational complexity, enabling it to be embedded in the basic modules of the network and is suitable for multi-scale feature modeling in low-light image enhancement tasks.

[0025] Preferably, in step S6: the image to be tested is input into the trained improved YOLOv8s model to obtain a water level detection result of a nighttime flood scene based on a bus.

[0026] The present invention integrates real-time image data from social media, effectively uses buses as the core reference for flood levels, selects the YOLOv8s model with a smaller number of parameters as the basic network based on the efficient detection capabilities of the YOLOv8 series of networks, and performs in-depth optimization based on the characteristics of night scenes. These improvements include further streamlining model parameters to improve operating efficiency, and enhancing the model's feature extraction and target detection capabilities in low-light environments. The improved network can efficiently process nighttime bus wading images in social media, and achieves an accurate assessment of flood level risk levels. The present invention provides a reliable and intelligent solution for urban traffic emergency management and flood disaster prevention and control. Through this method, city managers can make more scientific emergency decisions based on real-time flood data in nighttime environments, thereby maximizing the stability and safety of the public transportation system.

[0027] Beneficial effects: Compared with the prior art, it has the following beneficial effects:

[0028] (1) The present invention fully combines the advantages of social media image data, such as huge amount of data, wide coverage and strong real-time performance, and provides a new technical path for disaster risk assessment and analysis.

[0029] (2) The present invention improves the ability of YOLOv8s to detect and recognize targets in low-light environments by adding technical means of improved modules. The ORF framework models and solves the noise, artifacts and illumination distortion problems in low-light images through end-to-end integrated design, which greatly improves the visual quality and enhancement effect of low-light images. The illumination-guided transformer incorporates illumination feature information into multi-scale feature modeling, which significantly improves the model's recovery ability and feature extraction efficiency in dark areas. The illumination-guided multi-head self-attention mechanism guides the self-attention calculation between regions through illumination features, which greatly reduces the computational complexity while improving the ability to capture detailed features in low-light scenes.

[0030] (3) The method proposed in the present invention has the characteristics of fast detection speed and high accuracy, and supports the direct input of images of any size, significantly reducing the data preprocessing time and improving the efficiency of practical applications. As the core of the detection object, the bus has become an ideal reference for flood level monitoring due to its standardized body height and structure, small model differences and wide urban coverage. Its structural characteristics and social attributes further enhance the practicality and reliability of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is the overall flow chart of the present invention;

[0032] Figure 2 It is a Labelimg annotation diagram;

[0033] Figure 3 It is a schematic diagram of image data enhancement;

[0034] Figure 4 This is the improved YOLOv8 network structure diagram;

[0035] Figure 5 It is a specific structural diagram of the improved module in the present invention;

[0036] Figure 6 It is the optimization flow chart of the present invention. DETAILED DESCRIPTION

[0037] The present invention will be further described below in conjunction with the accompanying drawings.

[0038] like Figures 1 to 6 As shown, this embodiment introduces a method for automatically estimating the water level of a nighttime flood scene based on a bus wading image and an improved YOLOv8 algorithm, which specifically includes the following steps:

[0039] Step S1: On social media platforms such as TikTok, Weibo, WeChat public accounts, and The Paper, by searching for specific keywords such as "urban floods", "submerged buses", and "rainstorms and floods", data related to the target disaster is obtained by crawling and manually saving using Python code. This data should include information about buses wading in water.

[0040] There are two ways to obtain data:

[0041] ①Use Python code: Write Python code, set specific keywords, use Selenium tools to control the browser and simulate user behavior to scroll the page to load all relevant image content on the page, and download and save it to a local folder:

[0042] ② Manual retrieval: In addition to using Python code to crawl relevant graphic data on the browser, you can also manually retrieve the target image. Since social media platforms such as Weibo and Douyin have certain anti-crawler mechanisms, it is not easy to obtain data packets through code, and manual retrieval is more effective.

[0043] The data is divided into two categories:

[0044] ① User-posted images and texts: Images are usually saved in .JPG format. Other formats such as .PNG, .JPEG and .WEBP can also be stored in the same folder and then modified uniformly using command line window instructions. The obtained image resolution is not required, it only needs to contain relevant target information.

[0045] ② Videos posted by users: Videos are usually saved in .mp4 format. After obtaining the video file, the bus wading image can be further obtained by parsing the video stream or extracting key frames.

[0046] Step S2: Preprocess the collected data by cleaning, screening and converting the image data format to ensure the accuracy and reliability of the data.

[0047] Step S2 specifically includes:

[0048] Step S2.1: Data screening:

[0049] The images of buses wading in water were selected as the screening conditions. The collected data were preliminarily screened and the images irrelevant to the research were removed using existing technical means.

[0050] Step S2.2: Data format conversion:

[0051] Convert the cleaned image data into a format suitable for analysis. Run the command line window in the folder where the images are saved, output relevant instructions, and convert the images in .PNG, .JPEG, and .WEBP formats to .JPG format to facilitate subsequent Labelimg annotation work;

[0052] Step S3: Use image data enhancement technology to process and expand data samples for images that meet the requirements:

[0053] Step S3 specifically includes:

[0054] Step S3.1: Use Roboflow software to enhance image data, enter the new project page, upload the image data to the platform, and divide the uploaded data set into training set, validation set and test set according to a certain ratio;

[0055] Step S3.2: Roboflow can preprocess the image data to be enhanced, including automatic orientation, uniform image stretching, automatic contrast adjustment, object isolation, static cropping, slicing, class modification, screening and other operation functions. Select the preprocessing step according to the corresponding needs;

[0056] Step S3.3: Refer to Figure 3 , Select data enhancement methods. Roboflow includes a variety of data enhancement methods such as flipping, cropping, rotating, scaling, color adjustment, translation, grayscale adjustment, image stitching, etc., and multiple data enhancement methods can be used in one enhancement process. After a series of random transformations are performed on each image, a large number of new samples with different viewpoints, sizes, lighting conditions and backgrounds can be generated. This can obtain large-scale, high-quality training data set samples in a short time and at a low cost, alleviate the problem of sample imbalance, and at the same time greatly improve the generalization ability of the model and enhance the robustness of the model;

[0057] Step S3.4: Dataset export: Use the Export function provided by Roboflow to directly export the enhanced dataset to a local folder. When exporting, select the YOLOv8 PyTorch format zip version.

[0058] Step S4: Use the Labelimg tool to annotate all images and store them in YOLO format;

[0059] Step S4 specifically includes:

[0060] Step S4.1: Install Labelimg tool:

[0061] Depending on the computer environment status, you can install it through the pip command or clone and run it from the GitHub source code;

[0062] Step S4.2: Labeling using the Labelimg tool:

[0063] After launching LabelImg, the user needs to set the image input folder and annotation save directory. The annotation category file Classes.txt needs to be prepared in advance in the annotation save directory, and the category information needs to be written into it as required. Selecting the annotation output format as YOLO format reduces the file format conversion work to ensure that it meets the requirements of subsequent data processing and model training. The category file information is shown in Table 1.

[0064] Table 1 Detailed information of vehicle instances and flood risk levels in the flooded bus dataset

[0065]

[0066] When annotating, load the image, use the Create Rectangular Box tool to draw a bounding box and enter the label name in the pop-up window. Adjust the size and position of the box by dragging to ensure the accuracy of the annotation. After the annotation is completed, click the Save button or use the shortcut key to save the generated annotation file and make sure its format matches the input image.

[0067] During the annotation process, shortcut keys can be used to navigate the image, delete, and copy boxes to improve efficiency. After the annotation is completed, the saved annotation file should be loaded to check the accuracy of the annotation and make necessary modifications. Finally, the annotation file is exported according to the application requirements for object detection model training such as TensorFlow, Detectron2, or YOLO series models. The annotation work can systematically generate high-quality annotation data for training deep learning models;

[0068] Step S5: Select the target detection model for improvement and optimization, select the training parameters, and use the processed nighttime comprehensive data set to train the improved YOLOv8s model;

[0069] Step S5 specifically includes:

[0070] Step S5.1: Select the target detection model YOLOv8s:

[0071] YOLO (You Only Look Once) is a fast and accurate target detection algorithm. Its main principle is to transform the target detection task into a regression problem. It detects objects by dividing the image into grids and directly predicting the bounding box and category on each grid. YOLOv8, as the latest version of the YOLO algorithm, has demonstrated high accuracy and fast detection speed on the standard COCO (Common Objects in Conte) dataset. The YOLOv8 algorithm has a total of 5 configuration models, namely YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8x. The computer resources required for each configuration are different. As a preferred choice, YOLOv8s is recommended, which has a moderate grid size and achieves a good balance between model accuracy, training time, and computing resources.

[0072] Reference Figure 4 ,The network structure of the YOLOv8s algorithm is divided into three parts, namely the backbone network (Backbone), the feature fusion enhancement module (Neck) and the head network (Head).

[0073] ① Backbone network: The backbone network of YOLOv8 consists of 5 convolution modules, 4 C2f modules and one SPPF module, which is responsible for feature extraction of the input image. It gradually extracts image features through multi-layer convolution layers, batch normalization and activation functions (such as LeakyReLU), and combines residual modules similar to ResNet to effectively transfer gradients and avoid the gradient disappearance problem. In order to improve the feature expression ability, the backbone network also introduces the CSPNet structure to reduce computational redundancy through feature division and fusion. In addition, the spatial pyramid pooling (SPP) module expands the receptive field and improves the network's ability to detect targets of different scales, so that the backbone network maintains efficient feature extraction capabilities while reducing computational complexity.

[0074] ② Feature fusion enhancement module: This module includes feature pyramid network (FPN), path aggregation network (PANet), SPPF module and PAA module, which aims to promote the integration of multi-scale features. FPN combines low-resolution features with high-resolution details through bottom-up feature fusion to enhance the overall information perception ability; PANet realizes the linkage between feature layers through top-down path aggregation, further enhancing the feature expression ability. The SPPF module performs multi-scale pooling operations in the Neck part to improve the detection ability of targets of different sizes; and the PAA module improves the sample utilization efficiency and model convergence effect in training through intelligent anchor frames and positive and negative sample allocation, ensuring the robustness of the model in complex scenarios.

[0075] ③Head network: This module consists of a detection head and a classification head, each of which undertakes different tasks. It receives the fused feature map from the Neck module and predicts the output through the detection head and the classification head. The detection head consists of multiple layers of convolutional layers and deconvolutional layers, predicting the bounding box regression value and target confidence of each anchor box to achieve refined boundary detection. The classification head processes the feature map through global average pooling, reduces the dimension and outputs the probability distribution of the category, thereby achieving multi-category classification. This design enables YOLOv8 to perform efficient detection and classification while maintaining real-time performance, and combines non-maximum suppression (NMS) to remove redundant boxes to ensure the uniqueness and high accuracy of the output results. By optimizing the loss function (such as IoU and classification loss), the network continuously approaches the true value during the training process, thereby improving the detection effect. This comprehensive design of the head network enables YOLOv8 to perform target detection and classification efficiently and stably in multiple scenarios, meeting the needs of practical applications.

[0076] Step S5.2: Optimize and improve the network structure of the YOLOv8s model, build an improved model based on the Retinexformer framework, and use the nighttime comprehensive data set for model training. The specific implementation steps are as follows:

[0077] 1. After the image is input into the model, it first passes through the illumination modeling and enhancement module of the low-light image, such as Figure 4 As shown;

[0078] Input low-light image I∈R H×W×3 It is decomposed into a reflection image R and an illumination map L, which is expressed as I = R⊙L based on the Retinex theory, where ⊙ represents element-by-element multiplication. To deal with the problems of noise, artifacts, and illumination distortion in low-light environments, the illumination estimator module of Retinexformer performs illumination modeling and enhancement on the input image. First, the illumination prior map L is calculated. p :L p =mean c (I). Among them, mean c Indicates the channel mean calculation for each pixel. Then, I and L p The illumination feature F is generated by fusing 1×I convolution and depth-wise separable convolution (5×5). lu . Further, by enhancing the image with light Improve the image brightness and obtain the brightness enhanced image I lu : in, It is directly generated through the convolutional network, avoiding the overflow problem caused by the division operation in the traditional method.

[0079] 2. Damage recovery and detail enhancement;

[0080] For the illumination enhanced image I lu Possible problems such as overexposure and noise amplification are repaired using the damage recovery module (light-guided transformer, IGT) of Retinexformer. IGT adopts a three-scale U-shaped architecture and guides the illumination features to achieve efficient feature modeling and target recovery in low-light environments. In the downsampling branch, 4×4 convolution is used to perform lu Downsample layer by layer to generate hierarchical features F0, F1, and F2. In each layer of feature processing, an illumination guided attention block (IGAB) is added to use the illumination feature F lu The feature interaction is optimized through the illumination-guided multi-head self-attention mechanism (IG-MSA). IG-MSA first transforms the input feature F in and illumination feature F lu Reshape into multiple tokens and decompose into multi-head attention units. In each head, the query (Q), key (K) and value (V) are calculated and then combined with the illumination feature F lu Generate enhanced attention distribution. Finally, the output feature F is calculated through matrix multiplication and position information encoding outThis mechanism can introduce more illumination information in dark areas and improve the model's ability to recover from damage in low-light scenes. Compared with traditional global self-attention, IG-MSA significantly reduces the computational complexity, allowing it to be embedded in the basic modules of the network and is suitable for multi-scale feature modeling in low-light image enhancement tasks. The calculation of IG-MSA is as follows:

[0081]

[0082] Among them, Q, K, V represent query, key and value features respectively, Y is the illumination feature, and α is a learnable scaling parameter. In the upsampling branch, the features are gradually restored through deconvolution, and the detail information is transmitted by combining jump connections, and finally the residual image I is generated. re The enhanced image is calculated by the following formula I en =I lu +I re .

[0083] Finally, ORF not only improves the visual quality of low-light images through end-to-end integrated design, but also significantly reduces the complexity of multi-stage training, thereby achieving efficient and robust image enhancement. The specific expression of the framework is as follows:

[0084]

[0085] 3. YOLOv8 network structure optimization, introduction of IGAB module to enhance low-light feature recognition;

[0086] The IGAB module is embedded in the shallow and deep feature extraction modules of the YOLOv8 network, and combined with the illumination features, the feature expression capability of low-light scene targets is improved. Figure 4 The specific embedding locations are as follows:

[0087] ① After the first convolution (Conv) layer and before the C2f module, the shallow layer is responsible for extracting the basic texture and edge features of the image. Adding IGAB can improve the feature expression ability in low-light environments through lighting information;

[0088] ② After the second C2f module and before entering the next Conv layer, the features at this position have more intermediate structural information, and IGAB can further enhance feature modeling by combining illumination features;

[0089] ③ Before the SPPF module and after the last C2f module, the deep features have semantic information. Adding IGAB can use the illumination information to enhance the global feature expression ability of the target;

[0090] ④ After upsampling and feature concatenation, this part fuses features of different scales. Adding IGAB can use illumination information to optimize the feature fusion results and improve the expression ability of cross-scale features.

[0091] Finally, the YOLOv8 network uses the Decoupled-Head and Anchor-Free mechanisms to further optimize the detection speed and accuracy. The model quickly identifies the wading state of the bus through adaptive adjustment and extracts key features such as wheel position and body height.

[0092] Step S5.3: Select appropriate learning rate, batch size, epoch, etc., input the training set images into the improved network model for training, and obtain the trained network model.

[0093] As an embodiment, the input size of the image is set to 640*640, and the initial parameters are set as follows: the learning rate is set to 0.01, the SGD optimizer is used, the batch size is set to 16 due to the memory limit of the graphics card, and the number of epoch iterations is set to 200. The learning rate is initially set to a relatively large value of 0.01 in order to make the speed of decline faster at the beginning of training.

[0094] Step S6: input the image to be tested into the trained improved YOLOv8s model to obtain the water level detection result of the night flood scene based on the bus;

[0095] The best.pt with the best performance in 200 rounds of training is used as the model for urban night scene detection. Switch the model to inference mode, load the optimal model, input the image to be detected, and the flood level in the image to be tested can be obtained in a very short time. Night buses can be successfully detected and their flood levels can be detected with a high confidence level.

[0096] 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 principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for automatically estimating water level in nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm, characterized in that: The following steps are involved: Step S1: On social media platforms, crowdsourced image data related to floods, buses, and night scenes are obtained by searching for specified keywords to construct a comprehensive nighttime dataset; Step S2: preprocessing the collected data; Step S3: Use image data enhancement technology to process and expand data samples for images that meet the requirements; Step S4: Use the Labelimg tool to label all images and store them in YOLO format; Step S5: Select the target detection model for improvement and optimization, select the training parameters, and use the processed nighttime comprehensive data set to train the improved YOLOv8s model; Step S6: Use the trained optimal model to detect the image to be tested and obtain the result of nighttime urban flood water level recognition.

2. The method for automatically estimating water level in nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm according to claim 1 is characterized by: In step S1, social media platforms include Weibo, Tik Tok, WeChat public accounts, and The Paper. The specified keywords include "urban floods", "flooded buses", and "nighttime". The collected data must contain flood information, bus flooding conditions, and be in a nighttime environment. The data is collected by crawling and manually saving using Python code.

3. The method for automatically estimating water level in nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm according to claim 1 is characterized by: In step S2, the collected data is cleaned, screened, and the image format is converted. According to the analysis requirements, the screening conditions are determined, and the collected data is preliminarily screened to remove images that are not related to the research.

4. The method for automatically estimating water level in nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm according to claim 1 is characterized by: In step S3: using image data augmentation technology, a series of random transformations are performed on each image, including flipping, cropping, rotation, scaling, color adjustment, and translation, to generate a large number of new samples with different viewpoints, sizes, lighting conditions, and backgrounds.

5. The method for automatically estimating water level in nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm according to claim 1, characterized in that: In step S5: the target detection model is an improved YOLOv8s model, including: a one-stage Retinex-based framework ORF, an illumination-guided transformer IGT and an illumination-guided multi-head self-attention mechanism IG-MSA.

6. The method for automatically estimating water level in nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm according to claim 5, characterized in that: The specific expression of the framework is as follows:

7. The method for automatically estimating water level in nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm according to claim 6, characterized in that: The basic unit of the illumination-guided transformer IGT is the illumination-guided attention block IGAB, which includes two layers of normalized LN, an illumination-guided multi-head self-attention IG-MSA module and a feed-forward network FFN. The specific implementation process is as follows: Input the illumination-enhanced image I lu The image is sequentially passed through a 3×3 convolution, a light-guided attention module, a 4×4 convolution with a stride of 2, two light-guided attention modules, and then a 4×4 convolution with a stride of 2 to generate hierarchical features. Finally, two IGABs are passed again, and a symmetrical upsampling branch is designed to upsample the features. The final enhanced I en It is calculated by the following formula: en =I lu +I re .

8. The method for automatically estimating water level in nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm according to claim 7, characterized in that: The S5 comprises the following steps: Step S5.1: Select the target detection model YOLOv8s and set the number of training rounds: Step S5.2: Optimize and improve the network structure of the YOLOv8s model, build an improved model based on the Retinexformer framework, and use the nighttime comprehensive dataset for model training; Step S5.3: Select an appropriate learning rate, batch size and epoch, input the training set images into the improved network model for training, and obtain the trained network model.

9. The method for automatically estimating water level in nighttime flood scenes based on bus wading images and improved YOLOv8 algorithm according to claim 8, characterized in that: The S5.2 comprises the following steps: S5.21: After the image is input into the model, the input low-light image I∈R H×W×3 It is decomposed into a reflection image R and an illumination map L, which is expressed as I = R⊙L based on the Retinex theory, where ⊙ represents element-by-element multiplication to calculate the illumination prior map L p :L p =mean c (I), where mean c Indicates the channel mean calculation for each pixel, I and L p The illumination feature F is generated by fusing 1×I convolution and depth-wise separable convolution 5×5. lu , by enhancing the image with light Get the brightness enhanced image I lu : in, Directly generated through convolutional networks; S5.22: Light Enhancement Image I lu The damage recovery module of Retinexformer, the illumination-guided transformer IGT, is used for repair. In the downsampling branch, I is convolved by 4×4 convolution. lu Downsample layer by layer to generate hierarchical features F0, F1, F2. In each layer of feature processing, add the illumination-guided attention block IGAB to use the illumination feature F lu The multi-head self-attention mechanism IG-MSA is guided by illumination to optimize feature interaction. IG-MSA first transforms the input feature F in and illumination feature F lu Reshape into multiple tokens and decompose into multi-head attention units. In each head, the query Q, key K and value V are calculated, and then combined with the illumination feature F lu Generate enhanced attention distribution, calculate output feature F through matrix multiplication and position information encoding out , the calculation of IG-MSA is as follows: Among them, Q, K, V represent query, key and value features respectively, Y is the illumination feature, α is a learnable scaling parameter, and in the upsampling branch, the features are gradually restored by deconvolution, and the detail information is transmitted by combining the jump connection, and finally the residual image I is generated. re The enhanced image is calculated by the following formula I en =I lu +I re ; The specific expression of the framework is as follows: Among them, I lu is the illumination enhancement image, F lu is the illumination feature, ε is the illumination estimator, I is the low-light image, L p is the illumination prior map, I en To enhance the final image, It is the damage recovery module; S5.23: Embed the IGAB module in the shallow and deep feature extraction modules of the YOLOv8 network. The specific embedding positions are as follows: ①After the first convolution Conv layer and before the C2f module; ②After the second C2f module and before entering the next Conv layer; ③Before the SPPF module and after the last C2f module; ④After upsampling Upsample and feature concatenation Concat; Finally, the YOLOv8 network uses the Decoupled-Head and Anchor-Free mechanisms to adaptively adjust and quickly identify the wading state of the bus and extract key features.

Citation Information

Cited By

  • Barrel liquid level detection method and system for field image of surface water monitoring station

    CN121577121A