Method and device for constructing video water body segmentation model based on mask autoencoder
By introducing mask autoencoders and self-supervised learning into the video water segmentation model, and using scene encoding and spatiotemporal feature aggregation modules, the problem of difficulty in water segmentation in the existing technology is solved, and high-precision and low-cost water segmentation is achieved. Effect.
Patent Information
- Application Number
- CN202410823092.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-06-25
AI Technical Summary
Existing video water body segmentation methods are difficult to achieve efficient and accurate segmentation when dealing with large changes in the appearance of water bodies under different lighting and weather conditions, and traditional deep learning methods require complex models and a large amount of annotated data, which limits practical applications.
A video water segmentation model based on mask autoencoder is designed. Through single-frame supervised training and self-supervised learning, only the initial frame is annotated, using the scene encoding module, spatiotemporal feature aggregation module and mask autoencoding-decoding module. , gradually fuse features to achieve fine water body segmentation, reduce labeling costs and improve accuracy.
It achieves high-precision water body segmentation in the absence of a large amount of labeled data, reduces labeling costs, and improves the robustness and practical application value of the model.
Smart Images

Figure CN118397516B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method and device for constructing a video water body segmentation model based on a mask autoencoder. Background Art
[0002] Video water segmentation is an important task in the field of computer vision. It aims to automatically identify and separate water areas from video sequences. This has wide application value in environmental monitoring, natural disaster warning, and water resources management. With the popularization of remote sensing technology and drone monitoring, it has become easier to obtain continuous water video data, but how to efficiently and accurately process this data and extract valuable information has become a problem that needs to be solved urgently.
[0003] However, due to the complexity of the natural environment, the appearance of water bodies varies greatly under different lighting and weather conditions, which increases the difficulty of segmentation. Secondly, traditional video water body segmentation methods rely on technologies such as deep learning. Although these technologies have powerful performance, they usually require complex model structures to combine large amounts of labeled data for training, which limits their application in actual scenarios.
[0004] In summary, there is an urgent need for a method that can achieve high-precision water segmentation through a simple model structure in the absence of a large amount of labeled data, so as to be better applied in practical scenarios. Summary of the invention
[0005] The embodiments of the present application provide a method and device for constructing a video water body segmentation model based on a mask autoencoder. A mask autoencoder is designed and the video water body segmentation model is trained in a single-frame supervised manner. Only the initial frame needs to be labeled, thereby reducing the video labeling cost and improving the accuracy of video water body segmentation in a self-supervised learning manner.
[0006] In a first aspect, an embodiment of the present application provides a method for constructing a video water body segmentation model based on a mask autoencoder, the method comprising:
[0007] Obtain at least one video frame sequence containing water bodies as a training sample, and annotate the initial frame in each video frame sequence with water bodies and then input it into the constructed video water body segmentation framework;
[0008] The video water body segmentation architecture includes a scene encoding module, a spatiotemporal feature aggregation module, and a mask self-encoding-decoding module. The scene encoding module encodes each frame in the video frame sequence to obtain a multi-scale image corresponding to each frame.
[0009] The spatiotemporal feature aggregation module uses the input current frame as a query, the multi-scale image corresponding to the previous frame of the current frame as a key, and the predicted segmentation result corresponding to the previous frame of the current frame as a value to perform attention calculation to obtain a rough water body segmentation map of the current frame, wherein if the previous frame of the current frame is an initial frame, the water body annotation information of the initial frame is used as the predicted segmentation result of the initial frame;
[0010] In the mask self-encoding-decoding module, based on the coarse water body segmentation map of the current frame, the multi-scale image corresponding to the current frame and the current frame, the water body features of the current frame are gradually fused with the multi-scale image corresponding to the current frame to obtain a fine water body segmentation map of the current frame, and the fine water body segmentation map of the next frame is obtained by taking the fine water body segmentation map of the current frame as the predicted segmentation result of the next frame until the fine water body segmentation map of each frame image except the initial frame is obtained;
[0011] The spatiotemporal feature aggregation module then uses the initial frame as a query, and respectively uses a set number of fine water body segmentation maps as keys and multi-scale images corresponding to the keys as values to perform attention calculation to obtain a coarse water body segmentation map of the initial frame, and then the mask self-encoding-decoding module refines the coarse water body segmentation map of the initial frame to obtain a fine water body segmentation map of the initial frame;
[0012] The loss function is constructed using the fine water body segmentation map of the initial frame and the water body annotation information of the initial frame. When the loss function meets the set conditions, the parameters of the current video water body segmentation architecture are retained to obtain the video water body segmentation model.
[0013] In a second aspect, an embodiment of the present application provides a video water body segmentation method, comprising:
[0014] A video frame sequence to be segmented is obtained, and the video frame sequence to be segmented is input into a trained video water body segmentation model to obtain a water body segmentation result.
[0015] In a third aspect, an embodiment of the present application provides a device for constructing a video water body segmentation model based on a mask autoencoder, comprising:
[0016] An acquisition module is used to acquire at least one video frame sequence containing water bodies as a training sample, and annotate the water bodies on the initial frames in each video frame sequence and then input them into the constructed video water body segmentation framework;
[0017] A scene coding module, wherein the video water body segmentation architecture includes a scene coding module, a spatiotemporal feature aggregation module, and a mask self-coding-decoding module, wherein the scene coding module encodes each frame in a video frame sequence to obtain a multi-scale image corresponding to each frame;
[0018] A spatiotemporal feature aggregation module, wherein the spatiotemporal feature aggregation module uses the input current frame as a query, uses the multi-scale image corresponding to the previous frame of the current frame as a key, and uses the predicted segmentation result corresponding to the previous frame of the current frame as a value to perform attention calculation to obtain a rough water body segmentation map of the current frame, wherein if the previous frame of the current frame is an initial frame, the water body annotation information of the initial frame is used as the predicted segmentation result of the initial frame;
[0019] a mask self-encoding-decoding module, in which a water body feature of the current frame is obtained based on a coarse water body segmentation map of the current frame, a multi-scale image corresponding to the current frame, and the current frame, the water body feature of the current frame is gradually fused with the multi-scale image corresponding to the current frame to obtain a fine water body segmentation map of the current frame, and the fine water body segmentation map of the next frame is obtained by taking the fine water body segmentation map of the current frame as a predicted segmentation result of the next frame until a fine water body segmentation map of each frame image except the initial frame is obtained;
[0020] The initial frame prediction module, the spatiotemporal feature aggregation module uses the initial frame as a query, and respectively uses a set number of fine water body segmentation maps as keys and multi-scale images corresponding to the keys as values to perform attention calculation to obtain a rough water body segmentation map of the initial frame, and then the mask self-encoding-decoding module refines the rough water body segmentation map of the initial frame to obtain a fine water body segmentation map of the initial frame;
[0021] The loss calculation module uses the fine water body segmentation map of the initial frame and the water body annotation information of the initial frame to construct a loss function. When the loss function meets the set conditions, the parameters of the current video water body segmentation architecture are retained to obtain the video water body segmentation model.
[0022] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute a method for constructing a video water body segmentation model based on a mask autoencoder or a video water body segmentation method.
[0023] In a fifth aspect, an embodiment of the present application provides a readable storage medium, in which a computer program is stored. The computer program includes a program code for controlling a process to execute a process, and the process includes a method for constructing a video water body segmentation model based on a mask autoencoder or a video water body segmentation method.
[0024] The main contributions and innovations of the present invention are as follows:
[0025] In the embodiment of the present application, a video frame sequence is used as a training sample input into the video water body segmentation framework. The video water body segmentation framework uses the predicted segmentation result of the previous frame to predict the segmentation result of the current frame through a spatiotemporal feature aggregation module. Therefore, when annotating, this scheme only needs to annotate the initial frame in the video frame sequence, which greatly reduces the labor cost of annotation. This scheme designs a mask self-encoding-decoding module to refine the rough water body segmentation map, thereby ensuring the accuracy of the water body segmentation prediction of the current frame, and uses the fine water body segmentation map of the current frame as the predicted segmentation result of the next frame to obtain the fine water body segmentation map of the next frame, thereby obtaining highly accurate water body segmentation results with a small amount of annotation using a small sample in a self-supervised manner.
[0026] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0028] Figure 1 is a flowchart of a method for constructing a video water body segmentation model based on a mask autoencoder according to an embodiment of the present application;
[0029] Figure 2 is a structural diagram of a scene coding module according to an embodiment of the present application;
[0030] Figure 3 is a structural diagram of a mask self-encoding-decoding module according to an embodiment of the present application;
[0031] Figure 4 is an overall flow chart of a video water body segmentation model according to an embodiment of the present application;
[0032] Figure 5 It is a structural block diagram of a device for constructing a video water body segmentation model based on a mask autoencoder according to an embodiment of the present application;
[0033] Figure 6 It is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0034] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0035] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0036] Embodiment 1
[0037] The embodiment of the present application provides a method for constructing a video water body segmentation model based on a mask autoencoder, designs a mask autoencoder and trains the video water body segmentation model in a single-frame supervised manner, thereby reducing the video annotation cost and improving the accuracy of video water body segmentation. Specifically, reference Figure 1 , the method comprising:
[0038] Obtain at least one video frame sequence containing water bodies as a training sample, and annotate the initial frame in each video frame sequence with water bodies and then input it into the constructed video water body segmentation framework;
[0039] The video water body segmentation architecture includes a scene encoding module, a spatiotemporal feature aggregation module, and a mask self-encoding-decoding module. The scene encoding module encodes each frame in the video frame sequence to obtain a multi-scale image corresponding to each frame.
[0040] The spatiotemporal feature aggregation module uses the input current frame as a query, the multi-scale image corresponding to the previous frame of the current frame as a key, and the predicted segmentation result corresponding to the previous frame of the current frame as a value to perform attention calculation to obtain a rough water body segmentation map of the current frame, wherein if the previous frame of the current frame is an initial frame, the water body annotation information of the initial frame is used as the predicted segmentation result of the initial frame;
[0041] In the mask self-encoding-decoding module, based on the coarse water body segmentation map of the current frame, the multi-scale image corresponding to the current frame and the current frame, the water body features of the current frame are gradually fused with the multi-scale image corresponding to the current frame to obtain a fine water body segmentation map of the current frame, and the fine water body segmentation map of the next frame is obtained by taking the fine water body segmentation map of the current frame as the predicted segmentation result of the next frame until the fine water body segmentation map of each frame image except the initial frame is obtained;
[0042] The spatiotemporal feature aggregation module then uses the initial frame as a query, and respectively uses a set number of fine water body segmentation maps as keys and multi-scale images corresponding to the keys as values to perform attention calculation to obtain a coarse water body segmentation map of the initial frame, and then the mask self-encoding-decoding module refines the coarse water body segmentation map of the initial frame to obtain a fine water body segmentation map of the initial frame;
[0043] The loss function is constructed using the fine water body segmentation map of the initial frame and the water body annotation information of the initial frame. When the loss function meets the set conditions, the parameters of the current video water body segmentation architecture are retained to obtain the video water body segmentation model.
[0044] In this scheme, the video frame sequence in the training sample is preprocessed by random flipping, photometric distortion, random affine transformation, and random cropping and scaling. Among them, random flipping is to flip the video frame sequence trained in each batch horizontally with a probability of 50%. Photometric distortion is to adjust the brightness, chromaticity, contrast and saturation of the video frame sequence. Random affine transformation is to randomly rotate, translate, shear and scale the video frame sequence under the condition that the center of the video frame sequence remains unchanged. Random cropping and scaling is to crop the video frame sequence with a random area size and scale it to 384×384 to meet the input requirements of the video water body segmentation architecture. This scheme improves the diversity of training data through preprocessing operations, can enhance the robustness of the model when training the model, and can obtain better accuracy for video water body segmentation in the test phase.
[0045] In this solution, the number of frames in each video frame sequence in the training sample is a set number. In some specific embodiments, the set number is 8.
[0046] In the step of "the scene encoding module encodes each frame in the video frame sequence to obtain a multi-scale image corresponding to each frame", the scene encoding module is connected to a plurality of residual structures by a convolutional layer, and the multi-scale image includes feature maps of different sizes output by each residual structure.
[0047] In some specific embodiments, the structure of the scene encoding module is as follows: Figure 2As shown, the scene coding module includes a first residual block, a second residual block and a third residual block. The convolution layer in the scene coding module processes the input current frame and sequentially inputs it into the first residual block, the second residual block and the third residual block. The feature map size output by the first residual block is 96×96×256, the feature map size output by the second residual block is 48×48×512, and the feature map size output by the third residual block is 24×24×1024.
[0048] That is to say, the multi-scale features in this scheme include three feature maps of different sizes.
[0049] In this solution, the spatiotemporal feature aggregation module includes a storage body for storing the multi-scale feature map corresponding to each frame output by the scene encoding module, in order to facilitate the subsequent call calculation of these multi-scale features.
[0050] In the step of "taking the multi-scale image corresponding to the previous frame of the current frame as a key", a feature map with the smallest resolution in the multi-scale image corresponding to the previous frame of the current frame is taken as a key.
[0051] Specifically, since the multi-scale image contains multiple feature maps of different sizes, the smaller the resolution of the feature map, the larger the number of channels, that is, the smaller the resolution of the image will contain more semantic information, and thus it is more suitable as a key for water body segmentation. Therefore, this scheme uses the feature map with the smallest resolution in the multi-scale image as the key to improve the accuracy of water body segmentation.
[0052] Furthermore, the predicted segmentation result is downsampled to the same size as the feature map with the smallest resolution in the multi-scale image and used as the value.
[0053] Specifically, in the step of "using the predicted segmentation result corresponding to the previous frame of the current frame as a value to perform attention calculation to obtain a rough water body segmentation map of the current frame", the result of the attention calculation is upsampled to obtain a rough water body segmentation map, and the size of the rough water body segmentation map is the same as the image size in the video frame sequence.
[0054] Specifically, since the key and value sizes used in this scheme for attention calculation are both 24×24 feature maps, the attention calculation results are also 24×24 in size. Therefore, directly using the attention calculation results cannot restore the water body features in the video frame well. In order to better obtain the water body features in the video frame, the attention results are restored to the image size in the video frame sequence through upsampling.
[0055] In this solution, the structure of the mask self-encoding-decoding module is as follows: Figure 3As shown, the mask self-encoding-decoding module includes a mask encoding unit and a mask decoding unit. The mask encoding unit is connected in series by a coding convolution layer, multiple coding residual blocks and a feature coding fusion module. The current frame is first spliced with the rough water body segmentation map of the current frame and then input into the mask coding unit. After passing through the coding convolution layer and multiple coding residual blocks, the first feature map is output. The size of the first feature map is the same as the feature map with the smallest resolution in the multi-scale image, and the number of coding residual blocks is the same as the number of residual blocks in the scene coding module. The feature coding fusion module uses spatial attention and channel attention operations to fuse the first feature map with the feature map with the smallest resolution in the multi-scale image to obtain a first water body feature map.
[0056] The mask decoding unit is composed of a feature decoding fusion unit, multiple upsampling layers and a classification head connected in series. The feature decoding fusion unit is the same as the feature encoding fusion module. In the feature decoding fusion unit, spatial attention and channel attention operations are used to fuse the first water body feature map with the feature map with the smallest resolution in the multi-scale image again to obtain a second water body feature map. Multiple upsampling layers are used to gradually upsample the second water body feature map, and after each upsampling, the upsampling result is used to fuse the feature map of the same size as the upsampling result in the multi-scale image to obtain a third water body feature map. The classification head uses a bilinear interpolation upsampling operation to output the third water body feature map to obtain a fine water body segmentation map of the current frame.
[0057] That is, the number of upsampling layers in the mask decoding unit is one less than the number of residual blocks in the scene coding module.
[0058] Taking the case where the number of residual blocks in the scene coding module is 3 and the feature map sizes output by each residual block are 96×96, 48×48, and 24×24, respectively, the number of residual blocks in the mask coding unit is also 3, and the size of the first feature map output by the last residual block is 24×24. The feature coding fusion module then fuses the first feature map with the feature map with the smallest resolution in the multi-scale image to obtain the first water body feature map.
[0059] The number of upsampling layers in the mask decoding unit is 2 and the scaling factor is 2. The size of the second water body feature map output by the feature decoding fusion unit is 24×24. The second water body feature map is first upsampled to 48×48 by an upsampling layer and then fused with the feature map of 48×48 in the multi-scale feature map. Then, the second upsampling layer is upsampled to 96×96 and then fused with the feature map of 96×96 in the multi-scale feature map to obtain a third water body feature map. The classification head uses a bilinear interpolation upsampling operation to perform classification and output in a four-fold upsampling manner to obtain a fine water body segmentation map of 384×384. That is to say, the fine water body segmentation map output by this scheme is the same size as the image size input by the video water body segmentation architecture.
[0060] In this scheme, the fine water body segmentation map of the current frame is used as the predicted segmentation result of the next frame to obtain the fine water body segmentation map of the next frame, and the fine water body segmentation map of each frame image except the initial frame is obtained by the above method. The specific steps are not repeated here.
[0061] In this scheme, a set number of fine water body segmentation maps are obtained by random sampling, and each fine water body segmentation map is downsampled to the same size as the feature map with the smallest resolution in the multi-scale feature map. Each fine water body segmentation map and the feature map with the smallest resolution in the corresponding multi-scale feature map form a key-value pair, thereby obtaining a coarse water body segmentation map of the initial frame, and then the mask self-encoding-decoding module refines the coarse water body segmentation map of the initial frame to obtain a fine water body segmentation map of the initial frame. The overall process of the video water body segmentation model is as follows: Figure 4 shown.
[0062] In this scheme, the cross entropy loss and dice loss of the fine water body segmentation map of the initial frame and the water body annotation information of the initial frame are calculated. The specific formula is as follows:
[0063]
[0064] in, Indicates the water body annotation information of the initial frame, the value is 1 or 0, The fine water body segmentation map of the initial frame. Before the end of each batch of training, this scheme reduces the loss through back propagation, updates the network parameters and starts the next batch of training until all batches are trained or the loss is no longer reduced, and saves the current parameters of the video water body segmentation architecture.
[0065] Embodiment 2
[0066] A video water body segmentation method, comprising:
[0067] A video frame sequence to be segmented is obtained, and the video frame sequence to be segmented is input into a trained video water body segmentation model to obtain a water body segmentation result.
[0068] Embodiment 3
[0069] Based on the same idea, refer to Figure 5 , the application also proposes a device for constructing a video water body segmentation model based on a mask autoencoder, comprising:
[0070] An acquisition module is used to acquire at least one video frame sequence containing water bodies as a training sample, and annotate the water bodies on the initial frames in each video frame sequence and then input them into the constructed video water body segmentation framework;
[0071] A scene coding module, wherein the video water body segmentation architecture includes a scene coding module, a spatiotemporal feature aggregation module, and a mask self-coding-decoding module, wherein the scene coding module encodes each frame in a video frame sequence to obtain a multi-scale image corresponding to each frame;
[0072] A spatiotemporal feature aggregation module, wherein the spatiotemporal feature aggregation module uses the input current frame as a query, uses the multi-scale image corresponding to the previous frame of the current frame as a key, and uses the predicted segmentation result corresponding to the previous frame of the current frame as a value to perform attention calculation to obtain a rough water body segmentation map of the current frame, wherein if the previous frame of the current frame is an initial frame, the water body annotation information of the initial frame is used as the predicted segmentation result of the initial frame;
[0073] a mask self-encoding-decoding module, in which a water body feature of the current frame is obtained based on a coarse water body segmentation map of the current frame, a multi-scale image corresponding to the current frame, and the current frame, the water body feature of the current frame is gradually fused with the multi-scale image corresponding to the current frame to obtain a fine water body segmentation map of the current frame, and the fine water body segmentation map of the next frame is obtained by taking the fine water body segmentation map of the current frame as a predicted segmentation result of the next frame until a fine water body segmentation map of each frame image except the initial frame is obtained;
[0074] The initial frame prediction module, the spatiotemporal feature aggregation module uses the initial frame as a query, and respectively uses a set number of fine water body segmentation maps as keys and multi-scale images corresponding to the keys as values to perform attention calculation to obtain a rough water body segmentation map of the initial frame, and then the mask self-encoding-decoding module refines the rough water body segmentation map of the initial frame to obtain a fine water body segmentation map of the initial frame;
[0075] The loss calculation module uses the fine water body segmentation map of the initial frame and the water body annotation information of the initial frame to construct a loss function. When the loss function meets the set conditions, the parameters of the current video water body segmentation architecture are retained to obtain the video water body segmentation model.
[0076] Embodiment 3
[0077] This embodiment also provides an electronic device, referring to Figure 6 , comprises a memory 404 and a processor 402, wherein the memory 404 stores a computer program, and the processor 402 is configured to run the computer program to execute the steps in any of the above method embodiments.
[0078] Specifically, the processor 402 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0079] Among them, the memory 404 may include a large capacity memory 404 for data or instructions. For example, but not limitation, the memory 404 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive, or a combination of two or more of these. In appropriate cases, the memory 404 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 404 may be inside or outside the data processing device. In a specific embodiment, the memory 404 is a non-volatile memory. In a specific embodiment, the memory 404 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable Programmable Read-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable Programmable Read-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. In appropriate circumstances, the RAM may be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM may be a fast page mode dynamic random access memory 404 (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0080] The memory 404 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 402 .
[0081] The processor 402 reads and executes computer program instructions stored in the memory 404 to implement any one of the methods for constructing a video water body segmentation model based on a mask autoencoder in the above embodiments.
[0082] Optionally, the electronic device may further include a transmission device 406 and an input / output device 408 , wherein the transmission device 406 is connected to the processor 402 , and the input / output device 408 is connected to the processor 402 .
[0083] The transmission device 406 can be used to receive or send data via a network. Specific examples of the above-mentioned network may include a wired or wireless network provided by a communication provider of the electronic device. In one example, the transmission device includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 406 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0084] The input and output device 408 is used to input or output information. In this embodiment, the input information may be a video frame sequence containing water bodies, and the output information may be a water body segmentation result.
[0085] Optionally, in this embodiment, the processor 402 may be configured to perform the following steps through a computer program:
[0086] S101, obtaining at least one video frame sequence containing water bodies as a training sample, and annotating the initial frame in each video frame sequence with water bodies and inputting the resulting water bodies into a constructed video water body segmentation framework;
[0087] S102, the video water body segmentation architecture includes a scene encoding module, a spatiotemporal feature aggregation module and a mask self-encoding-decoding module, wherein the scene encoding module encodes each frame in a video frame sequence to obtain a multi-scale image corresponding to each frame;
[0088] S103, the spatiotemporal feature aggregation module uses the input current frame as a query, the multi-scale image corresponding to the previous frame of the current frame as a key, and the predicted segmentation result corresponding to the previous frame of the current frame as a value to perform attention calculation to obtain a rough water body segmentation map of the current frame, wherein if the previous frame of the current frame is an initial frame, the water body annotation information of the initial frame is used as the predicted segmentation result of the initial frame;
[0089] S104, in the mask self-encoding-decoding module, based on the coarse water body segmentation map of the current frame, the multi-scale image corresponding to the current frame, and the current frame, obtain the water body features of the current frame, gradually fuse the water body features of the current frame with the multi-scale image corresponding to the current frame to obtain a fine water body segmentation map of the current frame, and use the fine water body segmentation map of the current frame as the predicted segmentation result of the next frame to obtain a fine water body segmentation map of the next frame until the fine water body segmentation map of each frame image except the initial frame is obtained;
[0090] S105, the spatiotemporal feature aggregation module uses the initial frame as a query, and respectively uses a set number of fine water body segmentation maps as keys and multi-scale images corresponding to the keys as values to perform attention calculation to obtain a coarse water body segmentation map of the initial frame, and then the mask self-encoding-decoding module refines the coarse water body segmentation map of the initial frame to obtain a fine water body segmentation map of the initial frame;
[0091] S106, constructing a loss function using the fine water body segmentation map of the initial frame and the water body annotation information of the initial frame, and when the loss function meets the set conditions, retaining the parameters of the current video water body segmentation architecture to obtain a video water body segmentation model.
[0092] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0093] In general, various embodiments may be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects of the invention may be implemented in hardware, while other aspects may be implemented in firmware or software that may be executed by a controller, microprocessor, or other computing device, but the invention is not limited thereto. Although various aspects of the invention may be shown and described as block diagrams, flow charts, or using some other graphical representation, it should be understood that, as non-limiting examples, the boxes, devices, systems, techniques, or methods described herein may be implemented in hardware, software, firmware, dedicated circuits or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof.
[0094] Embodiments of the present invention may be implemented by computer software that is executable by a data processor of a mobile device, such as in a processor entity, or by hardware, or by a combination of software and hardware. Computer software or programs (also referred to as program products) including software routines, applets and / or macros may be stored in any device-readable data storage medium, and they include program instructions for performing specific tasks. A computer program product may include one or more computer executable components configured to perform an embodiment when the program is run. One or more computer executable components may be at least one software code or a portion thereof. In addition, at this point, it should be noted that, for example, Figure 6 Any block of the logic flow in the program may represent program steps, or interconnected logic circuits, blocks and functions, or a combination of program steps and logic circuits, blocks and functions. The software may be stored on physical media such as memory chips or storage blocks implemented within a processor, magnetic media such as hard disks or floppy disks, and optical media such as, for example, DVDs and their data variants, CDs, etc. Physical media are non-transitory media.
[0095] Those skilled in the art should understand that the technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0096] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for constructing a video water body segmentation model based on a mask autoencoder, characterized in that: The following steps are involved: Obtain at least one video frame sequence containing water bodies as a training sample, and annotate the initial frame in each video frame sequence with water bodies and then input it into the constructed video water body segmentation framework; The video water body segmentation architecture includes a scene encoding module, a spatiotemporal feature aggregation module, and a mask self-encoding-decoding module. The scene encoding module encodes each frame in the video frame sequence to obtain a multi-scale image corresponding to each frame. The spatiotemporal feature aggregation module uses the input current frame as a query, the multi-scale image corresponding to the previous frame of the current frame as a key, and the predicted segmentation result corresponding to the previous frame of the current frame as a value to perform attention calculation to obtain a rough water body segmentation map of the current frame, wherein if the previous frame of the current frame is an initial frame, the water body annotation information of the initial frame is used as the predicted segmentation result of the initial frame; In the mask self-encoding-decoding module, based on the coarse water body segmentation map of the current frame, the multi-scale image corresponding to the current frame and the current frame, the water body features of the current frame are gradually fused with the multi-scale image corresponding to the current frame to obtain a fine water body segmentation map of the current frame, and the fine water body segmentation map of the next frame is obtained by taking the fine water body segmentation map of the current frame as the predicted segmentation result of the next frame until the fine water body segmentation map of each frame image except the initial frame is obtained; The spatiotemporal feature aggregation module then uses the initial frame as a query, and respectively uses a set number of fine water body segmentation maps as keys and multi-scale images corresponding to the keys as values to perform attention calculation to obtain a coarse water body segmentation map of the initial frame, and then the mask self-encoding-decoding module refines the coarse water body segmentation map of the initial frame to obtain a fine water body segmentation map of the initial frame; The loss function is constructed using the fine water body segmentation map of the initial frame and the water body annotation information of the initial frame. When the loss function meets the set conditions, the parameters of the current video water body segmentation architecture are retained to obtain the video water body segmentation model.
2. According to the method for constructing a video water body segmentation model based on a mask autoencoder according to claim 1, it is characterized in that: In the step of "the scene encoding module encodes each frame in the video frame sequence to obtain a multi-scale image corresponding to each frame", the scene encoding module is connected to a plurality of residual structures by a convolutional layer, and the multi-scale image includes feature maps of different sizes output by each residual structure.
3. The method for constructing a video water body segmentation model based on a mask autoencoder according to claim 1, characterized in that: In the step of "taking the multi-scale image corresponding to the previous frame of the current frame as a key", the feature map with the smallest resolution in the multi-scale image corresponding to the previous frame of the current frame is taken as the key.
4. The method for constructing a video water body segmentation model based on a mask autoencoder according to claim 1, characterized in that: The predicted segmentation result is downsampled to the same size as the feature map with the smallest resolution in the multi-scale image and used as the value.
5. The method for constructing a video water body segmentation model based on a mask autoencoder according to claim 1, characterized in that: The mask self-encoding-decoding module includes a mask encoding unit and a mask decoding unit. The mask encoding unit is connected in series by an encoding convolution layer, multiple encoding residual blocks and a feature encoding fusion module. The current frame is first spliced with the rough water body segmentation map of the current frame and then input into the mask encoding unit. After passing through the encoding convolution layer and multiple encoding residual blocks, a first feature map is output. The size of the first feature map is the same as the feature map with the smallest resolution in the multi-scale image, and the number of encoding residual blocks is the same as the number of residual blocks in the scene encoding module. The feature encoding fusion module uses spatial attention and channel attention operations to fuse the first feature map with the feature map with the smallest resolution in the multi-scale image to obtain a first water body feature map.
6. The method for constructing a video water body segmentation model based on a mask autoencoder according to claim 5, characterized in that: The mask decoding unit is composed of a feature decoding fusion unit, multiple upsampling layers and a classification head connected in series. The feature decoding fusion unit is the same as the feature encoding fusion module. In the feature decoding fusion unit, spatial attention and channel attention operations are used to fuse the first water body feature map with the feature map with the smallest resolution in the multi-scale image again to obtain a second water body feature map. Multiple upsampling layers are used to gradually upsample the second water body feature map, and after each upsampling, the upsampling result is used to fuse the feature map of the same size as the upsampling result in the multi-scale image to obtain a third water body feature map. The classification head uses a bilinear interpolation upsampling operation to output the third water body feature map to obtain a fine water body segmentation map of the current frame.
7. A video water body segmentation method, characterized in that: include: A video frame sequence to be segmented is obtained, and the video frame sequence to be segmented is input into the video water body segmentation model trained in claim 1 to obtain a water body segmentation result.
8. A device for constructing a video water body segmentation model based on a mask autoencoder, characterized in that: An acquisition module is used to acquire at least one video frame sequence containing water bodies as a training sample, and annotate the water bodies on the initial frames in each video frame sequence and then input them into the constructed video water body segmentation framework; A scene coding module, wherein the video water body segmentation architecture includes a scene coding module, a spatiotemporal feature aggregation module, and a mask self-coding-decoding module, wherein the scene coding module encodes each frame in a video frame sequence to obtain a multi-scale image corresponding to each frame; A spatiotemporal feature aggregation module, wherein the spatiotemporal feature aggregation module uses the input current frame as a query, uses the multi-scale image corresponding to the previous frame of the current frame as a key, and uses the predicted segmentation result corresponding to the previous frame of the current frame as a value to perform attention calculation to obtain a rough water body segmentation map of the current frame, wherein if the previous frame of the current frame is an initial frame, the water body annotation information of the initial frame is used as the predicted segmentation result of the initial frame; a mask self-encoding-decoding module, in which a water body feature of the current frame is obtained based on a coarse water body segmentation map of the current frame, a multi-scale image corresponding to the current frame, and the current frame, the water body feature of the current frame is gradually fused with the multi-scale image corresponding to the current frame to obtain a fine water body segmentation map of the current frame, and the fine water body segmentation map of the next frame is obtained by taking the fine water body segmentation map of the current frame as a predicted segmentation result of the next frame until a fine water body segmentation map of each frame image except the initial frame is obtained; The initial frame prediction module, the spatiotemporal feature aggregation module uses the initial frame as a query, and respectively uses a set number of fine water body segmentation maps as keys and multi-scale images corresponding to the keys as values to perform attention calculation to obtain a rough water body segmentation map of the initial frame, and then the mask self-encoding-decoding module refines the rough water body segmentation map of the initial frame to obtain a fine water body segmentation map of the initial frame; The loss calculation module uses the fine water body segmentation map of the initial frame and the water body annotation information of the initial frame to construct a loss function. When the loss function meets the set conditions, the parameters of the current video water body segmentation architecture are retained to obtain the video water body segmentation model.
9. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the method for constructing a video water body segmentation model based on a mask autoencoder according to any one of claims 1 to 6 or the method for video water body segmentation according to claim 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which includes a program code for controlling a process to execute a process, wherein the process includes a method for constructing a video water body segmentation model based on a mask autoencoder according to any one of claims 1 to 6 or a video water body segmentation method according to claim 7.
