TransCAM: Transformer attention-based CAM refinement for Weakly supervised semantic segmentation

Ruiwen Li, Zheda Mai, Zhibo Zhang, Jongseong Jang, Scott Sanner · DOI

TL;DR

TransCAM is a novel approach to weakly supervised semantic segmentation (WSSS) that solves the "partial activation" problem—where models only identify the most distinct parts of an object—by leveraging the dual-branch Conformer architecture. By using transformer attention weights to refine CNN-generated Class Activation Maps (CAMs), it achieves state-of-the-art performance on the PASCAL VOC 2012 benchmark.

What Problem Does This Paper Address?

Semantic segmentation is the task of assigning a category label to every single pixel in an image. While powerful, standard deep learning models require massive amounts of pixel-level "ground truth" labels, which are incredibly expensive and time-consuming to produce.

Weakly Supervised Semantic Segmentation (WSSS) attempts to train these models using only image-level labels (e.g., "this image contains a bus"). The standard approach uses Class Activation Maps (CAMs) to identify which pixels contributed most to a classification decision, turning these maps into "pseudo-labels" for training.

However, CNN-based CAMs have a major flaw: partial activation. Because CNNs have a local receptive field, they tend to focus only on the most discriminative parts of an object (like the head of a bird or the wheels of a bus) rather than the entire object body. This leads to poor-quality pseudo-labels and, ultimately, inaccurate segmentation.

Methods

The authors introduce TransCAM, which utilizes a Conformer backbone—a hybrid architecture that runs a CNN branch and a Transformer branch in parallel, fusing their features at multiple scales.

The core innovation lies in how TransCAM generates pseudo-labels:

  1. Dual-Branch Synergy: It generates a standard CAM from the CNN branch.
  2. Attention-Based Refinement: Instead of relying solely on the CNN, TransCAM explicitly extracts the multi-head self-attention weights from the Transformer branch.
  3. The "All-Blocks" Strategy: The authors found that shallow transformer blocks capture low-level spatial similarities (textures), while deep blocks capture high-level semantic context. TransCAM averages these weights across all blocks to create a comprehensive "Attention Map."
  4. Refinement via Dot Product: The CNN-based CAM is refined by this Attention Map using a simple, efficient dot product. This "spreads" the activation from the discriminative parts to the rest of the object based on the global context captured by the transformer.

Datasets

The model was evaluated on the PASCAL VOC 2012 segmentation benchmark, a gold standard in the field containing 21 object categories.

  • Training: An augmented set of 10,582 images (using labels from the Semantic Boundary Dataset).
  • Validation/Testing: The standard PASCAL VOC 2012 val (1,449 images) and test (1,456 images) sets.
  • Pre-training: The backbone was pre-trained on ImageNet.

Key Insights and Ideas

  • The Conformer is a Natural Fit: While Vision Transformers (ViTs) are great at global context, they often lose local details. The Conformer’s dual-branch structure allows TransCAM to maintain sharp object boundaries (CNN) while ensuring full object coverage (Transformer).
  • Attention Hierarchy: One of the most interesting findings is the functional difference between layers. Shallow layers act almost like a sophisticated version of "color/texture similarity" filters, while deep layers understand "objectness." Combining them is essential for high-quality refinement.
  • Simplicity Wins: Unlike previous SOTA methods that required complex auxiliary modules (like AffinityNet) or multi-stage erasing techniques, TransCAM achieves better results by simply looking at the weights already inherent in the backbone.

Key Results

TransCAM set a new state-of-the-art for WSSS using only image-level labels:

  • Pseudo-label Quality: TransCAM improved the initial seed mIoU (mean Intersection-over-Union) from a baseline of 51.7% to 64.85% before any post-processing.
  • Final Segmentation: After full training, it achieved 69.3% mIoU on the PASCAL VOC 2012 validation set and 69.6% on the test set.
  • Efficiency: It outperforms models like ResNet-101 while using fewer parameters (37.7M for Conformer-S vs 44.5M for ResNet-101).

Limitations and Future Work

While TransCAM significantly reduces the need for complex post-processing, the authors still utilize PSA (Pixel-level Semantic Affinity) and CRF (Conditional Random Fields) to reach their peak scores. These steps are computationally intensive.

Future work could explore:

  • Integrating the refinement process directly into the end-to-end training loss to eliminate the need for offline pseudo-label generation.
  • Testing the TransCAM principle on even larger, more diverse datasets like MS COCO to see if the attention-based refinement scales to hundreds of categories.

Summary updated

BibTeX
@article{li2023transcam,
  author = {Ruiwen Li and Zheda Mai and Zhibo Zhang and Jongseong Jang and Scott Sanner},
  title = {{TransCAM: Transformer attention-based CAM refinement for Weakly supervised semantic segmentation}},
  journal = {J. Vis. Commun. Image Represent.},
  year = {2023},
  doi = {10.1016/j.jvcir.2023.103800},
}
Figure