A foreground segmentation method based on multi-level features and mask fusion
Through the multi-level feature and mask fusion method, combined with low-level and high-level features, the shortcomings of deep learning methods in edge detail segmentation are solved, and the accuracy and comprehensiveness of foreground segmentation are improved, especially when moving targets are small or moving distance In short scenes, the segmentation effect is significantly improved.
Patent Information
- Application Number
- CN202111162124.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-09-30
AI Technical Summary
Existing deep learning methods show insufficient edge detail segmentation capabilities in foreground segmentation, resulting in incomplete boundary segmentation accuracy and incomplete feature extraction. Especially in scenes with small moving targets or short moving distances, the segmentation performance is unsatisfactory.
Using a method based on multi-level feature and mask fusion, through coding and multi-scale feature fusion, low-level features and high-level features are combined, cascade cross-feature layer feature splicing and fusion is used, and different levels of features and corresponding scale masks are used to generate the final Foreground segmentation results.
It improves the accuracy of foreground boundary segmentation and the comprehensiveness of feature extraction, enhances the segmentation effect, especially the performance in difficult scene segments, and improves training efficiency and segmentation quality.
Smart Images

Figure CN113870286B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computational image processing, and in particular to a foreground segmentation method based on multi-level features and mask fusion. Background Art
[0002] Foreground Segmentation is a basic operation in computer image processing and visual effects production. Foreground segmentation refers to segmenting foreground objects of arbitrary shapes from an image. The task of foreground segmentation is to specify which parts of the image are foreground (i.e., the parts that the user wants to extract) and which parts are background. Although the human visual system can easily specify the foreground and background, it is difficult for computers to have this understanding ability without human help. Once the foreground part of the image is separated from the background, it is easy to synthesize it with other background images to obtain a new image.
[0003] In view of the problem that the existing foreground segmentation methods are prone to cause user fatigue, reduce user enthusiasm and interaction quality when processing a large number of images to be segmented, the Chinese patent with publication number CN109712165A discloses "A method for segmenting a set of similar foreground images based on convolutional neural networks", which includes: inputting a set of similar images into a computer; the computer reads one image from the set of similar images to generate a sample segmentation mask; constructing a training data set; learning a segmentation network model; segmenting the remaining images in the set of similar images based on the segmentation network model; if all images have obtained satisfactory segmentation results, the segmentation is completed.
[0004] The foreground image set segmentation method in the above-mentioned existing scheme realizes foreground segmentation through the method of deep learning (convolutional neural network). The deep learning method has universal segmentation performance, can stably extract significant features, and has better results than traditional methods. However, the applicant found that the existing deep learning method showed obvious limitations in edge detail segmentation. Multi-stage convolution pooling will lead to a decrease in the resolution of the final prediction result, and then lose more detail information; the high-level features extracted by the deep network lack high-frequency information for fine edge segmentation, and its lost low-level features are crucial for accurately segmenting boundary details. At the same time, for scenes with difficult foreground segmentation, such as scenes with small moving targets or short moving distances, the segmentation performance of the existing deep learning method is not ideal. If only high-level features are used, the segmented edges are not accurate; if only low-level features are used, it is easy to cause the segmentation target to be missed, resulting in poor boundary segmentation accuracy and feature extraction comprehensiveness during foreground segmentation. Therefore, how to design a foreground segmentation method that can improve the accuracy of boundary segmentation and the comprehensiveness of feature extraction is a technical problem that needs to be solved urgently. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the technical problem to be solved by the present invention is: how to provide a foreground segmentation method that can improve the accuracy of boundary segmentation and the comprehensiveness of feature extraction, thereby improving the segmentation effect of foreground segmentation.
[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0007] A foreground segmentation method based on multi-level feature and mask fusion, which encodes the original image to be classified and fuses multi-scale features, and then realizes foreground segmentation in the decoding stage by fusing low-level features with high-level features, cascading cross-feature layer feature splicing and fusion, and fusing different levels of features and corresponding scale masks, to obtain the foreground segmentation result of the original image to be classified.
[0008] Preferably, the foreground segmentation method specifically comprises the following steps:
[0009] S1: Encode the original image to be classified to obtain the corresponding high-level features and low-level features;
[0010] S2: Perform multi-scale feature fusion on the high-level features to obtain a corresponding multi-scale feature map;
[0011] S3: splicing the high-level feature and the multi-scale feature map to obtain a corresponding first prediction mask; then fusing the high-level feature, the multi-scale feature map and the first prediction mask to obtain a corresponding first fused feature;
[0012] S4: upsampling the first fused feature to obtain a corresponding first fused feature map; then concatenating the first fused feature map with the low-level feature to obtain a corresponding second prediction mask; finally, fusing the first fused feature map, the low-level feature and the second prediction mask to obtain a corresponding second fused feature;
[0013] S5: upsampling the second fused feature to obtain a corresponding second fused feature map; then generating a corresponding final prediction mask based on the second fused feature map; and finally generating a foreground segmentation result of the original image to be classified based on the final prediction mask.
[0014] Preferably, in step S1, encoding is performed by a set encoder; the encoder uses a ResNet-50 network as a backbone network and removes the last fully connected layer of the ResNet-50 network, including four layers of residual blocks cascaded in sequence; the output of the first layer of residual blocks of the encoder is a low-level feature, and the output of the fourth layer of residual blocks is a high-level feature.
[0015] Preferably, the output stride OS of the fourth-layer residual block of the encoder is 16, the convolution step size is 1, and the expansion rate is 2.
[0016] Preferably, in step S2, multi-scale feature fusion is performed by setting a multi-scale feature fusion module; the multi-scale feature fusion module includes five branch layers connected in parallel at the input end: a 1x1 convolution layer, three 3x3 convolution layers and a global average pooling layer;
[0017] After the high-level features are input into the five branch layers of the multi-scale feature fusion module, the output results of each branch layer are connected in parallel to obtain a multi-scale feature map.
[0018] Preferably, the three 3x3 convolutional layers of the multi-scale feature fusion module are hole convolutional layers with expansion rates of 4, 8, and 12; and the global average pooling layer is used to merge the global context information of the original image to be classified.
[0019] Preferably, in steps S3 to S5, a final prediction mask is generated by a set decoder; the decoder is a cascade structure, and each current-level fusion feature map is obtained by upsampling the fusion features obtained by fusion at the previous level; the sizes of the first prediction mask, the second prediction mask and the final prediction mask generated by the decoder are (W / 16, H / 16), (W / 4, H / 4), (W, H), respectively, and the output stride OS is 16, 4, and 1, respectively.
[0020] Preferably, the fusion feature obtained by the current stage fusion of the decoder is expressed as:
[0021] F′=Conv{Concat(F,features,mask)};
[0022] In the above formula: F′ represents the fused features of the current level; F represents the fused feature map generated by upsampling the fused features of the previous level; features represents the high-level features or low-level features output by the encoder; mask represents the prediction mask generated by the current level.
[0023] Preferably, before the high-level features, the low-level features and the multi-scale feature map are input into the decoder, the spatial dimensions of the high-level features, the low-level features and the multi-scale feature map are first mapped to be consistent with the output features of the encoder through a set 1x1 convolution.
[0024] Preferably, the decoder is optimized by training loss; the training loss includes cross entropy loss corresponding to output stride OS of 16 and 4, and normalized L2 loss corresponding to output stride OS of 1;
[0025] The training loss is calculated by the following formula:
[0026]
[0027] In the above formula: L represents the training loss; represents the cross entropy loss corresponding to an output stride OS of 16; represents the cross entropy loss corresponding to an output stride OS of 4; represents the L2 loss corresponding to an output stride OS of 1 and normalized.
[0028] Compared with the prior art, the foreground segmentation method in the present invention has the following beneficial effects:
[0029] The present invention extracts detailed features of an image by fusing high-level features with low-level features, wherein high-level features determine the basic outline of the foreground, and low-level features optimize the details of the segmentation. Under the guidance of a mask based on feature fusion, larger error areas are repaired, local boundaries are gradually improved and corrected, and the accuracy of foreground boundary segmentation is improved, thereby improving the segmentation effect of foreground segmentation.
[0030] The present invention gradually refines the boundary of the segmentation result by cascading cross-feature layer feature splicing and fusion, thereby progressively improving the segmentation quality; by fusing features of different levels and masks of different scales, the fused features not only contain semantic information, but also introduce certain underlying details.
[0031] The present invention fuses semantic features from different levels of the encoder backbone network through the decoder, which is conducive to collecting global and local features, so that the fused features are regressed together with the corresponding prediction masks to achieve segmentation performance, and the cascade design allows capturing more edge details, thereby improving the comprehensiveness of feature extraction.
[0032] The present invention learns foreground objects from isolated frames without considering temporal data, and thus can learn fine foreground segmentation using a small number of frames, which not only improves the training efficiency of foreground segmentation, but also makes the effect of segmenting difficult scenes outstanding. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to make the purpose, technical solution and advantages of the invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings, in which:
[0034] Figure 1 is a basic flow chart of the foreground segmentation method in the embodiment;
[0035] Figure 2 is a schematic diagram of a network structure of a foreground segmentation method in an embodiment;
[0036] Figure 3 is a logic block diagram of a foreground segmentation method in an embodiment;
[0037] Figure 4It is a qualitative comparison between the foreground segmentation model proposed in the embodiment and the existing methods;
[0038] Figure 5 is the test result of the foreground segmentation model proposed in the embodiment obtained in the CDnet2014 dataset;
[0039] Figure 6 It is a performance comparison between the foreground segmentation model proposed in the embodiment and the existing methods. DETAILED DESCRIPTION
[0040] The following is a further detailed description through specific implementation methods:
[0041] Example:
[0042] This embodiment discloses a foreground segmentation method based on multi-level features and mask fusion.
[0043] like Figure 1 As shown in the figure, the foreground segmentation method based on multi-level features and mask fusion encodes the original image to be classified and fuses the multi-scale features. Then, in the decoding stage, foreground segmentation is achieved by fusing low-level features with high-level features, cascading cross-feature layer feature splicing and fusion, and fusing different levels of features with corresponding scale masks, so as to obtain the foreground segmentation result of the original image to be classified.
[0044] Combination Figure 2 and Figure 3 As shown, the specific steps include:
[0045] S1: Encode the original image to be classified to obtain the corresponding high-level features and low-level features;
[0046] S2: Perform multi-scale feature fusion on high-level features to obtain the corresponding multi-scale feature map;
[0047] S3: concatenate the high-level features and the multi-scale feature map to obtain a corresponding first prediction mask; then fuse the high-level features, the multi-scale feature map and the first prediction mask to obtain a corresponding first fused feature;
[0048] S4: upsampling the first fused feature to obtain a corresponding first fused feature map; then concatenating the first fused feature map with the low-level feature to obtain a corresponding second prediction mask; finally, fusing the first fused feature map, the low-level feature and the second prediction mask to obtain a corresponding second fused feature;
[0049] S5: upsampling the second fused feature to obtain a corresponding second fused feature map; then generating a corresponding final prediction mask based on the second fused feature map; and finally generating a foreground segmentation result of the original image to be classified based on the final prediction mask.
[0050] In the present invention, the detailed features of the image are extracted by fusing high-level features and low-level features, wherein the high-level features determine the basic outline of the foreground, the low-level features optimize the details of the segmentation, and under the guidance of the mask based on feature fusion, the larger error area is repaired, the local boundary is gradually improved and corrected, and the accuracy of the foreground boundary segmentation is improved, thereby improving the segmentation effect of the foreground segmentation. At the same time, the present invention gradually refines the boundary of the segmentation result by cascading cross-feature layer feature splicing and fusion, and gradually improves the segmentation quality; by fusing different levels of features and different scale masks, the fused features not only contain semantic information, but also introduce certain underlying details. In addition, the present invention fuses semantic features from different levels of the encoder backbone network through the decoder, which is conducive to collecting global and local features, so that the fused features regress the segmentation performance together with the corresponding prediction mask, and the cascade design allows more edge details to be captured, thereby improving the comprehensiveness of feature extraction. Finally, the present invention learns the foreground object from the isolated frame without considering the time data, and then uses a small number of frames to learn the fine foreground segmentation, which can not only improve the training efficiency of the foreground segmentation, but also make the effect of segmenting difficult scenes outstanding.
[0051] In the specific implementation process, encoding is performed through a set encoder; the encoder uses the ResNet-50 network as the backbone network and removes the last fully connected layer of the ResNet-50 network, including four layers of residual blocks cascaded in sequence; the output of the first layer of residual blocks of the encoder is low-level features, and the output of the fourth layer of residual blocks is high-level features. Specifically, the output stride OS of the fourth layer of residual blocks of the encoder is 16, the convolution step is 1, and the expansion rate is 2.
[0052] The output stride OS (OS refers to the ratio of the input image spatial resolution to the final output resolution) of the original ResNet-50 network is 32. A larger output stride OS will result in the loss of feature map resolution, making it difficult for the subsequent decoder to restore the underlying details through upsampling. Therefore, the present invention uses a smaller output stride OS and sets the corresponding convolution step size and expansion rate, which can further improve the accuracy of foreground boundary segmentation.
[0053] In the specific implementation process, multi-scale feature fusion is performed through the multi-scale feature fusion module; the multi-scale feature fusion module includes five branch layers connected in parallel at the input end: a 1x1 convolution layer, three 3x3 convolution layers and a global average pooling layer; after the high-level features are input into the five branch layers of the multi-scale feature fusion module, the output results of each branch layer are connected in parallel to obtain a multi-scale feature map. Specifically, the three 3x3 convolution layers of the multi-scale feature fusion module are hole convolution layers with expansion rates of 4, 8, and 12; the global average pooling layer is used to merge the global context information of the original image to be classified.
[0054] In the present invention, multi-scale information is captured through the global average pooling layer and the hole convolution layer, and the output results of all branches are connected in parallel, so that a larger receptive field can be obtained without losing too much resolution, thereby reducing the amount of calculation and ensuring the resolution.
[0055] In the specific implementation process, the final prediction mask is generated by the set decoder; the decoder is a cascade structure, and each current-level fusion feature map is obtained by upsampling the fusion feature obtained by the previous level fusion; the sizes of the first prediction mask, the second prediction mask, and the final prediction mask generated by the decoder are (W / 16, H / 16), (W / 4, H / 4), and (W, H), respectively, and the output stride OS is 16, 4, and 1, respectively. Specifically, the fusion feature obtained by the current-level fusion of the decoder is expressed as:
[0056] F′=Conv{Concat(F,features,mask)};
[0057] In the above formula: F′ represents the fused features of the current level; F represents the fused feature map generated by upsampling the fused features of the previous level; features represents the high-level features or low-level features output by the encoder; mask represents the prediction mask generated by the current level.
[0058] In the present invention, a multi-scale prediction mask is set and fused with features at different levels (especially the fusion of low-level features and fine masks), so that the fused features not only contain semantic information, but also introduce certain underlying details. The optimization of the network occurs not only at the top level but also at the bottom level, thereby being able to obtain more image boundary details and contextual semantic information.
[0059] In the specific implementation process, before inputting high-level features, low-level features and multi-scale feature maps into the decoder, the spatial dimensions of high-level features, low-level features and multi-scale feature maps are first mapped to be consistent with the output features of the encoder through the set 1x1 convolution. This makes the fusion effect between high-level features and low-level features, and high-level features and multi-scale feature maps better, thereby improving the effect of foreground segmentation.
[0060] In the specific implementation, the decoder is optimized by training loss; the training loss includes cross entropy loss corresponding to output stride OS of 16 and 4, and normalized L2 loss corresponding to output stride OS of 1;
[0061] The training loss is calculated using the following formula:
[0062]
[0063] In the above formula: L represents the training loss; represents the cross entropy loss corresponding to an output stride OS of 16; represents the cross entropy loss corresponding to an output stride OS of 4; represents the L2 loss corresponding to an output stride OS of 1 and normalized.
[0064] In the present invention, different training losses correspond to different output strides OS, so that coarse refinement focuses on global information and ignores local details, and the finest refinement aims to achieve pixel-level accuracy by relying on local clues, thereby taking into account both the accuracy of foreground boundary segmentation and the comprehensiveness of feature extraction.
[0065] This embodiment uses an original image (W, H, 3) as the original image to be classified for illustration:
[0066] After the original image is passed through the encoder and multi-scale feature fusion module, the output multi-scale feature map F16 is (W / 16, H / 16, 256). The output of the first layer residual block of the encoder is convolved with 1x1 to obtain the low-level feature f4 of (W / 4, H / 4, 256), and the output of the fourth layer residual block is convolved with 1x1 to obtain the high-level feature f16 of (W / 16, H / 16, 256).
[0067] First, concatenate F16 and f16 and then perform 1x1 convolution to get the first prediction mask mask16 (W / 16, H / 16, 1). Since the receptive fields of F16 and f16 are both large, mask16 is more of a global judgment of the image without local exploration, which is a rough prediction. Although the prediction of mask16 is not precise enough, it can provide guidance for the next prediction.
[0068] F16, f16 and mask16 are fused to obtain the first fused feature F16′, and F16′ is upsampled to obtain the first fused feature map F4 with a dimension of (W / 4, H / 4, 256).
[0069] Concatenate F4 and f4 and then perform 1x1 convolution to obtain the second prediction mask mask4 (W / 4, H / 4, 1); fuse F4, f4 and mask4 to obtain the second fusion feature F4′. The segmentation of mask4 is more detailed than mask16, which proves the effectiveness of gradual fusion.
[0070] F4′ is upsampled to obtain the second fused feature map F1 with a dimension of (W, H, 256), and the corresponding final prediction mask mask1 is generated based on F1 (Sigmoid activation is not used).
[0071] In order to better illustrate the advantages of the foreground segmentation method in the present invention, the following experiment is disclosed in this embodiment.
[0072] 1. Dataset
[0073] The public dataset CDnet2014 for image foreground object segmentation with annotations is selected, which is widely used in foreground / background segmentation research. There are a total of 150,000 frames of pixel-level annotation data for 11 categories and 53 scenes. The 11 categories include badWeather, baseline, cameraJitter, dynamicBackground, shadow, nightVideos, lowFramerate, thermal, PTZ, intermittentObjectMotion and turbulence. Each category contains 4 to 6 video sequences, each video sequence contains 600 to 7999 frames, and the spatial resolution ranges from 320×240 to 720×576. In addition, the dataset covers a variety of challenging scenes, such as lighting changes, hard shadows, high dynamic background motion, and camera motion.
[0074] 2. Model Training
[0075] In this experiment, a foreground segmentation model (CFMFN) containing the above encoder, multi-scale feature fusion module and decoder was constructed using the PyTorch framework. The model maintained the pre-trained weights of the original ResNet-50 network. In the process of supervised training for the constructed foreground segmentation model, the parameters were initialized first. During the initialization process, the feature extraction backbone network was initialized using the ResNet-50 pre-trained on the ImageNet large-scale classification dataset. Two sets of experiments were conducted in each scene, with 50 frames and 200 frames selected as the training set, and the rest as the test set. After the training set was shuffled, a 20% validation split was performed, so 80% of the training examples were used to train the model. The learning rate was set to 0.001, the training rounds were set to 100, the momentum was set to 0.9, and the batch size was set to 32. An early stopping mechanism was designed for training up to 60 epochs. When the comprehensive performance index of the validation set, i.e., FM, no longer improved within 20 rounds, the training would end early. Due to the high imbalance between background / foreground pixels in the scene, balanced weights were used during the training process to alleviate the problem of unbalanced data classification. Furthermore, since the output of the Sigmoid activation is in the range [0, 1], it is used as the probability value; a threshold of 0.5 is applied to obtain discrete binary class labels as foreground and background.
[0076] In this experiment, the foreground segmentation model was trained for a total of 24,500 iterations, and the total training time on a single RTX2080 GPU was approximately 7 hours.
[0077] 3. Evaluation indicators
[0078] This experiment uses seven official indicators provided by the CDnet2014 dataset (i.e., recall (Re), precision (Pr), specificity (Sp), false negative rate (FRN), false positive rate (FNR), percentage of misclassification (PWC), and F-Measure (FM)) to evaluate the performance of CFMFN. Among them, FM is a comprehensive performance indicator for the performance ranking of CDnet2014 methods, so this experiment uses it as the main indicator for CFMFN performance evaluation.
[0079] 4. Baseline
[0080] Combination Figure 4 As shown in the figure, the foreground segmentation model of this experiment will be compared with the best algorithm reported on the official website of CDnet2014 to evaluate its segmentation performance. These models are divided into two categories: 1) Traditional methods, three typical traditional methods IUTIS-5, WeSamBE, and GMM-Stauffer are selected for comparison; 2) Deep learning methods, five advanced deep learning algorithms FgSegNet_v2, FgSegNet, BSPVGan, Cascade CNN, and DeepBS are selected for comparison.
[0081] V. Experimental Results
[0082] Since different algorithms have different training frame numbers and traditional algorithms do not require training sets, in order to compare the number of frames, this experiment uses all the Groundtruth (real results of foreground segmentation) provided by the CDnet2014 dataset to test the foreground segmentation model of the present invention. From the obtained data, the FM value based on the deep learning method is much higher than that of the traditional model, especially in challenging categories such as PTZ (camera motion) and nightVideos (low light at night).
[0083] This experiment only uses test frames for calculation, that is, training frames are not included in the performance evaluation. The result values are as follows Figure 5 As shown, each row shows the average result of each category, and the last row shows the average result of 11 categories. Under the above settings, the foreground segmentation model of the present invention generates a FM of 0.9510 in the 50-frame experiment and a FM of 0.9750 in the 200-frame experiment.
[0084] The foreground segmentation model of the present invention provides high-precision foreground segmentation in training with 200 frames. Compared with other categories, the baseline produces the highest average FM of 0.9955, and the lowFramrate has the lowest average FM, which reaches 0.8933. Comparing only the test frame results, the best models FgSegNet_v2 and FgSegNet reported on the official website of CDnet2014 have FM values of 0.8897 and 0.8816 on the lowFramrate dataset, respectively.
[0085] It can be seen that the performance of the foreground segmentation model in the present invention is significantly improved.
[0086] When the number of training samples is reduced from 200 to 50 frames, FM inevitably decreases. In particular, for the nightVideos category, FM is reduced by 0.0546 compared to the model with a training set of 200 frames. However, it still produces acceptable results, with an average total FM of 0.9510 for 11 categories, indicating that the foreground segmentation model of the present invention can work stably in challenging scenes.
[0087] Depend on Figure 6 It can be seen that the FM of the foreground segmentation model of the present invention is 0.71% and 0.13% higher than FgSegNet_v2 in the lowFramerate and turbulence categories, respectively, but slightly worse than FgSegNet_v2 in other data sets, with a slight gap of 0.22% in overall performance. The overall performance of the foreground segmentation model of the present invention is 0.03% higher than that of FgSegNet in the badWeather, dynamicBackground, lowFramerate, PTZ, and turbulence categories. In other words, the foreground segmentation model of the present invention has improved segmentation performance in more categories of scenes compared with other advanced algorithms, especially significantly improving the segmentation performance of difficult categories (i.e., lowFramerate, whose category scenes have small moving targets and short moving distances).
[0088] Compared with FgSegNet, BSPVGan, Cascade CNN, IUTIS-5, WeSamBE, DeepBS, and GMM-Stauffer, the overall FM of the foreground segmentation model of the present invention is improved by 0.03%, 3.67%, 5.69%, 24.78%, 22.75%, 20.48%, and 37.28%, respectively. In other words, in terms of overall performance (especially robustness and effectiveness), the foreground segmentation model of the present invention is not only superior to traditional unsupervised methods, but also superior to other supervised deep learning methods.
[0089] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit them. Although the present invention has been described with reference to the preferred embodiments of the present invention, it should be understood by those skilled in the art that various changes can be made to it in form and detail without departing from the spirit and scope of the present invention as defined in the appended claims. At the same time, common sense such as the well-known specific structures and characteristics in the embodiments are not described in detail here. Finally, the scope of protection claimed by the present invention shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.
Claims
1. A foreground segmentation method based on multi-level features and mask fusion, characterized in that: After encoding and fusing multi-scale features of the original image to be classified, foreground segmentation is achieved in the decoding stage by fusing low-level features with high-level features, cascading cross-feature layer feature splicing and fusion, and fusing different levels of features with corresponding scale masks, thus obtaining the foreground segmentation result of the original image to be classified. The method specifically comprises the following steps: S1: Encode the original image to be classified to obtain the corresponding high-level features and low-level features; S2: Perform multi-scale feature fusion on the high-level features to obtain a corresponding multi-scale feature map; S3: splicing the high-level feature and the multi-scale feature map to obtain a corresponding first prediction mask; then fusing the high-level feature, the multi-scale feature map and the first prediction mask to obtain a corresponding first fused feature; S4: upsampling the first fused feature to obtain a corresponding first fused feature map; then concatenating the first fused feature map with the low-level feature to obtain a corresponding second prediction mask; finally, fusing the first fused feature map, the low-level feature and the second prediction mask to obtain a corresponding second fused feature; S5: upsampling the second fused feature to obtain a corresponding second fused feature map; and then generating a corresponding final prediction mask based on the second fused feature map; Finally, a foreground segmentation result of the original image to be classified is generated based on the final prediction mask.
2. The foreground segmentation method based on multi-level features and mask fusion as claimed in claim 1, characterized in that: In step S1, encoding is performed by a set encoder; the encoder uses the ResNet-50 network as the backbone network and removes the last fully connected layer of the ResNet-50 network, including four layers of residual blocks cascaded in sequence; the output of the first layer of residual blocks of the encoder is a low-level feature, and the output of the fourth layer of residual blocks is a high-level feature.
3. The foreground segmentation method based on multi-level features and mask fusion as claimed in claim 2, characterized in that: The output stride OS of the fourth-layer residual block of the encoder is 16, the convolution step size is 1, and the expansion rate is 2.
4. The foreground segmentation method based on multi-level features and mask fusion as claimed in claim 1, characterized in that: In step S2, multi-scale feature fusion is performed by setting a multi-scale feature fusion module; the multi-scale feature fusion module includes five branch layers connected in parallel at the input end: a 1x1 convolution layer, three 3x3 convolution layers and a global average pooling layer; After the high-level features are input into the five branch layers of the multi-scale feature fusion module, the output results of each branch layer are connected in parallel to obtain a multi-scale feature map.
5. The foreground segmentation method based on multi-level features and mask fusion as claimed in claim 4, characterized in that: The three 3x3 convolutional layers of the multi-scale feature fusion module are hole convolutional layers with expansion rates of 4, 8, and 12; the global average pooling layer is used to merge the global context information of the original image to be classified.
6. The foreground segmentation method based on multi-level features and mask fusion as claimed in claim 1, characterized in that: In steps S3 to S5, a final prediction mask is generated by a set decoder; The decoder has a cascade structure, and each fused feature map of the current level is obtained by upsampling the fused features obtained by fusion of the previous level; the sizes of the first prediction mask, the second prediction mask and the final prediction mask generated by the decoder are (W / 16, H / 16), (W / 4, H / 4), (W, H), respectively, and the output stride OS is 16, 4, and 1, respectively.
7. The foreground segmentation method based on multi-level features and mask fusion as claimed in claim 6, characterized in that: The fusion feature obtained by the current stage fusion of the decoder is expressed as: F′=Conv{Concat(F,features,mask)}; In the above formula: F′ represents the fusion feature of the current level; F represents the fusion feature map generated by upsampling the fusion feature of the previous level; features represents the high-level features or low-level features output by the encoder; mask represents the prediction mask generated by the current stage.
8. The foreground segmentation method based on multi-level features and mask fusion as claimed in claim 6, characterized in that: Before the high-level features, the low-level features, and the multi-scale feature map are input into the decoder, the spatial dimensions of the high-level features, the low-level features, and the multi-scale feature map are mapped to be consistent with the output features of the encoder through a set 1x1 convolution.
9. The foreground segmentation method based on multi-level features and mask fusion as claimed in claim 6, characterized in that: Optimizing the decoder by training loss; the training loss includes cross entropy loss corresponding to output stride OS of 16 and 4, and normalized L2 loss corresponding to output stride OS of 1; The training loss is calculated by the following formula: In the above formula: L represents the training loss; represents the cross entropy loss corresponding to an output stride OS of 16; represents the cross entropy loss corresponding to an output stride OS of 4; represents the L2 loss corresponding to an output stride OS of 1 and normalized.
