Next Article in Journal
Heat-Transfer Performance of Medium–Low Temperature Molten Salt Phase-Change Heat Exchanger
Previous Article in Journal
Development and Characterization of Waste Polystyrene/Calcite Composites Prepared by Solution Casting
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Weakly Supervised Segmentation Algorithm Based on Local–Global Class Labelling Comparison

1
School of Electronic Information and Communications, Huazhong University of Science and Technology, Wuhan 430074, China
2
College of Electromechanical Engineering, Wuhan City Polytechnic, Wuhan 430064, China
3
School of Computer Science, Hubei University of Technology, Wuhan 430068, China
*
Authors to whom correspondence should be addressed.
Appl. Sci. 2026, 16(17), 8496; https://doi.org/10.3390/app16178496
Submission received: 24 June 2026 / Revised: 15 August 2026 / Accepted: 17 August 2026 / Published: 26 August 2026

Abstract

As a key pixel-level analysis technology, semantic segmentation is widely deployed in autonomous driving and medical imaging. Fully supervised segmentation relies on labour-intensive pixel-wise annotations, so weakly supervised semantic segmentation (WSSS) with only image-level labels has attracted wide attention. Existing Vision Transformer (ViT)-based WSSS methods suffer from two critical limitations: ViT’s global self-attention mechanism leads to insensitivity to local small target features and incomplete foreground activation; its class-agnostic attention maps frequently misactivate background regions as foreground objects, introducing heavy noise. To tackle these two issues, this paper proposes a single-stage weakly supervised segmentation algorithm based on local–global class labelling comparison. First, we design a local–global class labelling comparison (LTG) module. By feeding both original images and randomly cropped local patches into ViT, we adopt InfoNCE contrastive loss to align local class tokens with global class tokens, enhancing the feature integrity of local target regions and suppressing background false activation. Second, a class-aware stimulus module (CSM) is embedded into ViT’s multi-head attention branch. It injects category semantic constraints into self-attention to generate class-aware attention maps, guiding the model to focus on real foreground targets and reduce background interference. Finally, we construct a feature fusion class-aware activation map (FFCAM) by fusing ViT global output features and CSM class-aware attention features to generate high-quality pseudo-labels for segmentation training. Extensive experiments are conducted on PASCAL VOC 2012 and MS COCO 2014 datasets. Our method achieves 78.5% mIoU on the validation set of PASCAL VOC 2012 and 50.9% mIoU on MS COCO 2014, showing competitive numerical performance among the compared single-stage ViT-based WSSS approaches. Ablation experiments verify the independent and joint effectiveness of LTG, CSM and FFCAM. The proposed method effectively improves the completeness of target activation regions and suppresses background noise, and it maintains strong generalization for slender, small and texture-sparse objects. In future work, we will further lightweight the ViT backbone to reduce computational overhead for embedded deployment.

1. Introduction

With the advent of the information age, computer technology has developed rapidly and penetrated into all areas of human life. The rapid progress of artificial intelligence technology has greatly improved the efficiency of information acquisition and processing, and is widely used in many fields such as travel navigation, aerospace, financial payments, intelligent communications, etc., and has become an indispensable part of modern society. In recent years, AI has made breakthrough progress in many fields [1], and has become a key force driving human society into the era of big data. Among the many research directions of artificial intelligence, image classification, as the core problem of computer vision, has a pivotal position. Not only does it have the basic task of visual recognition, but it also plays a key role in research and application in the fields of target detection, image segmentation, face recognition, target tracking, and super resolution.
Notwithstanding the considerable advances witnessed in the domain of deep learning algorithms in recent years, the quantity and quality of training data remain a pivotal determinate of model performance. Given the propensity of deep learning models to depend on substantial volumes of data, they are susceptible to the overfitting problem. This is characterized by the models’ adeptness on the training data, yet their ineptitude on unseen data. This problem is particularly acute when the amount of data is insufficient, especially when it is limited by factors such as privacy protection or the high cost of manual labelling. Irrespective of the sophistication of the model design and the training techniques employed, inadequate or homogeneous training data invariably imposes constraints on the model’s generalization capabilities. Conversely, the employment of relatively uncomplicated algorithms, incorporating substantial and varied data, has been demonstrated to frequently yield substantial enhancements in model performance. However, the procurement of sufficient and diverse data for numerous practical applications continues to be a significant challenge. Despite the substantial size of widely used contemporary datasets (e.g., ImageNet and CIFAR-100), their diversity and variability still cannot fully satisfy real-world performance requirements. Furthermore, the presence of adversarial attacks poses a significant threat to the accuracy of models, with even minor perturbations potentially leading to erroneous recognition, thereby compromising the reliability of the models. In order to address these issues and enhance the generalization capability of deep neural networks, researchers have proposed a priori-based regularization methods and task-related transformation strategies to improve the diversity of training data. These methods have been shown to effectively extend the coverage of the data, thereby significantly enhancing the model’s performance on unseen data.
In order to improve the robustness and accuracy of machine learning models, so that they can maintain good performance despite small samples or under-representation, data augmentation techniques have emerged. Data augmentation effectively improves the performance of deep neural networks by extending the sample space. This technique is not only widely used in computer vision tasks, but also shows significant value in other fields such as audio [2] and text [3]. Data augmentation can generate more samples based on existing training data or create new training data from scratch by specific techniques, thus effectively alleviating the problem of insufficient data. Efficient data augmentation strategies can not only significantly improve model performance, but also reduce the dependence on complex algorithms, so that simple models can also have strong generalization ability. Especially in the field of computer vision, training data are often presented in the form of images or video sequences, so augmentation methods for these data types are particularly important.
As the intricacy of deep learning models escalates, the number of parameters experiences exponential growth. Achieving a balance between low power consumption and real-time performance has emerged as a pivotal concern in contemporary research. A significant proportion of deep learning models comprise a substantial number of redundant parameters, which exert a negligible influence on performance. Consequently, the optimization of network structures and the reduction in redundant parameters have been shown to enhance computational efficiency and reduce storage overhead, thereby enabling models to operate efficiently on devices with limited resources. The following mainstream model compression methods are currently employed: network pruning, parameter quantization, lightweight network design and low-rank decomposition. Among these methods, knowledge distillation has garnered significant attention in recent years due to its ability to effectively reduce model size while maintaining performance. This has led to it becoming a prominent research area.
The fundamental concept of knowledge distillation entails the compression of models through the collaborative interaction of a teacher model and a student model. The teacher model possesses a complex structure and a substantial number of parameters, whilst the student model is more straightforward and lightweight. During the distillation process, the teacher model transfers its learned knowledge (e.g., intermediate layer features, output distributions, and feature relationships) to the student model, thereby ensuring that the student model approaches the performance of the teacher model while maintaining its lightweight nature. A distinguishing feature of knowledge distillation is that it does not necessitate modification of the structure of the target model, thus offering a versatile approach to model compression applicable to any simple and efficient model architecture. This feature provides a foundation for novel ideas in the realm of efficient model deployment and extension.
Consequently, the enhancement of image classification performance has emerged as a pivotal research domain, particularly in scenarios where data are limited and model structures are becoming more intricate. To address this challenge, data augmentation and knowledge distillation have emerged as effective methods to enhance performance. The former involves the generation of new training samples by applying multiple transformations to the original data, thereby enhancing the generalization ability of the model. Conversely, knowledge distillation involves the process of reducing redundant parameters through model compression, thereby enhancing model performance.
In response to the above issues, we propose a local–global class label comparison (LTG) mechanism to align the representation of local regions with global class features, enhancing the integrity of the target region. In addition, a category-aware stimulus module (CSM) is introduced into the attention mechanism of ViT to guide the ViT model to focus on the correct target area and enhance its category perception ability. On the basis of the above two methods, a feature fusion class-aware activation map (FFCAM) is proposed to replace the generation of traditional class activation maps.
Recent studies further demonstrate why category-aware token modeling is important for ViT-based WSSS. Class Tokens Infusion injects class-token semantics into patch tokens to strengthen class-specific localization [4]. Class Token as Proxy identifies a token gap between classification-oriented class tokens and patch tokens containing both discriminative and non-discriminative cues, which can cause incomplete foreground activation [5]. Know Your Attention Maps directly uses class-specific ViT attention maps and token masking to improve class assignment and pseudo-mask quality [6]. These findings show that global self-attention provides valuable long-range context but does not by itself guarantee complete local responses or reliable category discrimination. Motivated by this evidence, our LTG module aligns local patch representations with global class semantics, while CSM imposes explicit category constraints on self-attention to suppress background confusion.
To overcome the two inherent defects of ViT in WSSS, this paper designs a complete single-stage segmentation framework based on image-level weak supervision. First, we propose a local–global class labelling comparison (LTG) module to solve ViT’s local feature insensitivity. We perform random local cropping on input images and feed both global full images and local cropped patches into the shared ViT backbone. By calculating InfoNCE contrastive loss between global class tokens and local class tokens, we pull positive local foreground features close to global semantic representations and push negative background local features away from global class tokens, which enhances the completeness of local target feature response and eliminates partial background false activation. Second, we construct a class-aware stimulus module (CSM) embedded inside ViT’s multi-head attention block. It reconstructs the original class-agnostic attention map into class-aware attention via encoder–decoder convolution layers and auxiliary classification loss, injecting explicit category constraints into self-attention to suppress background noise and concentrate attention on object regions. Finally, we fuse the global output features of ViT and the optimized attention features from CSM to build a feature fusion class-aware activation map (FFCAM), which generates more accurate and complete pseudo-labels for end-to-end segmentation training without multi-stage iterative refinement.
The rest of this paper is organized as follows. Section 2 reviews the state-of-the-art research on fully supervised semantic segmentation and multiple branches of weakly supervised semantic segmentation, and analyzes the existing limitations of ViT-based WSSS methods. Section 3 elaborates the complete network architecture of our proposed algorithm, and provides detailed mathematical derivation and structural illustration of the local–global class labelling comparison module, class-aware stimulus module and feature fusion class-aware activation map. Section 4 describes the experimental setup including datasets, evaluation metrics and training hyperparameters, reports quantitative comparison results against SOTA methods on two benchmarks, provides qualitative visualization of class activation maps and segmentation predictions, and conducts systematic ablation experiments to verify the effectiveness of each core component. Section 5 concludes the whole work and discusses feasible lightweight optimization directions for future research.

