Multi-class Token Transformer for Weakly Supervised Semantic Segmentation

Lian Xu, Wanli Ouyang, Mohammed Bennamoun, Farid Boussaïd, Dan Xu

Abstract

Weakly Supervised Semantic Segmentation (WSSS) aims to train segmentation models using only image-level labels, significantly reducing annotation costs. Traditional methods relying on Convolutional Neural Network (CNN) based Class Activation Mapping (CAM) often suffer from incomplete object localization. This paper presents MCTformer, a transformer-based framework that introduces multiple class-specific tokens to learn distinct object representations. By leveraging the transformer's inherent global receptive field and patch-level affinity, MCTformer produces high-quality localization maps that set new benchmarks on PASCAL VOC and MS COCO datasets.

Introduction

Semantic segmentation is a fundamental computer vision task requiring pixel-level labels, which are expensive to obtain. WSSS addresses this by utilizing "weak" supervision, such as image-level tags. While CNN-based CAMs have been the standard, they typically highlight only the most discriminative object parts and produce noisy boundaries. Vision Transformers (ViTs) offer a promising alternative due to their global attention mechanisms. However, standard ViTs utilize a single class token, resulting in class-agnostic attention maps that fail to differentiate between multiple categories in a single image.

The MCTformer Framework

The Multi-class Token Transformer (MCTformer) addresses the limitations of standard ViTs by fundamentally changing how tokens are utilized. Instead of a single global class token, MCTformer employs $C$ learnable class tokens, where $C$ corresponds to the number of object categories in the dataset. Each token is trained to specialize in a specific class.

Comparison between standard ViT and the proposed MCTformer.

By calculating the attention scores between these class tokens and the image patch tokens, the model generates class-specific localization maps. This allows for precise identification of multiple distinct objects within the same scene, overcoming the class-agnostic nature of traditional transformer attention.

Architecture and Refinement

The MCTformer architecture consists of a transformer encoder that processes both the multi-class tokens and image patch tokens. A key innovation is the use of "free" internal information for map refinement.

Detailed architecture of the MCTformer-V1 framework.

The model utilizes the patch-to-patch attention matrix as a pairwise affinity map. This internal affinity helps refine the initial class-to-patch attention maps, ensuring smoother object contours and better completeness without the need for additional sub-networks. An enhanced version, MCTformer-V2, further integrates a "PatchCAM" module, fusing global transformer attention with local feature activations for superior performance.

Experimental Results

MCTformer was evaluated on the PASCAL VOC 2012 and MS COCO 2014 benchmarks, achieving state-of-the-art results:

  • PASCAL VOC 2012: The model reached a mean Intersection-over-Union (mIoU) of 71.6% on the test set, significantly outperforming previous transformer-based approaches.
  • MS COCO 2014: On this more complex dataset, MCTformer achieved 42.0% mIoU, a substantial improvement over existing methods that often struggle with its 80 object classes and intricate scenes.
  • Efficiency: MCTformer-V1 is notably efficient, utilizing approximately 21.7M parameters, which is considerably less than the 100M+ parameters often required by ResNet38-based CNN pipelines.

Discussion and Limitations

Analysis revealed that the transformer's early layers produce generic, low-level attention maps. Optimal localization is achieved by fusing attention from only the final few layers (specifically the last three). While highly effective for large objects, the model can occasionally over-activate localization maps for very small or irregularly shaped objects. Future work may explore multi-scale fusion techniques to improve precision for these challenging cases.

Conclusion

MCTformer demonstrates that class tokens are a powerful tool for WSSS when adapted for multi-class representation. By combining class-specific attention with internal patch affinity, the framework provides a robust and efficient solution for generating high-quality semantic segmentation masks from image-level labels.

Summary updated

BibTeX
@inproceedings{xu2022multi,
  author = {Lian Xu and Wanli Ouyang and Mohammed Bennamoun and Farid Boussaïd and Dan Xu},
  title = {{Multi-class Token Transformer for Weakly Supervised Semantic Segmentation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  doi = {10.1109/cvpr52688.2022.00427},
}
Figure