An image segmentation method based on MaskFormer network
By introducing a network for refining difficult regions and an end-to-end training method, the problem of insufficient segmentation quality of Transformer in details is solved, and efficient image segmentation results are achieved, especially for fine processing of regions such as edges, corners, thin strips and hollow areas.
Patent Information
- Application Number
- CN202410652993.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2044-05-24
AI Technical Summary
Existing Transformer-based entity segmentation methods suffer from insufficient segmentation quality at detailed levels, and independent two-stage optimization methods are difficult to apply in practical engineering, resulting in low efficiency.
A network for refining difficult regions is introduced, including a difficult region extraction module, a difficult region sequence extraction module, and an encoder. Through feature extraction and multi-level feature fusion, the segmentation quality of difficult regions is optimized, and an end-to-end training method and a dual supervision mechanism are adopted.
It improves the quality of details in image segmentation, enhances computational efficiency, and can efficiently handle difficult areas such as edges, corners, thin strips, and hollow areas, making it suitable for high-precision image segmentation tasks.
Smart Images

Figure CN118470323B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image segmentation technology, and in particular to an image segmentation method based on neural networks. Background Technology
[0002] Image segmentation is a major research area in computer vision, with wide applications in daily life, industry, and the military. Image segmentation can be further divided into semantic segmentation, instance segmentation, panoptic segmentation, and entity segmentation. Semantic segmentation aims to classify all pixels in an image to obtain masks for each category; instance segmentation segments the "thing" category (categories with instances, such as people, cats, and dogs), requiring differentiation not only between different categories but also between different instances within each category; panoptic segmentation achieves instance-level segmentation for the "thing" category and semantic-level segmentation for the "stuff" category (categories where instances cannot be distinguished, such as the sky and the sea); entity segmentation aims to obtain category-independent segmentation masks, focusing on the open world, and therefore has stronger segmentation capabilities for unseen categories.
[0003] Transformer-based entity segmentation methods significantly improve overall segmentation accuracy compared to convolutional networks. However, the segmentation results of these methods are still too coarse, and the segmentation quality for details such as edges, corners, thin strips, and cutouts needs further improvement. Some methods, such as CascadePSP and CRM, have proposed using independent second-stage refine networks to further improve segmentation quality. These methods first obtain the initial image segmentation result through a first-stage network, then concatenate each mask of the segmentation result with the image and input it into another network for re-prediction. This type of method optimizes each mask individually, which is time-consuming and often difficult to apply in practical engineering. Summary of the Invention
[0004] In view of this, the purpose of this invention is to propose an image segmentation method based on MaskFormer network, which can effectively guarantee the segmentation quality at the details while maintaining computational efficiency.
[0005] According to one aspect of the present invention, an image segmentation method based on a MaskFormer network is provided, comprising:
[0006] The MaskFormer network includes at least one hard region refinement network, which includes a hard region extraction module, a hard region sequence extraction module, and an encoder.
[0007] Obtain several mask embeddings and per-pixel embeddings of the image data to be processed;
[0008] The difficult region extraction module is used to perform feature extraction on the per-pixel embeddings to obtain a difficult region map of the image;
[0009] Based on the difficult region map, difficult regions in the image are identified. The difficult region sequence extraction module is used to perform feature extraction on the difficult regions to obtain multi-level features of the difficult regions. The multi-level features are then combined with several mask embeddings to obtain image sequence features.
[0010] The image sequence features are thinned using an encoder to obtain image thinning features;
[0011] The image thinning features are input into the MaskFormer network, and the per-pixel embeddings are replaced before the image segmentation operation continues.
[0012] The proposed image segmentation method based on the MaskFormer network in the above technical solution effectively addresses the problem of insufficient segmentation quality in handling details in current image segmentation methods by introducing a difficult region refinement network. It optimizes small, difficult regions using multi-level features, completing the optimization of the entire image at the feature level in one step. Compared to independent two-stage optimization methods that re-predict each segmentation result individually, this method significantly improves efficiency. It has high practical value and application prospects.
[0013] In some embodiments, the difficult region includes a sparse region.
[0014] In the above technical solution, the difficult areas are details such as edges, corners, thin strips, and hollows. Compared with the whole image, these areas have a small pixel ratio and are sparse. Therefore, extracting from these difficult areas is much more efficient than extracting from the whole image directly.
[0015] In some embodiments, the difficult region extraction module is used to perform feature extraction on the per-pixel embeddings to obtain a difficult region map of the image, including:
[0016] The per-pixel embeddings are input into two convolutional layers to obtain convolutional per-pixel embeddings. Feature extraction is performed on the convolutional per-pixel embeddings based on the sigmoid activation function to obtain the hard region map of the image.
[0017] The above technical solution provides a simple and effective way to obtain hard region maps of images, thus providing important information support for subsequent processing. This method leverages the image processing capabilities of convolutional neural networks, using a combination of two convolutional layers and a sigmoid activation function to intuitively transform per-pixel embeddings into hard region maps. This design is simple, intuitive, and easy to understand and implement. This method directly embeds the feature extraction process into the entire network training process, achieving end-to-end processing. This allows the network to automatically learn and optimize the feature extraction process, thereby better adapting to different data and tasks.
[0018] In some embodiments, difficult regions in an image are determined based on the difficult region map, and feature extraction is performed on the difficult regions using the difficult region sequence extraction module to obtain multi-level features of the difficult regions. These multi-level features are then combined with several mask embeddings to obtain image sequence features, including:
[0019] From the image data to be processed, the backbone, pixel decoder and per-pixel embeddings in the MaskFormer network, the multi-level features of each pixel in the difficult region are obtained by sampling, and the dimension of the multi-level features is compressed to the same dimension as the per-pixel embeddings by convolution.
[0020] Several mask embeddings are aggregated with compressed multi-level features to form image sequence features.
[0021] The above technical solution has the following advantages:
[0022] (1) Multi-level feature extraction: Through the difficult region sequence extraction module, we can obtain multi-level features of each pixel from the difficult region map. These features include information at different levels, from local to global, from low level to high level, enabling the network to understand the difficult regions in the image more comprehensively.
[0023] (2) Sampling and Compression: Sampling can effectively obtain multi-level features of each pixel in difficult regions, while convolutional compression can adjust the dimensions of these features to be the same as those of per-pixel embeddings for subsequent processing. This sampling and compression strategy can reduce computational complexity and improve processing efficiency while retaining key information.
[0024] (3) The mask embeddings are aggregated with the compressed multi-level features to form image sequence features. This integrates information from different sources, enhances the network's overall understanding of the image, and helps improve segmentation quality and accuracy.
[0025] In summary, through the above steps, we obtained image sequence features that contain a comprehensive and detailed description of difficult regions, while also incorporating information from mask embeddings. This comprehensive feature representation can better guide the network's learning process, improving the accuracy and robustness of image segmentation.
[0026] In some embodiments, the image thinning features are input into the MaskFormer network, and the image segmentation operation is continued after the per-pixel embeddings are replaced, including:
[0027] The per-pixel embeddings are upsampled to the original image, and the per-pixel embeddings corresponding to the difficult regions are replaced with image thinning features to obtain refined per-pixel embeddings.
[0028] The image segmentation operation continues based on the refined per-pixel embeddings.
[0029] In the above technical solution, upsampling and replacement processing can directly integrate the feature information obtained by the network after refining difficult regions into the original per-pixel embeddings. The resulting refined per-pixel embeddings contain information about the image refining features while maintaining the spatial structure and resolution of the original per-pixel embeddings. This processing preserves the network's segmentation ability at the original pixel level while enhancing the expression and understanding of details.
[0030] According to another aspect of the present invention, a training method for a MaskFormer network is provided, the MaskFormer network including at least one hard region refinement network, the hard region refinement network including a hard region extraction module, a hard region sequence extraction module, and an encoder;
[0031] Obtain at least one training image data;
[0032] Obtain the segmentation ground truth labels and hard region ground truth labels of the training image data;
[0033] The MaskFormer network is used to perform feature extraction on the training image data to obtain several mask embeddings and per-pixel embeddings.
[0034] The difficult region extraction module is used to perform feature extraction on the per-pixel embeddings to obtain a difficult region map of the image;
[0035] Based on the difficult region map, difficult regions in the image are identified. The difficult region sequence extraction module is used to perform feature extraction on the difficult regions to obtain multi-level features of the difficult regions. The multi-level features are then combined with several mask embeddings to obtain image sequence features and predicted labels for the difficult regions.
[0036] Based on the predicted labels and the true labels of the difficult regions, a first loss value is calculated, and the difficult region extraction module is trained based on the first loss value.
[0037] The image sequence features are thinned using an encoder to obtain image thinning features;
[0038] The image thinning features are input into the MaskFormer network, and after the per-pixel embeddings are replaced, the image segmentation operation is continued. After image segmentation, the segmentation result of the training image data is obtained.
[0039] The segmentation prediction result and the segmentation true label are matched based on the bipartite graph matching method.
[0040] The second loss value is calculated based on the matching results, and
[0041] The MaskFormer network is trained based on the second loss value.
[0042] The above technical solution and training method have the following advantages:
[0043] (1) Refinement processing: The network enhances the network's ability to understand and segment details by extracting and refining features of difficult regions.
[0044] (2) Dual supervision: Two loss values (first loss value and second loss value) are used to train the difficult region refinement network and the overall segmentation network respectively, which provides a more comprehensive supervision signal and helps to improve the overall performance of the network.
[0045] (3) High-efficiency optimization: The calculation method based on bipartite graph matching enables the network to optimize the matching between the segmentation results and the real labels more efficiently, further improving the segmentation accuracy.
[0046] (5) Through end-to-end training methods and dual supervision mechanisms, this invention improves training efficiency and effectiveness, enabling the network to converge faster and achieve excellent segmentation performance.
[0047] According to another aspect of the present invention, a MaskFormer network is provided, the MaskFormer network being configured to acquire a plurality of mask embeddings and per-pixel embeddings of image data to be processed, and to segment the image data;
[0048] Also includes:
[0049] At least one hard region refinement network, the hard region refinement network comprising:
[0050] The difficult region extraction module is configured to perform feature extraction operations on the per-pixel embeddings to obtain a difficult region map of the image;
[0051] The difficult region sequence extraction module is configured to determine the difficult regions in the image based on the difficult region map, perform feature extraction operations on the difficult regions to obtain multi-level features of the difficult regions, and combine the multi-level features with several mask embeddings to obtain image sequence features.
[0052] The encoder is configured to refine the image sequence features to obtain image refinement features and input them into the MaskFormer network.
[0053] In the above technical solution, by introducing a network to refine difficult regions, the MaskFormer network can not only accurately segment general regions in an image, but also significantly improve its ability to handle difficult regions. This design improves the overall image segmentation effect while paying special attention to detail processing, making it suitable for various application scenarios requiring high-precision image segmentation.
[0054] According to another aspect of the present invention, an image segmentation apparatus based on a MaskFormer network is provided, based on the above-described method; comprising sequentially connected:
[0055] The acquisition module is used to acquire several mask embeddings and per-pixelelembeddings of the image data to be processed;
[0056] The first feature module is used to perform feature extraction on the per-pixel embeddings using the difficult region extraction module to obtain a difficult region map of the image;
[0057] The second feature module is used to determine the difficult regions in the image based on the difficult region map, use the difficult region sequence extraction module to perform feature extraction on the difficult regions to obtain multi-level features of the difficult regions, and combine the multi-level features with several mask embeddings to obtain image sequence features.
[0058] The third feature module is used to refine the image sequence features using an encoder to obtain image refinement features;
[0059] The segmentation module is used to input the image thinning features into the MaskFormer network, replace the per-pixelembeddings, and then continue to perform the image segmentation operation.
[0060] In order to better utilize the above method, this application proposes an image segmentation device based on the MaskFormer network. Each module corresponds to a step of the above method, and its specific principle has been described above and will not be repeated here.
[0061] According to another aspect of the present invention, an image segmentation device based on a MaskFormer network is provided, comprising:
[0062] At least one processor and a memory communicatively connected to said at least one processor;
[0063] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method described above.
[0064] In the above technical solution, to better operate and process the method, the method is stored in memory, and the stored method is executed by a processor. It should be noted that the principle and effect of each step have been described above and will not be elaborated upon here.
[0065] According to another aspect of the present invention, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the above-described method.
[0066] In the above technical solution, to better operate and use the method, the method is stored in a computer-readable storage medium and implemented using a processor. It should be noted that the principle and effect of each step have been described above and will not be elaborated upon here. Attached Figure Description
[0067] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0068] Figure 1 This is a flowchart illustrating an embodiment of an image segmentation method based on a MaskFormer network according to the present invention.
[0069] Figure 2 This is a schematic diagram of the overall structure of the existing MaskFormer network;
[0070] Figure 3 This is a schematic diagram of the overall structure of the MaskFormer network in an embodiment of an image segmentation method based on the MaskFormer network according to the present invention.
[0071] Figure 4 This is a flowchart illustrating an embodiment of a training method for a MaskFormer network according to the present invention.
[0072] Figure 5 This is a schematic diagram of an embodiment of an image segmentation device based on a MaskFormer network according to the present invention. Detailed Implementation
[0073] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be particularly noted that the following embodiments are for illustrative purposes only and do not limit the scope of the invention. Similarly, the following embodiments are only some, not all, embodiments of the present invention, and all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0074] This invention provides an image segmentation method based on MaskFormer network, which can effectively ensure the segmentation quality of details while maintaining computational efficiency.
[0075] Example 1
[0076] Please see Figure 1 An image segmentation method based on MaskFormer network, comprising:
[0077] The MaskFormer network includes at least one hard region refinement network, which comprises a hard region extraction module, a hard region sequence extraction module, and an encoder. In this embodiment, the hard regions include sparse regions. Hard regions are details such as edges, corners, thin strips, and cutouts. Compared to the entire image, they have a small pixel ratio and are sparse. Therefore, refining hard regions is much more efficient than refining the entire image directly.
[0078] S11. Obtain several mask embeddings and per-pixel embeddings of the image data to be processed;
[0079] In this embodiment, the acquisition of mask embeddings and per-pixel embeddings is based on the MaskFormer network itself, and its principles will not be explained in detail here.
[0080] S12. Using the difficult region extraction module, perform feature extraction on the per-pixel embeddings to obtain a difficult region map of the image; specifically including:
[0081] S121. The per-pixel embeddings are input into two convolutional layers to obtain convolutional per-pixel embeddings. Feature extraction is performed on the convolutional per-pixel embeddings based on the sigmoid activation function to obtain the hard region map of the image. The purpose of this step is to provide a simple and effective way to obtain the hard region map of the image, thus providing important information support for subsequent processing. This method utilizes the image processing capabilities of convolutional neural networks. Through the combination of two convolutional layers and the sigmoid activation function, per-pixel embeddings can be intuitively transformed into hard region maps. This design is simple, intuitive, easy to understand, and easy to implement. This method directly embeds the feature extraction process into the entire network training process, realizing end-to-end processing. This allows the network to automatically learn and optimize the feature extraction process, thereby better adapting to different data and tasks.
[0082] S13. Based on the difficult region map, determine the difficult regions in the image, use the difficult region sequence extraction module to perform feature extraction on the difficult regions, obtain multi-level features of the difficult regions, and combine the multi-level features with several mask embeddings to obtain image sequence features; including:
[0083] S131. From the image data to be processed, the backbone, pixel decoder and per-pixel embeddings in the MaskFormer network, the multi-level features of each pixel in the difficult region are obtained by sampling, and the dimension of the multi-level features is compressed to the same as the dimension of the per-pixel embeddings by convolution.
[0084] S132. Aggregate several mask embeddings with the compressed multi-level features to form image sequence features.
[0085] In this embodiment, the steps S131-S132 have the following advantages:
[0086] (1) Multi-level feature extraction: Through the difficult region sequence extraction module, we can obtain multi-level features of each pixel from the difficult region map. These features include information at different levels, from local to global, from low level to high level, enabling the network to understand the difficult regions in the image more comprehensively.
[0087] (2) Sampling and Compression: Sampling can effectively obtain multi-level features of each pixel in difficult regions, while convolutional compression can adjust the dimensions of these features to be the same as those of per-pixel embeddings for subsequent processing. This sampling and compression strategy can reduce computational complexity and improve processing efficiency while retaining key information.
[0088] (3) The mask embeddings are aggregated with the compressed multi-level features to form image sequence features. This integrates information from different sources, enhances the network's overall understanding of the image, and helps improve segmentation quality and accuracy.
[0089] In summary, through the above steps, we obtained image sequence features that contain a comprehensive and detailed description of difficult regions, while also incorporating information from mask embeddings. This comprehensive feature representation can better guide the network's learning process, improving the accuracy and robustness of image segmentation.
[0090] S14. The image sequence features are refined using an encoder to obtain image refinement features;
[0091] In this embodiment, the transformer encoder can be directly understood as a module.
[0092] The core idea of the Transformer encoder is to use a multi-head self-attention mechanism and a feedforward neural network to process the input sequence data. This step uses the Transformer encoder module to refine the sequence obtained in the previous step. Because it incorporates mask embeddings, the features of each point in the difficult region can be readjusted based on the mask embeddings, ultimately resulting in higher quality detail segmentation when performing mask prediction.
[0093] S15. Input the image thinning features into the MaskFormer network, replace the per-pixelembeddings, and then continue the image segmentation operation. Specifically, this includes:
[0094] S151. Upsample the per-pixel embeddings to the original image, and replace the per-pixel embeddings corresponding to the difficult regions with image thinning features to obtain refined per-pixel embeddings;
[0095] S152. Continue performing image segmentation operations based on refined per-pixel embeddings.
[0096] In this embodiment, the purpose of steps S151-S152 is to allow the upsampling and replacement processes to directly integrate the feature information obtained after the network has refined difficult regions into the original per-pixel embeddings. The resulting refined per-pixel embeddings thus contain information about the image refinement features while maintaining the spatial structure and resolution of the original per-pixel embeddings. This processing preserves the network's segmentation ability at the original pixel level while enhancing the expression and understanding of details.
[0097] The implementation principle of this invention will be explained in detail below:
[0098] (1) MaskFormer network
[0099] This invention uses MaskFormer as the basic segmentation framework. MaskFormer is a unified segmentation framework that can be applied to all image segmentation tasks, including semantic segmentation, instance segmentation, panoptic segmentation, and entity segmentation. Its overall structure is as follows: Figure 2 As shown. MaskFormer first extracts low-resolution features from the image using a backbone, then uses a pixel decoder to progressively upsample and extract per-pixel embeddings. A transformer decoder then extracts N per-segment embeddings. A linear classifier with softmax activation is applied to the per-segment embeddings to obtain the classification result for each segment. A Multi-Layer Perceptron (MLP) with two hidden layers is applied to the per-segment embeddings to obtain N mask embeddings. The mask embeddings and per-pixel embeddings are multiplied and then subjected to sigmoid activation to obtain the corresponding segmentation mask. For entity segmentation, since it is class-independent, the number of classes ( Figure 2 K) is set to 1.
[0100] (2) Scheme of the present invention
[0101] The network framework of the present invention is as follows: Figure 3 As shown, the relevant explanations are as follows:
[0102] 1. Obtain the mask embeddings and per-pixel embeddings of the input image using MaskFormer.
[0103] 2. Based on per-pixel embeddings, a difficult region map of the image is obtained through a difficult region extraction module. This module consists of two convolutional layers and obtains the difficult region map through sigmoid.
[0104] 3. Upsample the difficult region map to the input resolution, set a threshold to determine the difficult region, and obtain the multi-level features of each pixel in the difficult region by sampling from the input image, backbone, pixel decoder and per-pixel embeddings. Then, compress the dimension of the features to be consistent with the dimension of the per-pixel embeddings by point-wise convolution, and combine them with N mask embeddings to form a sequence.
[0105] 4. Refine the sequence obtained in the previous step using the transformer encoder module. Because it incorporates mask embeddings, the features of each point in the difficult region can be readjusted based on the mask embeddings, resulting in higher quality detail segmentation during mask prediction.
[0106] 5. Upsample the per-pixel embeddings obtained in step 1 to the original image, and replace the embeddings corresponding to the difficult regions with the result of the refinement in the previous step to obtain refined per-pixel embeddings.
[0107] 6. Multiply the mask embeddings with the refined per-pixel embeddings obtained in the previous step to obtain the final mask.
[0108] The Hard Region Refine Module, based on the Transformer Encoder, utilizes Mask Embeddings to refine the per-pixel embeddings of hard regions as a whole. For a single input, only one refinement is needed to achieve the effect of refining all targets. In contrast, methods that refine based on the mask predicted in the first stage require refining the mask for each target, leading to a rapid increase in inference time as the number of targets increases. This invention defines hard regions as detailed areas such as edges, corners, thin strips, and hollow areas, which exhibit sparse characteristics. Edge-type hard regions can be directly extracted using edge extraction algorithms based on the labeled image. Corners, thin strips, and hollow areas are extracted through morphological top and bottom cap calculations. The extracted regions are then dilated to a certain extent to obtain the ground truth of the hard regions. Compared to the entire image, hard regions exhibit sparse characteristics.
[0109] Example 2
[0110] Please see Figure 4 A training method for a MaskFormer network, comprising at least one hard region refinement network, wherein the hard region refinement network includes a hard region extraction module, a hard region sequence extraction module, and an encoder; the specific steps are as follows:
[0111] S21. Obtain at least one training image data;
[0112] In this embodiment, the training image data generally consists of an RGB image and a label image. The label image is an image of the same size as the input image, where the value of each pixel represents the semantic category or instance of that pixel. The label image typically uses integer encoding, with each integer representing a specific semantic category or instance.
[0113] S22. Obtain the segmentation real labels and hard region real labels of the training image data;
[0114] In this embodiment, the label can be applied manually, but other methods can also be used, which will not be elaborated here.
[0115] S23. Use the MaskFormer network to perform feature extraction on the training image data to obtain several mask embeddings and per-pixel embeddings;
[0116] S24. Use the difficult region extraction module to perform feature extraction on the per-pixel embeddings to obtain the difficult region map of the image;
[0117] S25. Based on the difficult region map, determine the difficult regions in the image, use the difficult region sequence extraction module to perform feature extraction on the difficult regions to obtain multi-level features of the difficult regions, and combine the multi-level features with several mask embeddings to obtain image sequence features and difficult region prediction labels.
[0118] S26. Based on the predicted labels of difficult regions and the true labels of difficult regions, calculate the first loss value, and train the difficult region extraction module based on the first loss value.
[0119] S27. The image sequence features are refined using an encoder to obtain image refinement features;
[0120] S28. Input the image thinning features into the MaskFormer network, replace the per-pixelembeddings, and continue to perform image segmentation operation. After image segmentation, obtain the segmentation result of the training image data.
[0121] S29. Matching the segmentation prediction results with the true segmentation labels using a bipartite graph matching method;
[0122] S210, Calculate the second loss value based on the matching result, and
[0123] S211. Based on the second loss value, train the MaskFormer network.
[0124] Furthermore, the overall training process can be mainly divided into the following four stages:
[0125] 1. MaskFormer training: The loss calculation of the prediction result and the ground truth is realized by using bipartite graph matching. In this step, when calculating the binary mask loss, the training is strengthened for difficult regions to improve the prediction ability of the MaskFormer model for difficult regions.
[0126] 2. The difficult region extraction module is trained by directly supervising the process using the ground truth of the difficult regions, and employing bceloss + dice loss for supervision.
[0127] 3. Transformer encoder module training: The loss calculation in this stage is the same as that in stage 1.
[0128] 4. Overall network fine-tuning: All losses are used in the calculation to fine-tune the network as a whole, making the modules more coordinated.
[0129] In this embodiment, the above training method has the following advantages:
[0130] (1) Refinement processing: The network enhances the network's ability to understand and segment details by extracting and refining features of difficult regions.
[0131] (2) Dual supervision: Two loss values (first loss value and second loss value) are used to train the difficult region refinement network and the overall segmentation network respectively, which provides a more comprehensive supervision signal and helps to improve the overall performance of the network.
[0132] (3) High-efficiency optimization: The calculation method based on bipartite graph matching enables the network to optimize the matching between the segmentation results and the real labels more efficiently, further improving the segmentation accuracy.
[0133] (5) Through end-to-end training methods and dual supervision mechanisms, this invention improves training efficiency and effectiveness, enabling the network to converge faster and achieve excellent segmentation performance.
[0134] Example 3
[0135] Please see Figure 3 A MaskFormer network, configured to acquire several mask embeddings and per-pixel embeddings of image data to be processed, and to segment the image data;
[0136] Also includes:
[0137] At least one hard region refinement network, the hard region refinement network comprising:
[0138] The difficult region extraction module is configured to perform feature extraction operations on the per-pixel embeddings to obtain a difficult region map of the image;
[0139] The difficult region sequence extraction module is configured to determine the difficult regions in the image based on the difficult region map, perform feature extraction operations on the difficult regions to obtain multi-level features of the difficult regions, and combine the multi-level features with several mask embeddings to obtain image sequence features.
[0140] The encoder is configured to refine the image sequence features to obtain image refinement features and input them into the MaskFormer network.
[0141] In this embodiment, by introducing a hard region refinement network based on the MaskFormer network, not only can general regions in the image be accurately segmented, but the processing capability for hard regions can also be significantly improved. This design improves the overall image segmentation effect while paying special attention to detail processing, making it suitable for various application scenarios requiring high-precision image segmentation.
[0142] Example 4
[0143] Please see Figure 5 An image segmentation apparatus based on a MaskFormer network, based on the method described in one embodiment; comprising sequentially connected:
[0144] The acquisition module is used to acquire several mask embeddings and per-pixelelembeddings of the image data to be processed;
[0145] The first feature module is used to perform feature extraction on the per-pixel embeddings using the difficult region extraction module to obtain a difficult region map of the image;
[0146] The second feature module is used to determine the difficult regions in the image based on the difficult region map, use the difficult region sequence extraction module to perform feature extraction on the difficult regions to obtain multi-level features of the difficult regions, and combine the multi-level features with several mask embeddings to obtain image sequence features.
[0147] The third feature module is used to refine the image sequence features using an encoder to obtain image refinement features;
[0148] The segmentation module is used to input the image thinning features into the MaskFormer network, replace the per-pixelembeddings, and then continue to perform the image segmentation operation.
[0149] In the above technical solutions, in order to better use the method described in one or two embodiments, this application proposes an image segmentation device based on MaskFormer network. Each module corresponds to each step of the above method, and its specific principle has been described above and will not be repeated here.
[0150] Example 5
[0151] An image segmentation device based on a MaskFormer network includes:
[0152] At least one processor and a memory communicatively connected to said at least one processor;
[0153] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method described above.
[0154] In the above technical solution, to better operate and process the method, the method is stored in memory, and the stored method is executed by a processor. It should be noted that the principle and effect of each step have been described above and will not be elaborated upon here.
[0155] Example 6
[0156] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.
[0157] In the above technical solution, to better operate and use the method, the method is stored in a computer-readable storage medium and implemented using a processor. It should be noted that the principle and effect of each step have been described above and will not be elaborated upon here.
[0158] The above description is only a part of the embodiments of the present invention and does not limit the scope of protection of the present invention. Any equivalent device or equivalent process transformation made based on the content of the present invention specification and drawings, or direct or indirect application in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. An image segmentation method based on MaskFormer network, characterized in that, The MaskFormer network includes at least one hard region refinement network, which includes a hard region extraction module, a hard region sequence extraction module, and an encoder. Obtain several mask embeddings and per-pixel embeddings of the image data to be processed; The difficult region extraction module is used to perform feature extraction on the per-pixel embeddings to obtain a difficult region map of the image; Based on the difficult region map, difficult regions in the image are identified. The difficult region sequence extraction module is used to perform feature extraction on the difficult regions to obtain multi-level features of the difficult regions. The multi-level features are then combined with several mask embeddings to obtain image sequence features. The image sequence features are thinned using an encoder to obtain image thinning features; The image thinning features are input into the MaskFormer network, and the image segmentation operation is continued after the per-pixel embeddings are replaced. Based on the difficult region map, difficult regions in the image are identified. The difficult region sequence extraction module is used to extract features from these difficult regions, obtaining multi-level features. These multi-level features are then combined with several mask embeddings to obtain image sequence features, including: From the image data to be processed, the backbone, pixel decoder and per-pixel embeddings in the MaskFormer network, multi-level features of each pixel in the difficult region are obtained by sampling, and the dimension of the multi-level features is compressed to the same dimension as the per-pixel embeddings by convolution. Several mask embeddings are aggregated with compressed multi-level features to form image sequence features; The image thinning features are input into the MaskFormer network, and after replacing the per-pixel embeddings, the image segmentation operation continues, including: The per-pixel embeddings are upsampled to the original image, and the per-pixel embeddings corresponding to the difficult regions are replaced with image thinning features to obtain refined per-pixel embeddings. The image segmentation operation continues based on the refined per-pixel embeddings; The difficult region extraction module is used to perform feature extraction on the per-pixel embeddings to obtain a difficult region map of the image, including: The per-pixel embeddings are input into two convolutional layers to obtain convolutional per-pixel embeddings. Feature extraction is performed on the convolutional per-pixel embeddings based on the sigmoid activation function to obtain the hard region map of the image.
2. The image segmentation method based on MaskFormer network as described in claim 1, characterized in that, The difficult region includes regions with sparse characteristics.
3. A training method for a MaskFormer network, characterized in that, The method described in any one of claims 1-2 is applicable to the MaskFormer network, which includes at least one hard region refinement network, wherein the hard region refinement network includes a hard region extraction module, a hard region sequence extraction module, and an encoder. Obtain at least one training image data; Obtain the segmentation ground truth labels and hard region ground truth labels of the training image data; The MaskFormer network is used to perform feature extraction on the training image data to obtain several maskembeddings and per-pixel embeddings. The difficult region extraction module is used to perform feature extraction on the per-pixel embeddings to obtain a difficult region map of the image; Based on the difficult region map, difficult regions in the image are identified. The difficult region sequence extraction module is used to perform feature extraction on the difficult regions to obtain multi-level features of the difficult regions. The multi-level features are then combined with several mask embeddings to obtain image sequence features and predicted labels for the difficult regions. Based on the predicted labels and the true labels of the difficult regions, a first loss value is calculated, and the difficult region extraction module is trained based on the first loss value. The image sequence features are thinned using an encoder to obtain image thinning features; The image thinning features are input into the MaskFormer network, and after the per-pixel embeddings are replaced, the image segmentation operation is continued to be performed. After image segmentation, the segmentation result of the training image data is obtained. The segmentation prediction result and the segmentation true label are matched based on the bipartite graph matching method. The second loss value is calculated based on the matching results, and The MaskFormer network is trained based on the second loss value.
4. A MaskFormer network, characterized in that, Applicable to the method according to any one of claims 1-2; The MaskFormer network is configured to acquire several mask embeddings and per-pixel embeddings of the image data to be processed, and to segment the image data; Also includes: At least one hard region refinement network, the hard region refinement network comprising: The difficult region extraction module is configured to perform feature extraction operations on the per-pixel embeddings to obtain a difficult region map of the image; The difficult region sequence extraction module is configured to determine the difficult regions in the image based on the difficult region map, perform feature extraction operations on the difficult regions to obtain multi-level features of the difficult regions, and combine the multi-level features with several mask embeddings to obtain image sequence features. The encoder is configured to refine the image sequence features to obtain image refinement features and input them into the MaskFormer network.
5. An image segmentation device based on a MaskFormer network, characterized in that, The method based on any one of claims 1-2; comprising sequentially connected: The acquisition module is used to acquire several mask embeddings and per-pixelelembeddings of the image data to be processed; The first feature module is used to perform feature extraction on the per-pixel embeddings using the difficult region extraction module to obtain a difficult region map of the image; The second feature module is used to determine the difficult regions in the image based on the difficult region map, use the difficult region sequence extraction module to perform feature extraction on the difficult regions to obtain multi-level features of the difficult regions, and combine the multi-level features with several mask embeddings to obtain image sequence features. The third feature module is used to refine the image sequence features using an encoder to obtain image refinement features; The segmentation module is used to input the image thinning features into the MaskFormer network, replace the per-pixelembeddings, and then continue to perform the image segmentation operation.
6. An image segmentation device based on a MaskFormer network, characterized in that, include: At least one processor and a memory communicatively connected to said at least one processor; The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method as described in any one of claims 1 to 2.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 2.