2. Related Work

2.1. State-of-the-Art Research on Fully Supervised Semantic Segmentation Based on Deep Learning

The advent of deep learning, particularly convolutional neural networks, has precipitated a paradigm shift in the realm of semantic segmentation. A seminal paper in this area was the 2012 publication of the AlexNet network by Hinton et al., which demonstrated the immense potential of deep learning in image classification tasks and led to a proliferation of deep learning techniques in the field of semantic segmentation. A significant development was the introduction of the fully convolutional network (FCN), which replaced the fully connected layers with convolutional layers, thereby enabling the network to process images of any size. This became the standard method for semantic segmentation tasks. In 2015, the U-Net architecture was proposed by Ranneberger et al., which employs a typical encoder–decoder structure with jump connections between the two for enhanced image detail recovery. The U-Net architecture achieved remarkable performance in medical image segmentation tasks and had a substantial impact on subsequent research in semantic segmentation algorithms. DeepLabv2 [7] introduced Dilated Space Pyramid Pooling, which enhanced the network model’s capacity to learn multi-scale features, thus improving the segmentation effect. In 2019, APCNet [8] introduced an innovative approach by combining multi-scale feature extraction and contextual information adaptive through the incorporation of an adaptive pyramid context module learning mechanism. This development yielded significant advancements in detail recovery and multi-object recognition capabilities of the network. In 2021, Xie et al. proposed SegFormer [9], which used a lightweight Transformer [10] model and has excellent performance on multiple datasets through an efficient self-attention mechanism and a flexible end-to-end training process. In 2023, Zhang et al. proposed CMNeXt [11], which not only improved the accuracy of the semantic segmentation task, but also enhanced the robustness and generalizability of the model through the fusion of multimodal information and adaptive mode selection.
In general, fully supervised semantic segmentation algorithms have historically occupied a pivotal position in the development of the field, and they play an indispensable role in many current areas of research. However, fully supervised semantic segmentation requires pixel-level labels as a reference for supervised training, and acquiring these labels is usually a laborious and time-consuming process that is costly in terms of both time and labour. As the amount of data increases, the difficulty and cost of acquiring labelled data also increase exponentially, which limits the wide application of fully supervised methods.

2.2. State-of-the-Art Research on Weakly Supervised Semantic Segmentation Based on Deep Learning

