Image segmentation method and system based on global boundary affinity

By using a global boundary affinity branch to filter boundary features during the training phase and employing an attention mechanism for supervision, the problem of fuzzy boundary features in lightweight semantic segmentation models is solved, achieving efficient and accurate boundary segmentation, which is suitable for autonomous driving and medical image analysis.

CN122473460APending Publication Date: 2026-07-28NANKAI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANKAI UNIV
Filing Date
2026-05-29
Publication Date
2026-07-28

AI Technical Summary

Technical Problem

Existing lightweight semantic segmentation models suffer from semantic drift during feature aggregation in boundary regions, leading to blurred boundary features. Existing methods either increase computational latency or rely on blurred neighboring pixels, which cannot effectively solve this problem.

Method used

During the training phase, a global boundary affinity branch is constructed, and boundary pixel features are filtered through morphological operations. Attention mechanisms and ideal affinity matrices are used for supervision to align boundary features with the correct category semantics. After training, the auxiliary branch is discarded during the inference phase.

Benefits of technology

Without increasing computational overhead, it significantly improves boundary segmentation accuracy, meets the real-time inference needs of mobile terminals, and outputs accurate pixel-level segmentation results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122473460A_ABST
    Figure CN122473460A_ABST
Patent Text Reader

Abstract

The application provides an image segmentation method and system based on global boundary affinity, and relates to the technical field of computer vision. The method comprises the following steps: inputting a sample image into an image segmentation model; obtaining a high-dimensional feature map based on an encoder, and processing a corresponding real label into a boundary mask; screening boundary pixel features from the high-dimensional feature map based on the boundary mask, and constructing the boundary pixel features into a query vector set; adopting an attention mechanism for the high-dimensional feature map and the query vector set based on a global boundary affinity branch, and obtaining a predicted affinity matrix; calculating an affinity loss function between the predicted affinity matrix and an ideal affinity matrix, and calculating a semantic loss function between a predicted label and a real label; iteratively training the model by using a joint loss function; inputting an image to be segmented into the trained image segmentation model, and obtaining an image segmentation result. The method effectively solves the core defects of boundary segmentation ambiguity and semantic drift of a semantic segmentation model, and balances segmentation accuracy and inference efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, and in particular to an image segmentation method and system based on global boundary affinity. Background Technology

[0002] Semantic segmentation is a core foundational task in computer vision, aiming to assign a corresponding category label to each pixel of an input image, widely supporting key applications such as autonomous driving and medical image analysis. With the widespread adoption of mobile terminals and embedded devices, the demand for real-time inference under limited computing resources is becoming increasingly urgent, leading to the development of efficient semantic segmentation models.

[0003] These types of models typically employ lightweight backbone networks and active space downsampling strategies, which, while compressing model size and expanding receptive field to improve efficiency, also introduce inherent drawbacks.

[0004] Features such as convolution stride and pooling can cause the receptive fields of different object boundary regions to merge and mix visual information, leading to semantic drift of boundary features and forming a "fuzzy intermediate state". Existing solutions attempt to address this by using additional boundary refinement branches or geometric contour loss, but the former increases computational latency and defeats the purpose of efficiency, while the latter relies on blurred boundary neighborhood pixels and cannot provide reliable discrimination guidance. Summary of the Invention

[0005] To address the aforementioned issues, this invention proposes an image segmentation method and system based on global boundary affinity. Without introducing any additional inference computation overhead, it fundamentally breaks the trap of the "intermediate state" of features and achieves alignment between boundary features and the correct category semantics.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides an image segmentation method based on global boundary affinity, comprising: The sample image is input into the image segmentation model; the image segmentation model includes an encoder / decoder, a global boundary affinity branch, and a classifier. The high-dimensional feature map obtained based on the codec and the real label are input into the global boundary affinity branch; based on the real label, boundary pixel features are selected from the high-dimensional feature map to construct a query vector set; the attention weight between the query vector set and the high-dimensional feature map is calculated to obtain the predicted affinity matrix; the affinity loss function between the predicted affinity matrix and the ideal affinity matrix is ​​calculated. The high-dimensional feature map is input into the classifier to obtain the predicted label, and the semantic loss function between the predicted label and the true label is calculated. The joint loss function is used to iteratively train the model. The image to be segmented is input into the trained image segmentation model to obtain the image segmentation result.

