Abstract
Weakly Supervised Semantic Segmentation (WSSS) aims to train segmentation models using only image-level labels, significantly reducing annotation costs. However, traditional methods relying on Class Activation Maps (CAMs) often produce coarse and incomplete masks. This paper introduces a novel single-stage WSSS method that leverages the inherent spatial awareness of Vision Transformers (ViTs). By introducing class-specific [CLS] tokens, a random masking strategy during training, and attention head pruning, the proposed architecture generates high-quality pseudo-masks directly from self-attention maps. Experimental results on PASCAL VOC, MS COCO, and specialized datasets like DFC2020 demonstrate state-of-the-art performance, even surpassing fully supervised baselines in specific domains.
Introduction
Semantic segmentation is a critical task in computer vision, yet its reliance on pixel-level annotations makes it prohibitively expensive for large-scale or specialized applications. Weakly Supervised Semantic Segmentation (WSSS) offers a solution by utilizing cheaper image-level labels. Historically, WSSS has relied on Class Activation Maps (CAMs), which typically highlight only the most discriminative object parts and require auxiliary modules.
Vision Transformers (ViTs) offer a promising alternative due to their global receptive field and self-attention mechanism. However, standard ViTs use a single global [CLS] token, making it difficult to disentangle class-specific information in multi-object scenes. This paper addresses these challenges by modifying the ViT architecture to produce interpretable, class-specific attention maps that serve as accurate pseudo-masks for downstream segmentation tasks.
Methodology
The core of the proposed method is an end-to-end pipeline based on a ViT-B architecture, enhanced with several key components to ensure class-specific interpretability.
- Class-specific Tokens: Instead of a single
[CLS]token, the model uses $C$ tokens, where $C$ is the number of classes. Each token is responsible for capturing features related to its specific class. - Register Token ([REG]): A dedicated register token is added to act as a "sink" for global context and background noise, preventing these elements from interfering with the spatial attention maps of the class tokens.
- Random Masking Strategy: To prevent "lazy routing" where features bleed across tokens, the model randomly masks 50% of the
[CLS]tokens not present in the image during training. This forces the network to establish a hard assignment between a class token and its corresponding visual features. - Attention Head Pruning: The authors observe that many attention heads contribute noise rather than structure. By using a stochastic relaxation method to prune approximately two-thirds of the heads, the model retains only the most structurally relevant attention patterns.
- Pseudo-mask Generation: During inference, the self-attention maps from the predicted class tokens are reshaped and binarized to form pseudo-masks, which then train a standard U-Net for final segmentation.
Experiments and Results
The method was evaluated on standard benchmarks (PASCAL VOC 2012, MS COCO 2014) and specialized datasets (DFC2020 for remote sensing, EndoTect for medical imaging, and ADE20K).
On PASCAL VOC, the method achieved a pseudo-mask mIoU of 73.7%, outperforming previous single-stage state-of-the-art methods. In specialized domains, the performance was even more striking; on the DFC2020 dataset, the model achieved 74.1% pixel accuracy, exceeding the performance of a fully supervised baseline (70%).
Ablation studies confirmed the importance of the proposed components. Removing random masking led to a decrease in mIoU on MS COCO from 43.2% to 41.9%, while omitting head pruning dropped performance to 41.7%. These results highlight that both specialization through masking and sparsity through pruning are essential for high-quality segmentation.
Discussion and Insights
The success of this approach lies in forcing the network to specialize. The random masking strategy effectively solves the interference problem in multi-label classification within ViTs. Furthermore, the inclusion of the [REG] token validates the need for a non-spatial "dumping ground" for global information, which significantly sharpens object boundaries in the resulting masks. The pruning of attention heads further proves that sparsity is key for interpretability; retaining all heads leads to fragmented, noisy attention patterns.
Conclusion
This paper presents a robust, single-stage framework for WSSS that turns ViT attention maps into high-fidelity pseudo-masks. While the linear scaling of [CLS] tokens with the number of classes presents a challenge for very large taxonomies, the method sets a new standard for efficiency and accuracy in weakly supervised tasks. Future work will focus on dynamic token assignment to improve scalability for massive datasets.
Summary updated