Fully supervised semantic segmentation is contingent upon a substantial amount of pixel-level labelled data, which faces significant challenges in many practical scenarios. This is especially the case given that the data labelling process is not only time-consuming and labour-intensive, but it also becomes more and more difficult to obtain accurate annotations as the scale of the dataset increases. This makes the limitations of traditional fully supervised methods more and more obvious in practical applications. Consequently, the urgent need to reduce annotation costs and enhance data utilization efficiency has emerged as a pivotal challenge in contemporary semantic segmentation research.
In order to solve this challenge, weakly supervised semantic segmentation (WSSS) has gradually received widespread attention as an emerging research direction. In contrast to fully supervised methods that rely on pixel-level annotations, weakly supervised semantic segmentation employs a more simplified form of annotation. This can be categorized as follows: (a) image-level annotation, (b) object point annotation, (c) object box annotation, and (d) graffiti annotation. Image-level annotation is the simplest form of annotation and usually only assigns a classification label to each image to indicate the presence or absence of a particular object classification in the image. This form of annotation does not involve the specification of object location or shape information. Consequently, image-level annotation has been the subject of study by a wide range of scholars, primarily due to its relatively low acquisition cost. Object point annotation, by contrast, involves the assignment of one or more specific point locations to objects in an image, with these points representing a particular object classification. These classifications are usually located in the centre or a prominent region of the object. Weak labelling based on object boxes requires the drawing of a rectangular box for each object in the image. This method of labelling is coarse, and the boundary information of the object cannot be obtained more accurately. Graffiti annotation, on the other hand, involves the use of simple hand-drawn markers to denote the semantic information of the image, thus facilitating the rapid acquisition of more rudimentary information concerning the object regions. The following section will elaborate on the various forms of annotation in the context of weakly supervised semantic segmentation research.
The object box annotation-based approach involves the delineation of rectangular boxes for each object in an image, thereby providing spatial information but not specific shapes and edges. This approach is more efficient than pixel-level annotation and contains more positional information than image-level and point annotation. Lee et al. proposed BBAM [12], which performs pixel-level semantic segmentation by generating a bounding-box attribution map for each object and using the bounding-box information. SDI [13] unifies the tasks of instance segmentation and semantic segmentation under a single framework, and gradually denoises the previous round of training by using the prediction results of the previous round of the training convolutional network as the next round of supervised signals, through a well-designed labelling generation strategy and recursive training. The convolutional network prediction results from the initial round of training are utilized as the supervised signals in the subsequent round, thereby progressively denoising the model and enhancing its performance. Song et al. [14] proposed a classification mask generation method employing bounding-box supervised signals, which is capable of efficiently removing background noise and providing clear foreground indications for the segmentation task by learning a specific mask for each classification.
Object point labelling is the use of points in the image to label the target object, and usually these points are located in the central region of the target object. Compared to pixel-level labelling, the cost of object point labelling is greatly reduced, but it can suffer from the problem of insufficient labelling. Bearman [15] et al. proposed point-level labelling for the first time, which significantly improves the performance of the model while keeping the labelling cost low through the combination of point-level supervision and objectivity prior. PCAMS [16] propagates the labels through the introduction of a class of activation maps with point-level supervision, which significantly improves the performance of the model, but its generalization ability in complex scenarios and its ability to handle small objects still need further validation.
Graffiti annotation, a method of delineating object regions by hand-drawn markings or contour lines, does not necessitate the precise delineation of boundaries. However, the accuracy of graffiti annotation is suboptimal, necessitating post-processing techniques to enhance the precision of the delineated object regions. In their seminal work, Zhang et al. [17] proposed a classification-driven graffiti boosting network that leverages the complementary information of graffiti and pseudo-tagging. The network incorporates a localization correction module that effectively addresses the issue of noise. SASFormer [18] introduces a Visual Transformer into the weakly supervised semantic segmentation task and proposes a hierarchical patch attention graph and an affinity loss function to significantly improve segmentation performance. However, SASFormer is characterized by high computational complexity and a dependence on the quality of initialized annotations.
Image-level annotation-based methods have become the focus of WSSS research due to their low acquisition cost and fast annotation speed compared to several other forms of weak labelling. The majority of extant image-level annotation-based WSSS methods employ convolutional neural networks as the classification network, after which the corresponding image features are obtained by the classification network. Class activation maps (CAMs) are then used to generate approximate target regions, and post-processing technological tools (e.g., refinement of the initial seeds [19]) are used to generate pseudo-labels to supervise the training of the segmentation network. However, CAM typically highlights only the most discriminative part of the region in the image, thus failing to provide a complete pseudo-mask. Consequently, researchers have proposed a plethora of innovative approaches to address this issue, which can be broadly categorized as follows: region erasure, region growing, additional supervised information, contrast learning, and so forth.
The process of region erasure has been shown to compel the network to pay closer attention to the remaining regions. This is achieved by erasing certain regions of the image. AE-PSL [20] proposes adversarial erasure and online prohibitive segmentation learning methods, which gradually identify the target region through adversarial erasure and reduce noise through online prohibitive segmentation learning. In the context of region growing methods, SEC [21] puts forward a set of three principles—seed, expand and constrain—with the aim of optimizing segmentation performance through the implementation of innovative global weighted rank pooling and boundary constrained loss. DSRG [22] employs a classification network to generate seed regions and trains the segmentation network by balancing the seed loss to gradually expand these regions to cover the entire object. Furthermore, there exist additional methodologies that employ supplementary supervised information to train the network, including the utilization of additional saliency maps and CLIP [23]-based supervision, amongst others. EPS [24] generates high-quality pseudo-pixel supervised information by combining saliency maps and image-level labelling, which significantly improves object boundaries and co-occurring pixel problems. CLIP-ES [25] takes full advantage of CLIP’s zero-sample capability and text–image alignment capability, and proposes to introduce a Softmax function into GradCAM [26] to significantly simplify the multi-stage process of traditional WSSS. POLE [27] was the first to introduce cue learning into WSSS, exploring the effect of classification labelling in cue words on CAM. LPCAM [28] extends the coverage of CAM by capturing non-discriminative and discriminative features to capture the object’s complete region. DSCNet [29] utilizes both pixel-level and semantic-level cross-image contextual information, employing a combination of pixel-level group contrast learning and semantic-level map contrast learning to address the limitations of existing methods in leveraging global semantic information. HSC [30] introduces multi-level semantic contrasts, encompassing ROI-level, classification-level, and pixel-level semantic contrasts. This multi-level contrast learning mechanism has the potential to assist the model in comprehending the semantic structure of the image and generating more accurate CAMs.
All of the aforementioned methods utilize convolutional neural networks (CNNs) as the backbone network, and in recent years, Vision Transformer (ViT) [31] has gained widespread attention due to its excellent global dependency modelling capability and its ability to capture contextual information over long distances. Consequently, several recent studies have adopted ViT as a classification model to generate high-quality CAMs. However, as illustrated in Figure 1, the cross-regional information interaction of ViT renders its feature learning for local regions ineffective, particularly when dealing with small targets in images. This results in the model’s inability to capture their complete semantic information, leading to small targets being easily ignored or incorrectly identified. This also leads to fuzzy target boundaries, which prevents accurate segmentation of fine-grained targets. Additionally, since the attention graph in ViT networks is classification-independent, the model may erroneously confuse the background region with the target classification, resulting in an attention distribution that is insufficiently focused, thus affecting the final segmentation outcome. Consequently, the development of effective optimization strategies for the ViT network is a significant area of research.
The work of TS-CAM [32] is inspired by the fact that class tokens in the standard Transformer can be arranged into class-independent attention graphs. The aim of TS-CAM is to couple CAMs with class-independent attention graphs in order to obtain positional cues in weak supervision. TransCAM [33] combines the Transformer as well as a CNN network. The attentional weights of the Transformer are used to refine the CAM of the CNN branches in order to obtain local features and global representations. MCTformer [34] introduces multiple class labels to generate class-specific attention graphs and refines the CAM with class-specific object localization maps and patch-level pairwise affinities. Thus, attentional learning from class labels to patch labels can generate class-specific attention graphs. ViT-PCM [35] proposes an alternative to CAM based on the localization property of the Visual Transformer by modelling the mapping mechanism between patch-level features and classification predictions. FBR [36] was proposed by Yin et al. to solve the problem of CAM methods having difficulty in distinguishing foreground objects from suspicious background pixels and being unable to activate the entire target area. AFA [37] suggests using the initial pseudo-labels as supervisory information to guide the training of self-attention, which leads to the learning of high-quality affinity information for pseudo-labelling improvement. ToCo [38] provides an alternative to CAM based on the localization property of the Visual Transformer by exploiting the intermediate layers of the semantic information to significantly alleviate the problem of over-smoothing of attention in ViT and to generate more accurate and complete CAMs. CSRM [39] was proposed by David et al. to address the constraints of pseudo-label uncertainty on training quality in WSSS. WeakTr [40] was proposed by Zhu et al., aiming to systematically explore the potential of naive Vision Transformers in WSSS tasks.

3. Method

In this paper, we propose a local–global class labelling comparison network to address ViT’s weak sensitivity to local features. As shown in Figure 2, the framework consists of a ViT feature extractor, a local–global class labelling comparison (LTG) module, a class-aware stimulus module (CSM), and feature fusion class-aware activation maps (FFCAM). The input image is locally cropped, and global and local class tokens are compared through contrastive learning to align local regions with global category semantics. CSM then transforms the original class-agnostic ViT attention into class-aware attention by injecting category constraints, thereby focusing the model on foreground regions and suppressing background noise. Finally, FFCAM fuses the ViT features with the class-aware attention features to refine the initial class activation map.

3.1. Local–Global Class Labelling Comparison Module

In this WSSS framework, ViT is utilized as a baseline network, employing a self-attention mechanism to construct global features. However, its local regions exhibit inadequate feature extraction capabilities, potentially resulting in incomplete foreground activation regions during segmentation. This may lead to erroneous activation of background regions. Inspired by TS-CAM [32] that class tokens can aggregate high-level semantic features, a local–global class token comparison (LTG) module is proposed, which aims to compare local regions with global class tokens to ensure that the classification-related local regions can be aligned with the global class tokens, which can improve the accuracy of activation regions.
As shown in Figure 3, for a given input image X H × W × M , where H , W are the height and width of the image and M is the number of channels, it is first subjected to random local cropping, and then both the original image and the cropped image are fed together into a ViT network to learn the features. The specific network structure in ViT is illustrated in Figure 4, where the input image is partitioned into non-overlapping patches (Patch) of a fixed size, and each Patch is of size w × h , which is then spread and linearly projected to generate Patch tokens T p N × D , where FA is the dimension of each patch and N = w × h . In addition, the class token T c l s 1 × D is a feature learning vector that captures the semantic information of an image, aggregates it with the Patch tokens and inputs it into the Transformer together with the Positional Embedding T p o s ( N + 1 ) × D , and interacts with it layer by layer through the self-attention mechanism to gradually aggregate the global semantic information. Since the class tags of ViT capture the high-level semantic information of the image related to the target classification, the class tags of global and local images aggregate the global and local object information, respectively. The input sequence gets output after a Transformer block, and the output global and local class tokens are finally taken out, and the comparison learning idea is used to compare the local region with the global class tokens and minimize the difference between the two (approximating the positive samples), and to ensure that the representation of the whole object region can be more consistent.
To cope with the case that the cropped local images do not contain foreground object regions, we crop some local images from the background region, which also suppresses the false activation of the background by maximizing the distance between the local background region and the global image class labels (pushing away the negative samples). In our experiments, we identified randomly cropped local images as positive examples (class-related foreground regions) and negative examples (background regions) based on the initial pseudo-labels.
Specifically, the output global class token and local class tokens are projected through projection heads p1 and p2, each consisting of a linear layer and L2 normalization. Let Q+ denote the set of local views that are semantically consistent with the global view (positive samples), and let Q denote the set of local views sampled from background or class-inconsistent regions (negative samples). LTG minimizes the discrepancy between the global representation and Q+ while maximizing its discrepancy from Q. We implement this objective using the InfoNCE loss [41], formulated as follows:
L l t g = 1 N + q + log e ( p q + / τ ) e ( p q + / τ ) + q e ( p q / τ )
where q + Q + denotes positive samples, q Q denotes negative samples, N + denotes the total number of positive samples, and τ is the temperature coefficient. Note that LTG aims to enhance the local view representation as a way to adjust the global view representation. Therefore, in the experiments, the gradient update of the projection head p1 is stopped. To update p1, we use an exponential moving average (EMA), which is corrected as follows:
θ 1 ρ θ 1 + ( 1 ρ ) θ 2
where ρ is the momentum factor, θ 1 denotes the parameters of the global view projection head p1, and θ 2 denotes the parameters of the local view projection head p2. The stable update of p1 can be maintained by EMA, while avoiding the noise of the local view to have a direct impact on the global view representation.