[0007] In one implementation, the real label is the real segmentation map corresponding to the sample image.

[0008] As one implementation method, the step of filtering boundary pixel features from the high-dimensional feature map based on the real labels specifically includes: The real label is processed using morphological dilation and erosion operations to obtain a binary boundary mask; in the binary boundary mask, 1 represents the boundary and 0 represents the background. The features in the high-dimensional feature map corresponding to 1 in the binary boundary mask are used as the features of the boundary pixel points.

[0009] As one implementation method, the calculation of the attention weights between the query vector set and the high-dimensional feature map to obtain the predicted affinity matrix specifically includes: flattening the high-dimensional feature map as a key vector, and calculating the predicted affinity matrix by combining the query vector set with dot product attention.

[0010] As one implementation method, obtaining the ideal affinity matrix specifically includes: Extract the boundary pixel set from the real label, and construct an initial matrix based on the boundary pixel set and the size of the real label; Iterate through the boundary pixels of each row of the initial matrix and count the total number of pixels in the entire image belonging to the category of the boundary pixels; iterate through the label pixels in the entire image of each column. If the category of the entire image pixel is the same as that of the boundary pixel, assign the reciprocal of the total number of pixels to the corresponding position in the matrix; otherwise, assign 0. The ideal affinity matrix is ​​finally obtained.

[0011] As one implementation method, the calculation of the affinity loss function between the predicted affinity matrix and the ideal affinity matrix specifically includes: using divergence to calculate the deviation between the predicted affinity matrix and the ideal affinity matrix as the affinity loss function.

[0012] As one implementation method, the global boundary affinity branch does not participate in the model inference stage.

[0013] Secondly, the present invention provides an image segmentation system based on global boundary affinity, comprising: An image input unit is configured to input a sample image into an image segmentation model; the image segmentation model includes an encoder / decoder, a global boundary affinity branch, and a classifier. The affinity calculation unit is configured to input the high-dimensional feature map obtained based on the codec and the real label into the global boundary affinity branch; filter boundary pixel features from the high-dimensional feature map based on the real label to construct a query vector set; calculate the attention weight between the query vector set and the high-dimensional feature map to obtain the predicted affinity matrix; and calculate the affinity loss function between the predicted affinity matrix and the ideal affinity matrix. The semantic loss calculation unit is configured to input a high-dimensional feature map into a classifier to obtain a predicted label and calculate the semantic loss function between the predicted label and the true label. The training and segmentation unit is configured to iteratively train the model using a joint loss function, input the image to be segmented into the trained image segmentation model, and obtain the image segmentation result.

[0014] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the image segmentation method based on global boundary affinity described in the first aspect.

[0015] Fourthly, the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the image segmentation method based on global boundary affinity described in the first aspect.

[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention constructs a boundary mask to filter boundary pixel features, and combines a global boundary affinity branch with an attention mechanism to accurately capture the feature associations of boundary regions, avoiding the "fuzzy intermediate state" caused by mixed visual information, thus significantly improving boundary segmentation accuracy. It eliminates the need for additional boundary refinement branches, avoiding extra computational delays and meeting the core requirement of efficient segmentation. Simultaneously, it constructs an ideal affinity matrix based on a global perspective, guiding the convergence of boundary pixel features based on stable features of similar pixels, eliminating dependence on blurred boundary neighbor pixels and providing reliable discrimination guidance. During training, affinity loss and semantic loss are integrated to achieve synergistic optimization of boundary features and global semantics. This enables the trained model to meet the real-time inference needs of mobile terminals and output accurate pixel-level segmentation results in scenarios such as autonomous driving and medical image analysis.

[0017] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0018] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute a limitation thereof.

[0019] Figure 1 A main flowchart of an image segmentation method based on global boundary affinity provided in an embodiment of the present invention; Figure 2 A detailed flowchart of an image segmentation method based on global boundary affinity provided for an embodiment of the present invention; Figure 3 This diagram illustrates a comparison of the results of the method of the present invention with other existing methods, as provided in the embodiments of the present invention. Detailed Implementation

[0020] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0021] Semantic segmentation aims to assign a category label to each pixel in an input image, and it is a core foundational task for many computer vision applications such as autonomous driving and medical image analysis.

