Abstract
In this work, we propose a new transformer-based regularization to better localize objects for Weakly supervised semantic segmentation (WSSS). In image-level WSSS, Class Activation Map (CAM) is adopted to generate object localization as pseudo segmentation labels. To address the partial activation issue of the CAMs, consistency regularization is employed to maintain activation intensity invariance across various image augmentations. However, such methods ignore pair-wise relations among regions within each CAM, which capture context and should also be invariant across image views. To this end, we propose a new all-pairs consistency regularization (ACR). Given a pair of augmented views, our approach regularizes the activation intensities between a pair of augmented views, while also ensuring that the affinity across regions within each view remains consistent. We adopt vision transformers as the self-attention mechanism naturally embeds pair-wise affinity. This enables us to simply regularize the distance between the attention matrices of augmented image pairs. Additionally, we introduce a novel class-wise localization method that leverages the gradients of the class token. Our method can be seamlessly integrated into existing WSSS methods using transformers without modifying the architectures. We evaluate our method on PASCAL VOC and MS COCO datasets. Our method produces noticeably better class localization maps (67.3% mIoU on PASCAL VOC train), resulting in superior WSSS performances.
Introduction
Semantic segmentation is a cornerstone of computer vision, yet its reliance on pixel-perfect annotations presents a significant bottleneck due to the high cost of manual labeling. Weakly Supervised Semantic Segmentation (WSSS) offers a compelling alternative by training models using only image-level tags. The standard pipeline involves generating Class Activation Maps (CAMs) to identify object regions, which then serve as pseudo-labels for training a segmentation network.
However, CAMs frequently suffer from the "partial activation" problem, where the model focuses only on the most discriminative features (e.g., the head of a bird) rather than the entire object. While previous research attempted to solve this using consistency regularization—ensuring activation intensity remains stable across image augmentations—these methods often overlook the structural context and relationships between different image regions. This paper introduces All-pairs Consistency Learning (ACR), a framework designed to enforce consistency in both object localization and the internal relationships between image patches.
Methodology
All-pairs Consistency Regularization (ACR)
ACR utilizes a Siamese Vision Transformer (ViT) architecture to process two differently augmented views of the same image. The core innovation lies in regularizing the self-attention matrix, which inherently captures the relationships between all pairs of image patches.
The framework enforces two distinct types of consistency:
- Region Activation Consistency: Ensures that the intensity of object detection remains spatially consistent across different views.
- Region Affinity Consistency: Ensures that the pairwise relationships (affinities) between all regions remain invariant. For example, if a "wing" patch and a "tail" patch are strongly related in one view, that relationship should be preserved in a flipped or rotated view.
Transformation Inversion
Because augmentations like rotation or flipping change the spatial order of patches, the attention matrices of two views cannot be compared directly. The authors developed a mathematical inversion formula to re-align these matrices, allowing for a direct L1 loss calculation between the augmented views.
Gradient-based Localization
To refine the final localization "seeds," ACR moves beyond raw attention weights. Instead, it leverages the gradients of the class token. This provides a class-specific signal that, when combined with the learned all-pairs affinity, helps the activation map expand from discriminative parts to the entire object boundary.
Experimental Results
The ACR framework was evaluated on the PASCAL VOC 2012 and MS COCO 2014 datasets, demonstrating significant improvements over existing transformer-based and CNN-based WSSS methods.
- Localization Accuracy: On PASCAL VOC, ACR achieved an initial localization seed mIoU of 67.3%, outperforming the previous state-of-the-art transformer method, MCTformer, by over 5%.
- Segmentation Performance: On the challenging MS COCO dataset, ACR reached a segmentation mIoU of 45.0%.
- Efficiency and Simplicity: ACR achieves these results without requiring external saliency data or complex architectural modifications. By maintaining a simple single-class-token structure, the model remains efficient during inference.
Discussion and Limitations
A key insight of this work is that Vision Transformers are naturally suited for WSSS because their self-attention mechanism acts as a built-in affinity matrix. By enforcing consistency on this matrix, the model learns to "fill in" the gaps of traditional CAMs by understanding that related patches should share similar activation states.
Despite its success, the authors note certain limitations. ACR can occasionally lead to "over-activation," where the model struggles to distinguish between distinct but physically connected objects, such as a horse and its rider. Furthermore, because the current consistency regularization is class-indifferent, it may produce blurred boundaries in highly crowded scenes with multiple overlapping object classes.
Conclusion
All-pairs Consistency Learning (ACR) represents a significant step forward for WSSS. By regularizing the contextual relationships between image regions through the lens of Vision Transformers, ACR produces more complete and accurate object localizations. This approach proves that internal structural consistency is a powerful substitute for expensive manual annotations or external saliency priors.
Summary updated