3.2. Class-Aware Stimulus Module

Current weakly supervised semantic segmentation methods rely on class activation maps (CAMs), but these methods usually capture only the most salient parts of an object and not the whole object. Existing Transformer-based WSSS methods use class-agnostic attention maps, resulting in background noise and bias in the final feature results. To address the above problems, this algorithm proposes the class-aware stimulus module (CSM). The CSM generates class-aware attention maps by injecting classification information into the Transformer’s self-attention maps.
Specifically, as shown in Figure 5, the class-aware stimulus module is based on an encoder–decoder structure that extracts more precise semantic information from the self-attention graph and enhances the class-awareness capability with an auxiliary classification loss. Assume that the attention matrix A m of the multi-head attention module in the Transformer block is as follows:
A m L × S × ( N + 1 ) × ( N + 1 )
where L denotes the number of blocks in Transformer, S denotes the number of heads in the multi-head attention mechanism, and N + 1 denotes the Patch tokens output dimension. First, the classification labelled attention vectors are extracted and reshaped from a Patch to obtain the attention graph:
A ¯ L × S × w × h
It aggregates the feature representations of all Transformer blocks and heads. However, A ¯ acquires information from different representation subspaces at different locations in the input image, including all regions of interest in the image, which makes it difficult for the final result to include specific local target regions. To solve this problem, the class-aware stimulus module is proposed to optimize A ¯ .
F a ( L S ) × w × h
A CNN-based encoder–decoder structure is then applied to extract more precise semantic information. The encoder structure is shown in Figure 5. It contains two convolutional layers and a max-pooling layer with stride 2, which yields the w/2 × h/2 output resolution specified in Equation (6).
F e G × w 2 × h 2
where G denotes the number of feature channels. The feature map F e is then up-sampled and spliced with the input feature map F a , and the connected feature maps are then passed through the convolutional layers of the two 3 × 3 to get the output feature map F c s m . Next, we add an auxiliary classification header after F c s m to improve the classification recognition capability. The classification header is composed of the convolutional layers of 1 × 1 and a global average pooling layer and produces the output feature map as follows:
F c s m C × w × h
The classification loss formula used by CSM is as follows:
L c s m = i C y i log ( e y ^ i C j C e y ^ j C )

3.3. Feature Fusion Class-Aware Activation Maps

In weakly supervised semantic segmentation tasks, which are not trained based on pixel-level labels but only using image-level labels, CAM, as a class-aware saliency map, can be used to extract rough regions of the target object to provide pseudo-labels for subsequent semantic segmentation tasks. However, CAM focuses only on the most discriminative regions and may misclassify classes. Based on the class-aware stimulus module proposed above, we proposed the feature fusion class-aware activation map (FFCAM) to optimize the CAM for enhanced classification perception.
Specifically, the whole process of feature fusion class-aware activation map generation is shown in Figure 6 and is expressed as follows:
M f u s e = ( M o u t + M c s m ) A m
The class activation map M o u t w × h is obtained from the image input to the final output features F o u t in the ViT network, and F o u t is optimized by the local–global class label comparison module to enable the network to pay more attention to local features. M c s m w × h is obtained from the feature attention graph F c s m generated by the class-aware stimulus module, and F c s m is enhanced by the class-aware stimulus mechanism to increase the network’s attention to the class-related regions, thus reducing the background error. denotes element-by-element multiplication. For A m , firstly, the averaging operator is used on the attention map A ¯ L × S × w × h along the block and head dimensions, and so the class-aware attention map A m w × h can be obtained, which is given by the following:
A m = 1 L S l L s S A ¯ ( l , s )
For the generation of the final feature fusion class-aware activation map M f u s e , M o u t is firstly summed with M c s m . Through this operation, the final feature map contains local–global contextual information, and emphasizes the class-aware capability to improve the recognition accuracy of the model. Then, an element-by-element multiplication operation is performed with the class-aware attention graph A m . The class-aware filtering through A m can improve the activation strength of the target region and enhance the semantic consistency. Finally, M f u s e is adjusted to the same size of the original image using linear interpolation to obtain the final feature fusion class-aware activation map.

4. Experiments

4.1. Experimental Environment and Dataset

In order to fully validate the effectiveness of the method, we conduct experiments on two datasets: the PASCAL VOC 2012 and the MS COCO 2014. The PASCAL VOC 2012 consists of 20 foreground semantic object classes and 1 background class, and the training, validation, and test sets consist of 1464, 1449, and 1456 images, respectively. MS COCO 2014 uses 80 foreground object classes and 1 background class with 82,081 images in the training set and 40,137 images in the validation set.
For the experimental network model, the ViT pre-trained on ImageNet-1K was used as the backbone network, and unlike multi-stage weakly supervised semantic segmentation, our single-stage approach uses only a simple segmentation header as the decoder, which consists of two convolutional layers (with an expansion rate of 5) and a prediction layer. For the PASCAL VOC 2012 dataset, the training batch size (Batch_Size) of the network is set to 2 and a total of 20,000 iterations are performed. For the MS COCO 2014 dataset, the network was trained over a total of 80,000 iterations with a Batch_Size of 1. The AdamW optimizer was used in the experiments to train our network, and the initial 1500 iterations were considered as a warm-up phase, during which the learning rate was 1 × 10−6, and was increased in a linear fashion up to 6 × 10−5, with the decay rate set to 0.9. For the input images, the global and local images are cropped to sizes 448 × 448 and 96 × 96 , respectively. The temperature coefficient τ in Equation (1) is 0.5. The momentum factor in the local–global class labelling comparison module EMA is set to 0.9. All the experiments in this algorithm are done on an NVIDIA RTX 3090 graphics device with the specific configuration shown in Table 1.

4.2. Experimental Evaluation Indicators