[0022] In recent years, efficient semantic segmentation models have received widespread attention in order to meet the real-time inference needs of mobile terminals or embedded devices with limited computing resources. These models typically employ lightweight backbone networks and aggressive spatial downsampling strategies to compress model size and expand the receptive field.

[0023] However, this feature aggregation operation through convolution stride or pooling introduces a serious inherent drawback: at the boundaries of different object categories (i.e., boundary regions), the receptive field inevitably aggregates mixed visual information from adjacent different categories. This spatial physical mixing causes semantic drift of boundary features in the hidden feature space, resulting in a "fuzzy intermediate state" that belongs to neither category A nor category B. Existing techniques attempt to address this problem by introducing additional boundary refinement branches (such as local attention or point rendering) or explicit geometric contour loss. However, these methods have significant limitations: the former introduces high additional computational latency, violating the original intention of efficient segmentation; the latter often relies on local neighboring pixels for correction, while the pixels in the boundary neighborhood are often also in a fuzzy state, resulting in the inability to provide reliable discriminative guidance.

[0024] Therefore, how to fundamentally break the "intermediate state" trap of features and achieve alignment between boundary features and correct category semantics without introducing any additional inference computation overhead is a key technical problem that urgently needs to be solved in this field.

[0025] Based on this, this invention proposes an image segmentation method, system, medium, and device based on global boundary affinity, involving an auxiliary optimization paradigm that only takes effect during the training phase. Specifically, a global boundary affinity learning branch is constructed on the basis of a standard encoder-decoder network: first, boundary pixel features are dynamically extracted as query vectors through morphological operations, and the whole image features are used as key vectors to calculate a dense attention matrix from the boundary to the pixel; then, an ideal affinity target constructed based on real labels is used to supervise the attention distribution through KL divergence. This method forces blurred boundary features to form strong associations with global high-quality prototype features belonging to the same semantic category, thereby pulling them back from the decision edge to the correct semantic category space. In particular, the auxiliary branch of this invention is completely discarded during the inference deployment phase, significantly improving the model's fine-grained segmentation accuracy of object boundaries without increasing any additional parameters or computational cost (FLOPs).

[0026] Example 1 like Figure 1 As shown, this embodiment discloses an image segmentation method based on global boundary affinity, including the following steps: S1: Input the sample image into the image segmentation model; the image segmentation model includes an encoder / decoder, a global boundary affinity branch, and a classifier; S2: Input the high-dimensional feature map obtained based on the codec and the real label into the global boundary affinity branch; based on the real label, filter the boundary pixel features from the high-dimensional feature map to construct a query vector set; calculate the attention weight between the query vector set and the high-dimensional feature map to obtain the predicted affinity matrix; calculate the affinity loss function between the predicted affinity matrix and the ideal affinity matrix; S3: Input the high-dimensional feature map into the classifier to obtain the predicted label, and calculate the semantic loss function between the predicted label and the true label; S4: The joint loss function is used to iteratively train the model. The image to be segmented is input into the trained image segmentation model to obtain the image segmentation result.

[0027] Next, combined Figure 2 This paper provides a detailed description of an image segmentation method based on global boundary affinity disclosed in this embodiment.

[0028] First, we design and initialize an image segmentation network model, which mainly includes an encoder, a decoder head, a global boundary affinity branch (GBA), and a classifier.

[0029] Among them, such as Figure 2As shown, the backbone network is specifically an encoder, which is used to encode the input image, extract and output multi-scale features; the decoder head is used to fuse the multi-scale features output by the encoder to generate the final feature map.

[0030] It should be understood that both the encoder and decoder head adopt existing structures, and those skilled in the art can select and adapt them according to actual needs.

[0031] During the training of the image segmentation model, the model receives natural scene image samples, such as traffic scene images, mobile imaging images, and medical images. After joint processing by the encoder and decoder, a high-dimensional hidden layer feature map is obtained. At the same time, the ground truth segmentation map corresponding to the natural scene image sample is obtained as the label. .

[0032] Next, the high-dimensional hidden layer feature map and tags Input the global boundary affinity branch. In this embodiment, "global" means that when optimizing the boundary, we do not only consider the features of the boundary part, but start from the global perspective of the entire prototype image, so that the boundary features move closer to the global features of the entire image semantics.