The semantic segmentation performance is evaluated using the Intersection over Union (IoU) and mean Intersection over Union (mIoU) metrics. IoU measures the overlap ratio between the predicted segmentation region and the ground-truth region, which is defined as follows:
IoU = T P F N + F P + T P
where TP, FP, and FN represent the numbers of true positive, false positive, and false negative pixels, respectively. Specifically, TP denotes the pixels that are correctly predicted as the target class; FP indicates the pixels incorrectly predicted as the target class but belonging to other classes; and FN represents the pixels belonging to the target class but incorrectly predicted as other classes.
For multi-class semantic segmentation tasks, the mean Intersection over Union (mIoU) is calculated by averaging the IoU values across all semantic classes:
m I o U = 1 C i = 1 C I o U i
To provide a multidimensional assessment beyond region overlap, we additionally report cosine similarity, mean absolute error (MAE), mean squared error (MSE), and root mean squared error (RMSE).
For a normalized prediction map P and ground-truth map G with N pixels, cosine similarity is defined as follows:
Cosine Similarity = i = 1 N P i G i i = 1 N P i 2 i = 1 N G i 2
MAE = 1 N i = 1 N | P i G i |
MSE = 1 N i = 1 N ( P i G i ) 2
RMSE = MSE
where Pi and Gi denote the predicted and ground-truth values of the i-th pixel, respectively.
Cosine similarity measures directional agreement between prediction and ground-truth (higher is better), whereas MAE, MSE, and RMSE measure pixel-wise prediction deviations (lower is better). Each metric is computed per image from normalized class-probability maps and then averaged over the validation set. These complementary criteria are reported with mIoU in Table 2.

4.3. Comparative Analysis of Experimental Results

This chapter validates the performance of the algorithm proposed in this paper through experiments on the PASCAL VOC 2012 and MS COCO 2014 datasets. The experimental analysis, which includes quantitative evaluation, qualitative visualization and comparison with existing methods, has comprehensively demonstrated the advantages of this paper’s algorithm in weakly supervised semantic segmentation tasks.
In weakly supervised semantic segmentation tasks, the quality of pseudo-labels directly affects the final segmentation performance. Therefore, we set up a set of experiments to evaluate the quality of pseudo-tags generated by different methods. As shown in Table 2, comparisons are made on SEAM, SLRNet, ViT-PCM, AFA, MCTformer, ToCo and WeakTr methods on the PASCAL VOC 2012 dataset.
The comparison includes every method reported in Table 2, Table 3 and Table 4. The multi-stage group contains NSROM (ResNet101), EPS (ResNet101 with saliency-based pseudo-pixel supervision), L2G (ResNet101 with local-to-global representation transfer), CLIP-ES (ResNet101 with CLIP-derived text–image cues), SEAM (ResNet38 with equivariant self-attention), SIPE (ResNet101), and W-OoD (ResNet38). The Transformer-based group contains MCTformer (DeiT-S with multiple class tokens), ViT-PCM (ViT-B with patch-class mapping), AFA (MiT-B1 with affinity learning), SLRNet (ResNet38), ToCo (ViT-B with token contrast), and WeakTr (ViT-B). In contrast, our ViT-B framework combines LTG local–global contrastive learning, CSM class-aware attention, and FFCAM feature fusion in a single stage without external saliency or text supervision. This unified comparison makes the architectural and supervision differences explicit when interpreting the reported results.
As the results show, it can be seen that the pseudo-labelled mIoU generated by the present method achieves 73.4% as well as 72.3% on the training and validation sets, respectively, which represents competitive performance among the methods compared in Table 2. Compared with the SEAM method, the present method improves nearly 10 percentage points on the training set and validation set, respectively. Compared to the suboptimal ToCo, it has increased by 1.2 and 1.8 percentage points. This advantage validates the effectiveness of the pseudo-label generation strategy proposed in this paper in suppressing noise and preserving the integrity of target boundaries, while also indicating its stronger generalization ability and minimal accuracy degradation in the validation set (only 1.1%).
In order to further validate the effectiveness of the methods, the segmentation results of the current state-of-the-art methods are compared on the PASCAL VOC 2012 dataset, and the comparisons include the multi-stage WSSS methods NSROM, EPS, L2G, CLIP-ES, SEAM, and SIPE, W-OoD, MCTformer, and the single-stage methods AFA, SLRNet, ToCo and WeakTr. Table 3 shows the segmentation comparison results on the PASCAL VOC 2012 dataset segmentation comparison results, the third column in Table 3 indicates whether additional supervised information is used or not; Table 3 also indicates the use of pixel-level labelling information, the use of additional external salient maps, and the use of textual-linguistic supervised information.
Among single-stage methods, AFA, SLRNet, and ToCo obtain validation mIoU values of 66.3%, 67.6%, and 70.5%, respectively, while WeakTr reports 78.4%. Our method achieves 78.5% on the validation set, showing competitive performance among the compared single-stage methods.
Multi-stage methods such as NSROM, EPS, L2G, and CLIP-ES generally require iterative refinement or additional supervision. The strongest L2G and MCTformer validation scores are 71.7% and 71.6%, respectively. Our verified 78.5% result is 6.8 percentage points above L2G, demonstrating the effectiveness of the single-stage design while avoiding multi-stage error accumulation.
The advantages of our method mainly come from the following: firstly, the high-quality pseudo-label generation strategy provides more reliable supervision signals for the segmentation model; secondly, the end-to-end single-stage training based on ViT-B avoids error accumulation and additional module overhead in multi-stage methods.
On the MS COCO 2014 dataset, for the final segmentation results of the network, this paper is quantitatively compared with the multi-stage methods EPS, L2G, SEAM, SIPE, MCTformer, and the single-stage methods SLRNet, AFA, ToCo, WeakTr. As shown in Table 4, where it is denoted that the network uses additional supervisory information, the algorithm in this paper achieves better results among many methods.
In the single-stage method, the validation set accuracies of SLRNet, AFA, and ToCo are 35.0, 38.9, and 41.3, respectively, indicating relatively low performance. WeakTr reached 50.3, significantly better than previous methods. On this basis, the method in this article has been further improved to 50.9, showing competitive performance among the compared single-stage methods. Compared to WeakTr, it has increased by 0.6 percentage points. Although the absolute increase is not significant, even a small improvement on large-scale, multi class datasets like COCO requires substantial improvements in pseudo-label quality and model robustness. Meanwhile, this method does not require additional complex designs that WeakTr may rely on, demonstrating a better balance between efficiency and accuracy.
Among the multi-stage methods, L2G (42.0) and MCTformer (42.0) performed better, with SIPE of 40.6, EPS of 35.7, and SEAM of only 31.9. Compared with L2G/MCTformer, the method proposed in this article (50.9) has improved by 8.9 percentage points, with a relative increase of over 20%. This indicates that traditional multi-stage iterative refinement strategies are easily limited by the noise accumulation of initial pseudo-labels in scenarios such as COCO, which contain a large number of small targets, overlapping instances, and complex backgrounds. This article is based on the single-stage framework of ViT-B, which generates higher quality pseudo-labels (as shown in Table 2, a pseudo-label accuracy of 72.3 on VOC, with similar advantages on COCO) and trains the segmentation model end-to-end, effectively avoiding error diffusion and having more obvious advantages on complex datasets.
Table 5 reports class-wise IoU on the PASCAL VOC 2012 validation set. Using 78.5% as the verified headline result, the class-wise entries and reported mean are mutually consistent. The proposed method achieves strong results for background (96.0%), bicycle (47.2%), bird (92.8%), bottle (88.8%), cat (95.7%), cow (96.7%), and sheep (92.5%), showing improved coverage for both small structures and large foreground regions.
In order to show the effectiveness of this paper’s algorithm more intuitively, we compare the class activation maps generated by the ViT benchmark network as well as the ToCo algorithm. As shown in Figure 7, the feature fusion class-aware activation maps generated by this paper’s algorithm are closer to the real labels, focus more on the local feature regions than the class activation maps generated by ViT, generate more complete response regions for small target objects, and are more refined in some boundary regions, e.g., the ear region of the sheep in Figure 7. This demonstrates that the local–global class labelling comparison algorithm proposed in this paper leads to enhanced classification consistency in local regions and more complete activation for small target regions. In addition, the class-aware attention generated by the proposed class-aware stimulus module can direct the ViT to focus on the correct target region, improve the differentiation of target classes, and further suppress the background noise.
The experiment also visualizes the PASCAL VOC 2012 and MS COCO 2014 segmentation results compared with the ToCo algorithm and the visualization results are shown in Figure 8. Panels (a), (b), (c) and (d) represent the results of the original image, real labels, ToCo and this paper’s algorithm, respectively. Through the visualization experiment comparison, it is found that this paper’s algorithm has significant enhancement in local features, generates a more complete region for some small target objects, has strong sensitivity to edge texture, and has a corrective effect for background mis-activation.
The chair category remains challenging, but our method reaches 36.5%. The train and television categories obtain 68.2% and 66.0%, respectively. Together with the 78.5% mean, these results indicate stable performance across categories with different shapes and background contexts.
The proposed method maintains an IoU above 36% for every class and reaches a mean of 78.5%. This balanced class-wise behaviour is consistent with the design of LTG, which strengthens local semantic consistency, and CSM, which suppresses category-irrelevant background activation.
As reported in Table 6, the proposed method shows favourable cosine similarity, MAE, MSE, and RMSE values among the compared methods. The complementary metrics therefore agree with the mIoU comparison: the predicted probability maps are more directionally consistent with the ground-truth and exhibit smaller pixel-wise deviations.
To complement the accuracy comparison, Table 7 reports parameter count and single-image inference time for representative CNN- and Transformer-based competitors under the same RTX 3090 environment. Our model has slightly more parameters and a modestly longer inference time than WeakTr and ToCo, while the accuracy gain on VOC and COCO offsets this limited efficiency cost. Compared with the CNN-based SEAM baseline, the single-stage ViT framework provides substantially higher segmentation accuracy with acceptable inference overhead.

4.4. Ablation Experiments

In order to further analyze the effectiveness of the method proposed in this paper, in this section, we conduct a series of ablation experimental studies. All the ablation experiments are conducted on the PASCAL VOC 2012 dataset, which mainly reports the mean intersection and merger ratio (mIoU) scores of the final CAMs generated on the validation set and the mean intersection and merger ratio (mIoU) scores of the semantic segmentation results. The main purpose of the ablation experiments is to evaluate the roles played by the local–global class labelling contrast module (LTG), the classification sense stimulus module (CSM), and the feature fusion classification aware activation map (FFCAM).
Table 8 evaluates LTG, CSM, and FFCAM on PASCAL VOC 2012. The ViT baseline obtains 47.8% segmentation mIoU. Adding LTG increases the result to 63.6%. Adding CSM further improves it from 63.6% to 69.7% (+6.1 points), and replacing conventional CAM with FFCAM raises the full-model result from 69.7% to 78.5% (+8.8 points). The corresponding CAM mIoU values progress from 49.7% to 63.0%, 69.4%, and 73.3%.
In addition, the experiment visualizes the class activation maps generated by each group of components on the network, as shown in Figure 9, from which it is visually and intuitively obvious to find out the importance of each component for the optimization of the network model. The algorithm proposed in this paper continuously optimizes the initial CAM generated by ViT, which makes the network have a good response to the local small object features, and also provides a better solution to the problem of ViT incorrectly activating the background region as the foreground region.
The local–global class token comparison module is designed to facilitate a comparative analysis of the image representations of local and global views. The primary objective of this module is to ensure the maintenance of feature consistency within the target region across both local and global views. Additionally, it aims to enable the model to differentiate between various object regions. However, the size of the local crop image can pose a challenge, as a smaller local image may not contain foreground target objects, potentially leading to a target mismatch. Conversely, larger local images may contain an excessive number of foreground objects, resulting in a local view that is too similar to the global view, thereby hindering the full utilization of LTG for comparison learning. This paper presents an experimental study on the impact of local cropping size in LTG, as outlined in Table 9. The experimental results demonstrate that the optimal performance is achieved by cropping the local image to the size of 96 × 96.
Small crops may omit complete foreground semantics, whereas excessively large crops reduce the difference between local and global views and weaken contrastive learning. A crop size of 96 × 96 provides the best balance, achieving 73.3% CAM mIoU and 78.5% segmentation mIoU.
In LTG, the global projection head p1 is updated by EMA. Table 10 evaluates the influence of the EMA momentum factor and shows that 0.9 provides the best result.
A small momentum factor causes unstable updates and introduces noise into the global representation, whereas an excessively large factor adapts too slowly to local semantic changes. Momentum 0.9 provides the best balance, reaching 73.3% CAM mIoU and 78.5% segmentation mIoU.

5. Conclusions

This study proposes a ViT-based weakly supervised semantic segmentation framework that addresses local feature insensitivity and background confusion. LTG aligns local views with global class semantics through contrastive learning. CSM transforms class-agnostic self-attention into class-aware attention by injecting category constraints. FFCAM then fuses ViT features with class-aware attention features to obtain more complete activation maps. Experiments on PASCAL VOC 2012 and MS COCO 2014 demonstrate the effectiveness of the proposed components and the overall single-stage framework.
Although we achieve excellent performance in multiple experiments, there are still some directions worth further research and optimization. The algorithm in this article is based on the Vision Transformer network for experimentation. Although ViT performs well in semantic segmentation tasks, its computational complexity is relatively high. Therefore, in the future, lightweight models can be adopted to reduce computational complexity and enable deployment on lower configured mobile or embedded devices, thereby enhancing the feasibility of practical applications.

Author Contributions

Conceptualization, B.G. and C.W.; methodology, B.G. and L.Y.; validation, L.Y.; writing—original draft preparation, B.G. and Y.Y.; writing—review and editing, L.Y.; visualization, B.G.; supervision, Y.Y.; project administration, C.W.; funding acquisition, C.W. All authors have read and agreed to the published version of the manuscript.

Funding

Acknowledgements This work was supported in part by the National Natural Science Foundation of China under Grant (62302155) and Wuhan International Cooperation Project (2025071204030386).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The original contributions presented in the study are included in the article; further inquiries can be directed to the corresponding author.

Acknowledgments