[0033] For tags Using morphological operations, a binary boundary mask is obtained through dilation and erosion operations. This enables the collection of dynamic boundaries. The formula is expressed as: ; In this embodiment, by utilizing the expansion region (dilation) and contraction region (erosion), the difference between the two can adaptively capture the edge contours of the target at different scales, adapting to the dynamic changes in boundary morphology, thereby achieving dynamic boundary collection. By extracting the boundary through morphological operations of dilation and erosion, the target contour can be accurately stripped away, effectively suppressing internal pixel interference and highlighting edge details. The resulting mask contains only binary pixels of 0 and 1, where 1 represents the boundary and 0 represents the background. This mask can accurately mark the target edge position, simplifying subsequent feature extraction and localization processes, and improving the accuracy and stability of boundary detection.

[0034] Furthermore, by utilizing the binary nature of this mask, from The features of the boundary pixels are selected from the data, that is, the features of the boundary pixels are selected from the data. The features corresponding to points with a value of 1 are selected as boundary pixel features to form a query vector set. ,in C represents the number of boundary pixels and the number of channels.

[0035] For high-dimensional hidden layer feature maps ,Will Flatten as a key vector The predicted affinity matrix is ​​calculated by combining the query vector with dot product attention. : ; in, It is the first Each boundary query feature It is the first A global pixel feature, where T represents the transpose.

[0036] In this embodiment, feature map information is used as the key vector, and the boundary information of the corresponding ground truth labels in the feature map is used as the query vector to construct an attention mechanism. This accurately guides the model to focus on the feature associations of the target boundary region. The attention mechanism strengthens the interactive matching between boundary and region features, effectively mining the adjacency dependencies between pixels. Selecting boundary information as the query can anchor the target contour constraint, and the feature map as the key can fully utilize the underlying semantic features. The combination of the two can achieve boundary-guided fine-grained global feature alignment and reduce interference from irrelevant regions. Finally, the output predicted affinity matrix is ​​used to characterize the degree of association between pixels in the image that belong to the same target, providing pixel-level similarity basis for the segmentation task and improving the accuracy of target differentiation and boundary segmentation.

[0037] This embodiment abandons the traditional approach of local neighborhood refinement and breaks the feature reconstruction trap of "intermediate state". By innovatively transforming boundary correction into a dense global attention problem, it uses the pure global category prototype inside the object to "awaken" the boundary pixels in the mixed state, and completely removes cross-class pollution from the source of feature representation (latent space).

[0038] Furthermore, based on real labels Building an ideal affinity goal It is used for monitoring ideal affinity.

[0039] The rule stipulates that pixels on the boundary should only have high affinity with pixels belonging to the same semantic category, thereby filtering out noise interference from adjacent heterogeneous categories. Specifically, an ideal affinity target matrix with boundary pixels as the row dimension and the total number of H×W pixels in the image as the column dimension is constructed, with the number of boundary pixels × H×W. Affinity weights are defined based on pixel category consistency; if the total number of pixels in the image... With boundary pixels If they belong to the same category, then the ideal affinity target weight is... (This represents the total number of pixels of that class in the image), otherwise it is 0. This forces boundary pixels to establish high correlation only with pixels of the same class, isolating them from noise interference from pixels of different classes.

[0040] The ideal affinity objective guides the alignment of boundary pixel features with the overall features of the same type of object through affinity constraints. This can transform the classification of boundary pixel features into the modeling of the boundary pixel and the entire object, thereby bringing the features of the boundary pixel and the entire object closer together and better solving the boundary classification problem.

[0041] Next, the deviation between the affinity matrix predicted by the model and the ideal affinity target matrix is ​​calculated using divergence (such as Kullback-Leibler Divergence), and this deviation is taken as the affinity loss. : ; Simultaneously, the high-dimensional feature map is input into the classifier to obtain the predicted label, and the semantic loss function between the predicted label and the true label is calculated. .

[0042] Afterwards, the affinity will be lost. Cross-entropy loss compared to standard image semantic segmentation By performing a weighted linear combination, the total loss is obtained: ; Used for joint backpropagation update of network parameters. By using the gradient backpropagation algorithm and leveraging the feedback signal from global high-quality prototype features, boundary pixels in a mixed state are forced to converge towards their true semantic cluster centers, thereby updating all weight parameters of the base network.

[0043] When the loss function converges, a well-trained image segmentation model is obtained.

[0044] After training, the global boundary affinity branch, which serves as an auxiliary branch, is completely discarded during the inference and deployment phase. Only the main network structure is retained for feature extraction and mask generation, enabling efficient image segmentation in real-world business scenarios.

[0045] The image to be segmented is input into the trained image segmentation model to obtain the image segmentation result.

[0046] In this embodiment, the core global boundary affinity module is cleverly designed as an auxiliary optimization branch during pure training. While maintaining the high-resolution feature space structure, the basic network internalizes boundary awareness during training. Deployment does not introduce any additional model parameters or floating-point operations (FLOPs), allowing the input image to output a semantic segmentation mask with clear boundaries and high accuracy simply by passing through the basic segmentation network. This significantly improves the model's fine-grained segmentation accuracy and efficiency for object boundaries without increasing any additional parameters or computational cost (FLOPs), achieving true zero inference cost (Free Lunch).

[0047] To intuitively evaluate the effectiveness of the method proposed in this embodiment, in Figure 3 The visualization of the segmentation prediction results is presented. The method GBANet in this embodiment is compared with ground truth and representative efficient segmentation methods at similar model sizes (including SegFormer, CGRSeg, and OffSeg). Yellow boxes highlight challenging regions with severe semantic ambiguity, such as fine structures and dense boundaries.

[0048] Standard, efficient models often suffer from semantic ambiguity due to unclear intermediate states caused by feature aggregation, resulting in imprecise boundaries. For example, in the first and second rows (indoor scenes), contrastive methods struggle to separate adjacent objects, such as gaps between paintings or the boundaries of luggage in a crowd, leading to over-mixing of predictions. In contrast, GBANet effectively decouples these adjacent features using global guidance, generating clear boundaries that are highly consistent with the true labels.

[0049] The third and fourth rows (outdoor scenes) further demonstrate GBANet's robustness in preserving fine-grained details. Irregularly shaped objects (such as bushes and road signs) are often underrepresented in standard, efficient architectures. This is because background features often overwhelm local contextual operations, suppressing signals from smaller or more complex structures. In contrast, GBANet successfully predicts the structural integrity and clear boundaries of these regions by anchoring them to their global semantic identities.

[0050] This invention achieves alignment between boundary features and the correct category semantics without introducing any additional inference computation overhead. It can be widely applied to various computer vision tasks with limited computing resources but high requirements for boundary accuracy, such as, but not limited to, obstacle detection in autonomous driving, mobile image processing, and organ segmentation in medical images. Furthermore, the global boundary affinity optimization method proposed in this invention does not depend on a specific network structure; it can be seamlessly integrated as a plug-and-play component into various mainstream CNN or Transformer-based high-efficiency semantic segmentation architectures, consistently delivering significant improvements in segmentation accuracy and boundary IoU (B-IoU), demonstrating excellent versatility and scalability.

[0051] Example 2 This embodiment provides an image segmentation system based on global boundary affinity, including: An image input unit is configured to input a sample image into an image segmentation model; the image segmentation model includes an encoder / decoder, a global boundary affinity branch, and a classifier. The affinity calculation unit is configured to input the high-dimensional feature map obtained based on the codec and the real label into the global boundary affinity branch; filter boundary pixel features from the high-dimensional feature map based on the real label to construct a query vector set; calculate the attention weight between the query vector set and the high-dimensional feature map to obtain the predicted affinity matrix; and calculate the affinity loss function between the predicted affinity matrix and the ideal affinity matrix. The semantic loss calculation unit is configured to input a high-dimensional feature map into a classifier to obtain a predicted label and calculate the semantic loss function between the predicted label and the true label. The training and segmentation unit is configured to iteratively train the model using a joint loss function, input the image to be segmented into the trained image segmentation model, and obtain the image segmentation result.

[0052] Example 3 This embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the image segmentation method based on global boundary affinity as described in Embodiment 1 above.

[0053] Example 4 This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in the image segmentation method based on global boundary affinity as described in Embodiment 1 above.