The authors are thankful to the providers for all the datasets used in this study. We also thank the anonymous reviewers and editors for their comments to improve this paper.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Yan, L.; Chen, J.; Tang, Y. TSD-CAM: Transformer-based self distillation with CAM similarity for weakly supervised semantic segmentation. J. Electron. Imaging 2024, 33, 023029. [Google Scholar] [CrossRef] [Scilit]
  2. Long, J.; Shelhamer, E.; Darrell, T. Fully convolutional networks for semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2015; pp. 3431–3440. [Google Scholar]
  3. Zhou, B.; Khosla, A.; Lapedriza, A.; Oliva, A.; Torralba, A. Learning deep features for discriminative localization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2016; pp. 2921–2929. [Google Scholar]
  4. Yoon, S.H.; Kwon, H.; Kim, H.; Yoon, K.J. Class tokens infusion for weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2024; pp. 3595–3605. [Google Scholar]
  5. Wang, J.; Dai, T.; Zhang, B.; Yu, S.; Lim, E.G.; Xiao, J. Class token as proxy: Optimal transport-assisted proxy learning for weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF International Conference on Computer Vision; IEEE: New York, NY, USA, 2025; pp. 21645–21654. [Google Scholar]
  6. Hanna, J.; Borth, D. Know your attention maps: Class-specific token masking for weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF International Conference on Computer Vision; IEEE: New York, NY, USA, 2025; pp. 23763–23772. [Google Scholar]
  7. Xie, E.; Wang, W.; Yu, Z.; Anandkumar, A.; Alvarez, J.M.; Luo, P. SegFormer: Simple and efficient design for semantic segmentation with transformers. Adv. Neural Inf. Process. Syst. 2021, 34, 12077–12090. [Google Scholar]
  8. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention is all you need. Adv. Neural Inf. Process. Syst. 2017, 30, 30–35. [Google Scholar]
  9. Zhang, J.; Liu, R.; Shi, H.; Yang, K.; Reiß, S.; Peng, K.; Fu, H.; Wang, K.; Stiefelhagen, R. Delivering arbitrary-modal semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2023; pp. 1136–1147. [Google Scholar]
  10. Lee, J.; Yi, J.; Shin, C.; Yoon, S. Bbam: Bounding box attribution map for weakly supervised semantic and instance segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2021; pp. 2643–2652. [Google Scholar]
  11. Khoreva, A.; Benenson, R.; Hosang, J.; Hein, M.; Schiele, B. Simple does it: Weakly supervised instance and semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2017; pp. 876–885. [Google Scholar]
  12. Song, C.; Huang, Y.; Ouyang, W.; Wang, L. Box-driven class-wise region masking and filling rate guided loss for weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2019; pp. 3136–3145. [Google Scholar]
  13. Bearman, A.; Russakovsky, O.; Ferrari, V.; Fei-Fei, L. What’s the point: Semantic segmentation with point supervision. In ECCV; Springer: Berlin/Heidelberg, Germany, 2016; pp. 549–565. [Google Scholar]
  14. Wei, J.; Lin, G.; Yap, K.H.; Hung, T.Y.; Xie, L. Multi-path region mining for weakly supervised 3D semantic segmentation on point clouds. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2020; pp. 4384–4393. [Google Scholar]
  15. Zhang, X.; Zhu, L.; He, H.; Jin, L.; Lu, Y. Scribble hides class: Promoting scribble-based weakly-supervised semantic segmentation with its class label. In Proceedings of the AAAI Conference on Artificial Intelligence, Vancouver, BC, Canada, 20–27 February 2024; Volume 38, pp. 7332–7340. [Google Scholar]
  16. Su, H.; Ye, Y.; Hua, W.; Cheng, L.; Song, M. SASFormer: Transformers for Sparsely Annotated Semantic Segmentation. In Proceedings of the IEEE International Conference on Multimedia and Expo (ICME); IEEE: New York, NY, USA, 2023. [Google Scholar]
  17. Englebert, A.; Cornu, O.; Vleeschouwer, C.D. Poly-cam: High resolution class activation map for convolutional neural networks. Mach. Vis. Appl. 2024, 35, 89. [Google Scholar] [CrossRef] [Scilit]
  18. Wei, Y.; Feng, J.; Liang, X.; Cheng, M.M.; Zhao, Y.; Yan, S. Object region mining with adversarial erasing: A simple classification to semantic segmentation approach. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2017; pp. 1568–1576. [Google Scholar]
  19. Kolesnikov, A.; Lampert, C.H. Seed, expand and constrain: Three principles for weakly-supervised image segmentation. In Computer Vision–ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, 11–14 October 2016, Proceedings, Part IV 14; Springer International Publishing: Cham, Switzerland, 2016; pp. 695–711. [Google Scholar]
  20. Huang, Z.; Wang, X.; Wang, J.; Liu, W.; Wang, J. Weakly-supervised semantic segmentation network with deep seeded region growing. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2018; pp. 7014–7023. [Google Scholar]
  21. Radford, A.; Kim, J.W.; Hallacy, C.; Ramesh, A.; Goh, G.; Agarwal, S.; Sastry, G.; Askell, A.; Mishkin, P.; Clark, J.; et al. Learning transferable visual models from natural language supervision. In Proceedings of the International Conference on Machine Learning, Online, 18–24 July 2021; PmLR: Cambridge, MA, USA, 2021; pp. 8748–8763. [Google Scholar]
  22. Lee, S.; Lee, M.; Lee, J.; Shim, H. Railroad is not a train: Saliency as pseudo-pixel supervision for weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2021; pp. 5495–5505. [Google Scholar]
  23. Lin, Y.; Chen, M.; Wang, W.; Wu, B.; Li, K.; Lin, B.; Liu, H.; He, X. Clip is also an efficient segmenter: A text-driven approach for weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2023; pp. 15305–15314. [Google Scholar]
  24. Selvaraju, R.R.; Cogswell, M.; Das, A.; Vedantam, R.; Parikh, D.; Batra, D. Grad-cam: Visual explanations from deep networks via gradient-based localization. In Proceedings of the IEEE International Conference on Computer Vision; IEEE: New York, NY, USA, 2017; pp. 618–626. [Google Scholar]
  25. Murugesan, B.; Hussain, R.; Bhattacharya, R.; Ben Ayed, I.; Dolz, J. Prompting classes: Exploring the power of prompt class learning in weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision; IEEE: New York, NY, USA, 2024; pp. 291–302. [Google Scholar]
  26. Chen, Z.; Sun, Q. Extracting class activation maps from non-discriminative features as well. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2023; pp. 3135–3144. [Google Scholar]
  27. Lai, Q.; Vong, C.M.; Chen, C. Weakly Supervised Semantic Segmentation via Dual-Stream Contrastive Learning of Cross-Image Contextual Information. In Proceedings of the IEEE Transactions on Industrial Informatics; IEEE: New York, NY, USA, 2024. [Google Scholar]
  28. Wu, Y.; Li, X.; Dai, S.; Li, J.; Liu, T.; Xie, S. Hierarchical Semantic Contrast for Weakly Supervised Semantic Segmentation. In Proceedings of the IJCAI—International Joint Conference on Artificial Intelligence, Macao, China, 19–25 August 2023; pp. 1542–1550. [Google Scholar]
  29. Mao, X.; Qi, G.; Chen, Y.; Li, X.; Duan, R.; Ye, S.; He, Y.; Xue, H. Towards robust vision transformer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2022; pp. 12042–12051. [Google Scholar]
  30. Gao, W.; Wan, F.; Pan, X.; Peng, Z.; Tian, Q.; Han, Z.; Zhou, B.; Ye, Q. Ts-cam: Token semantic coupled attention map for weakly supervised object localization. In Proceedings of the IEEE/CVF International Conference on Computer Vision; IEEE: New York, NY, USA, 2021; pp. 2886–2895. [Google Scholar]
  31. Li, R.; Mai, Z.; Zhang, Z.; Jang, J.; Sanner, S. Transcam: Transformer attention-based cam refinement for weakly supervised semantic segmentation. J. Vis. Commun. Image Represent. 2023, 92, 103800. [Google Scholar] [CrossRef] [Scilit]
  32. Xu, L.; Ouyang, W.; Bennamoun, M.; Boussaid, F.; Xu, D. Multi-class token transformer for weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2022; pp. 4310–4319. [Google Scholar]
  33. Rossetti, S.; Zappia, D.; Sanzari, M.; Schaerf, M.; Pirri, F. Max pooling with vision transformers reconciles class and shape in weakly supervised semantic segmentation. In European Conference on Computer Vision; Springer Nature: Cham, Switzerland, 2022; pp. 446–463. [Google Scholar]
  34. Ru, L.; Zhan, Y.; Yu, B.; Du, B. Learning affinity from attention: End-to-end weakly-supervised semantic segmentation with transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2022; pp. 16846–16855. [Google Scholar]
  35. Ru, L.; Zheng, H.; Zhan, Y.; Du, B. Token contrast for weakly-supervised semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2023; pp. 3093–3102. [Google Scholar]
  36. Yin, X.; Im, W.; Min, D.; Huo, Y.; Pan, F.; Yoon, S.E. Fine-Grained Background Representation for Weakly Supervised Semantic Segmentation. IEEE Trans. Circuits Syst. Video Technol. 2024, 34, 11739–11750. [Google Scholar] [CrossRef] [Scilit]
  37. Qin, Y.; Pu, N.; Wu, H.; Sebe, N. Margin-aware Noise-robust Contrastive Learning for Partially View-aligned Problem. ACM Trans. Knowl. Discov. From Data 2025, 19, 1–20. [Google Scholar] [CrossRef] [Scilit]
  38. Tang, J.; Cheng, K.; Wei, L.; Zhan, Y. Inter-image Token Relation Learning for weakly supervised semantic segmentation. J. Vis. Commun. Image Represent. 2025, 112, 104576. [Google Scholar] [CrossRef] [Scilit]
  39. David, L.; Pedrini, H.; Dias, Z. Learning Weakly Supervised Semantic Segmentation Through Cross-Supervision and Contrasting of Pixel-Level Pseudo-Labels. In Proceedings of the 20th International Joint Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications (VISAPP), Porto, Portugal, 26–28 February 2025; pp. 154–165. [Google Scholar]
  40. Zhu, L.; Li, Y.; Fang, J.; Liu, Y.; Xin, H.; Liu, W.; Wang, X. WeakTr: Exploring Plain Vision Transformer for Weakly-supervised Semantic Segmentation. IEEE Trans. Image Process. 2026, 35, 4425–4439. [Google Scholar] [CrossRef] [Scilit]
  41. van den Oord, A.; Li, Y.; Vinyals, O. Representation learning with contrastive predictive coding. arXiv 2018, arXiv:1807.03748. [Google Scholar]