[0054] The steps or modules involved in Embodiments 2 to 4 above correspond to those in Embodiment 1. For specific implementation details, please refer to the relevant description section of Embodiment 1. The term "computer-readable storage medium" should be understood as a single medium or multiple media including one or more instruction sets; it should also be understood as including any medium capable of storing, encoding, or carrying an instruction set for execution by a processor and enabling the processor to perform any of the methods in this invention.

[0055] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An image segmentation method based on global boundary affinity, characterized in that, include: The sample image is input into the image segmentation model; the image segmentation model includes an encoder / decoder, a global boundary affinity branch, and a classifier. The high-dimensional feature map obtained based on the encoder and decoder, along with the real label, is input into the global boundary affinity branch; Based on the real labels, boundary pixel features are selected from the high-dimensional feature map to construct a query vector set; the attention weight between the query vector set and the high-dimensional feature map is calculated to obtain the predicted affinity matrix; the affinity loss function between the predicted affinity matrix and the ideal affinity matrix is ​​calculated. The high-dimensional feature map is input into the classifier to obtain the predicted label, and the semantic loss function between the predicted label and the true label is calculated. The joint loss function is used to iteratively train the model. The image to be segmented is input into the trained image segmentation model to obtain the image segmentation result.

2. The image segmentation method based on global boundary affinity as described in claim 1, characterized in that, The true label is the true segmentation map corresponding to the sample image.

3. The image segmentation method based on global boundary affinity as described in claim 1, characterized in that, The step of filtering boundary pixel features from the high-dimensional feature map based on the real labels specifically includes: The real label is processed using morphological dilation and erosion operations to obtain a binary boundary mask; in the binary boundary mask, 1 represents the boundary and 0 represents the background. The features in the high-dimensional feature map corresponding to 1 in the binary boundary mask are used as the features of the boundary pixel points.

4. The image segmentation method based on global boundary affinity as described in claim 1, characterized in that, The calculation of the attention weights between the query vector set and the high-dimensional feature map to obtain the predicted affinity matrix specifically includes: flattening the high-dimensional feature map as a key vector, and calculating the predicted affinity matrix by combining the query vector set with dot product attention.

5. The image segmentation method based on global boundary affinity as described in claim 1, characterized in that, The acquisition of the ideal affinity matrix specifically includes: Extract the boundary pixel set from the real label, and construct an initial matrix based on the boundary pixel set and the size of the real label; Iterate through the boundary pixels of each row of the initial matrix and count the total number of pixels in the entire image belonging to the category of the boundary pixels; iterate through the label pixels in the entire image of each column. If the category of the entire image pixel is the same as that of the boundary pixel, assign the reciprocal of the total number of pixels to the corresponding position in the matrix; otherwise, assign 0. The ideal affinity matrix is ​​finally obtained.

6. The image segmentation method based on global boundary affinity as described in claim 1, characterized in that, The calculation of the affinity loss function between the predicted affinity matrix and the ideal affinity matrix specifically includes: using divergence to calculate the deviation between the predicted affinity matrix and the ideal affinity matrix, which is used as the affinity loss function.

7. The image segmentation method based on global boundary affinity as described in claim 1, characterized in that, It also includes the fact that the global boundary affinity branch does not participate in the model inference stage.

8. An image segmentation system based on global boundary affinity, characterized in that, include: An image input unit is configured to input a sample image into an image segmentation model; the image segmentation model includes an encoder / decoder, a global boundary affinity branch, and a classifier. The affinity calculation unit is configured to input the high-dimensional feature map obtained based on the encoder and decoder and the real label into the global boundary affinity branch; Based on the real labels, boundary pixel features are selected from the high-dimensional feature map to construct a query vector set; the attention weight between the query vector set and the high-dimensional feature map is calculated to obtain the predicted affinity matrix; the affinity loss function between the predicted affinity matrix and the ideal affinity matrix is ​​calculated. The semantic loss calculation unit is configured to input a high-dimensional feature map into a classifier to obtain a predicted label and calculate the semantic loss function between the predicted label and the true label. The training and segmentation unit is configured to iteratively train the model using a joint loss function, input the image to be segmented into the trained image segmentation model, and obtain the image segmentation result.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the image segmentation method based on global boundary affinity as described in any one of claims 1-7.

10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the image segmentation method based on global boundary affinity as described in any one of claims 1-7.