Figure 1. Inadequate local feature extraction for ViT in weakly supervised semantic segmentation.
Figure 1. Inadequate local feature extraction for ViT in weakly supervised semantic segmentation.
Applsci 16 08496 g001
Figure 2. Local–global class labelling comparison network.
Figure 2. Local–global class labelling comparison network.
Applsci 16 08496 g002
Figure 3. Local cropping.
Figure 3. Local cropping.
Applsci 16 08496 g003
Figure 4. Detailed structure of ViT.
Figure 4. Detailed structure of ViT.
Applsci 16 08496 g004
Figure 5. CSM encoder structure.
Figure 5. CSM encoder structure.
Applsci 16 08496 g005
Figure 6. Feature fusion class-aware activation map.
Figure 6. Feature fusion class-aware activation map.
Applsci 16 08496 g006
Figure 7. Comparison of class activation graph visualizations.
Figure 7. Comparison of class activation graph visualizations.
Applsci 16 08496 g007
Figure 8. Comparison of qualitative visualization of segmentation results.
Figure 8. Comparison of qualitative visualization of segmentation results.
Applsci 16 08496 g008
Figure 9. Component ablation experiment based on CAM results.
Figure 9. Component ablation experiment based on CAM results.
Applsci 16 08496 g009
Table 1. Experimental environment.
Table 1. Experimental environment.
TypeEnvironmental Conditions
SystemUbuntu 16.04
GPUNVIDIA RTX 3090
RAM64 GB
CPUIntel(R) Xeon(R) 8255C
FrameworkPytorch 1.13
Table 2. Pseudo-label mIoU (%) on PASCAL VOC 2012.
Table 2. Pseudo-label mIoU (%) on PASCAL VOC 2012.
MethodBackbonePseudo-Label mIoU (%)
Training
Pseudo-Label mIoU (%)
Validation
SEAMResNet3863.662.1
SLRNetResNet3867.166.2
ViT-PCMViT-B67.766.0
AFAMiT-B168.766.5
MCTformerDeiT-S69.168.2
ToCoViT-B72.270.5
WeakTrViT-B72.070.2
OursViT-B73.472.3
Table 3. Segmentation mIoU (%) on PASCAL VOC 2012. I: image-level labels; S: external saliency supervision.
Table 3. Segmentation mIoU (%) on PASCAL VOC 2012. I: image-level labels; S: external saliency supervision.
MethodBackboneSupervisionSegmentation mIoU (%)
Training
Segmentation mIoU (%)
Validation
Multi-stage WSSS
NSROMResNet101 I + S 68.368.5
EPSResNet101 I + S 70.970.8
L2GResNet101 I + S 72.171.7
CLIP-ESResNet101 I + L 71.171.4
SEAMResNet38 I 6565.7
SIPEResNet101 I 68.869.7
W-OoDResNet38 I 70.770.1
MCTformerDeiT-S I 71.971.6
Single-stage WSSS
AFAMiT-B1 I 66.066.3
SLRNetResNet38 I 67.267.6
ToCoViT-B I 69.870.5
WeakTrViT-B I -78.4
OursViT-B I 73.878.5
Table 4. Validation segmentation mIoU (%) on MS COCO 2014. I: image-level labels; S: external saliency supervision.
Table 4. Validation segmentation mIoU (%) on MS COCO 2014. I: image-level labels; S: external saliency supervision.
MethodBackboneSupervisionValidation Segmentation mIoU (%)
Multi-stage WSSS
EPSResNet101 I + S 35.7
L2GResNet101 I + S 42
SEAMResNet38 I 31.9
SIPEResNet101 I 40.6
MCTformerDeiT-S I 42.0
Single-stage WSSS
SLRNetWResNet38 I 35.0
AFAMiT-B1 I 38.9
ToCoViT-B I 41.3
WeakTrViT-B I 50.3
OursViT-B I 50.9
Table 5. Comparison of IoU per classification in the PASCAL VOC 2012 dataset.
Table 5. Comparison of IoU per classification in the PASCAL VOC 2012 dataset.
ClassSEAMAFATransCAMToCoOurs
bkg88.889.991.389.996.0
aero68.579.581.981.887.0
bike33.331.235.435.447.2
bird85.780.78768.192.8
boat40.467.267.662.074.0
bottle67.361.967.976.688.8
bus78.981.487.583.691.8
car76.365.480.580.485.5
cat81.982.386.587.795.7
chair29.128.731.42536.5
cow75.583.473.988.196.7
table48.141.652.55962.7
dog79.982.28087.091.6
horse73.875.9798086.9
motor71.470.27676.080.8
person75.269.479.068.284.8
plant48.953.04765.669.8
sheep79.885.98185.892.5
sofa40.94147.042.453.2
train58.26278.457.768.2
tv53.050.946.665.666.0
mIoU65.066.069.369.878.5
Table 6. Complementary evaluation metrics on the PASCAL VOC 2012 validation set.
Table 6. Complementary evaluation metrics on the PASCAL VOC 2012 validation set.
MethodmIoU (%)Cosine SimilarityMAEMSERMSE
AFA66.30.8240.1370.0480.219
ToCo70.50.8730.1120.0350.187
WeakTr78.40.9080.0830.0230.152
Ours78.50.9140.0790.0210.145
Table 7. Model complexity and single-image inference time on an NVIDIA RTX 3090.
Table 7. Model complexity and single-image inference time on an NVIDIA RTX 3090.
MethodBackboneParams (M)Inference Time (ms)
SEAMResNet3841.248.6
ToCoViT-B86.372.5
MCTformerDeiT-S44.761.3
WeakTrViT-B86.374.1
OursViT-B88.176.8
Table 8. Ablation study of the proposed components (“√” means the corresponding module is used).
Table 8. Ablation study of the proposed components (“√” means the corresponding module is used).
MethodLTGCSMFFCAMCAM (%)Seg. (%)
Baseline---49.747.8
Ours --6363.6
-69.469.7
73.378.5
Table 9. Effect of local-view crop size on CAM and segmentation mIoU (%).
Table 9. Effect of local-view crop size on CAM and segmentation mIoU (%).
SizeCAM mIoU (%)Segmentation mIoU (%)
64 × 64 69.667.1
80 × 80 71.269.6
96 × 96 73.378.5
112 × 112 72.470.1
Table 10. Effect of EMA momentum on CAM and segmentation mIoU (%).
Table 10. Effect of EMA momentum on CAM and segmentation mIoU (%).
SizeCAM mIoU (%)Segmentation mIoU (%)
070.168.6
0.172.770.4
0.973.378.5
0.9971.769.1
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Guo, B.; Yu, L.; Yang, Y.; Wang, C. A Weakly Supervised Segmentation Algorithm Based on Local–Global Class Labelling Comparison. Appl. Sci. 2026, 16, 8496. https://doi.org/10.3390/app16178496

AMA Style

Guo B, Yu L, Yang Y, Wang C. A Weakly Supervised Segmentation Algorithm Based on Local–Global Class Labelling Comparison. Applied Sciences. 2026; 16(17):8496. https://doi.org/10.3390/app16178496

Chicago/Turabian Style

Guo, Binyu, Laibao Yu, Yiming Yang, and Chunzhi Wang. 2026. "A Weakly Supervised Segmentation Algorithm Based on Local–Global Class Labelling Comparison" Applied Sciences 16, no. 17: 8496. https://doi.org/10.3390/app16178496

APA Style

Guo, B., Yu, L., Yang, Y., & Wang, C. (2026). A Weakly Supervised Segmentation Algorithm Based on Local–Global Class Labelling Comparison. Applied Sciences, 16(17), 8496. https://doi.org/10.3390/app16178496

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop