SegViT v2: Exploring Efficient and Continual Semantic Segmentation with Plain Vision Transformers

Bowen Zhang, Liyang Liu, Minh Hieu Phan, Zhi Tian, Chunhua Shen, Yifan Liu

TL;DR

This paper introduces SegViTv2, a novel framework for semantic segmentation using plain Vision Transformers (ViTs). It achieves state-of-the-art performance with significantly reduced computational cost through an efficient Attention-to-Mask (ATM) decoder and a Shrunk++ encoder. Furthermore, SegViTv2 demonstrates remarkable robustness in continual learning scenarios, exhibiting nearly zero forgetting of previously learned knowledge.

What Problem Does This Paper Address?

Semantic segmentation, a crucial computer vision task, aims to assign a class label to every pixel in an image. While Convolutional Neural Networks (CNNs) have been dominant, Vision Transformers (ViTs) have emerged as powerful alternatives. However, adapting plain ViTs for semantic segmentation presents challenges:

  • Computational Cost: Plain ViTs, especially when used with existing hierarchical architectures or complex decoders, can be computationally expensive.
  • Decoder Design: Existing decoders often assume hierarchical feature maps, which plain ViTs don't inherently provide, leading to suboptimal performance or requiring modifications that break compatibility with pre-trained ViT checkpoints.
  • Continual Learning: Deep learning models, including those for segmentation, often suffer from "catastrophic forgetting" – losing performance on previously learned tasks when trained on new ones. This is a significant hurdle for real-world applications that require continuous adaptation.

The authors aim to develop an efficient and effective segmentation framework based on plain ViTs that addresses these issues, particularly by leveraging powerful pre-trained ViT models without the need for hierarchical adaptations.

Methods

SegViTv2 introduces several key innovations:

  • Attention-to-Mask (ATM) Decoder: This novel module takes class embeddings as queries and feature maps from the ViT backbone as keys and values. It leverages cross-attention to generate a similarity map, which is then converted into category-specific masks. This approach directly maps attention to semantic masks, offering a new paradigm for segmentation. The ATM module is designed to be lightweight and can be deployed at various layers of the backbone to extract masks at different scales.
  • Shrunk and Shrunk++ Encoder Structures: To tackle the high computational cost of plain ViT encoders, the authors propose:
  • Shrunk: This structure incorporates Query-based Downsampling (QD) and Query-based Upsampling (QU) modules. QD selectively prunes tokens to reduce computation, while QU recovers discarded information to maintain feature detail.
  • Shrunk++: This is an enhanced version that integrates an Edge-aware Query-based Downsampling (EQD) module. EQD not only downsamples tokens but also specifically preserves tokens located at object edges, which are crucial for detailed segmentation. This is achieved by adding a lightweight edge detection head trained alongside the main decoder.
  • Continual Semantic Segmentation (CSS) Adaptation: SegViT is adapted for CSS by decoupling class prediction from mask segmentation. When learning new tasks, only new class tokens and a corresponding fully-connected layer are trained, while all previous parameters (ViT encoder, ATM modules, and old FC layers) are frozen. This "forget-free" approach prevents interference with learned knowledge.

Datasets

The proposed SegViTv2 was evaluated on three standard semantic segmentation benchmarks:

  • ADE20K: A large-scale dataset for scene parsing with 150 semantic classes.
  • COCO-Stuff-10K: A scene parsing benchmark with 171 categories.
  • PASCAL-Context: A dataset with 60 semantic classes.

Key Insights and Ideas

  • Attention Maps as Semantic Masks: The core idea of the ATM module is that the attention maps, which inherently capture relationships between different parts of an image and class tokens, can be directly transformed into meaningful semantic masks. This is a departure from traditional per-pixel classification approaches.
  • Efficiency through Selective Downsampling: The Shrunk and Shrunk++ structures demonstrate that significant computational savings can be achieved in ViT encoders by intelligently pruning tokens, especially when combined with mechanisms to recover lost information (QU) or preserve critical details (EQD).
  • Edge Information for Robust Downsampling: The Shrunk++ encoder's EQD module highlights the importance of edge information for effective downsampling in segmentation. Preserving edge tokens helps maintain fine spatial details that are crucial for accurate segmentation, even when reducing computational load.
  • Decoupling for Forget-Free Continual Learning: The separation of mask prediction and class prediction in SegViT's architecture is key to its success in continual learning. By freezing old parameters and only training new class tokens, the model avoids the catastrophic forgetting typically seen in other methods.

Key Results

  • State-of-the-Art Performance: SegViTv2 achieves state-of-the-art mIoU scores on ADE20K (58.0% with BEiTv2-Large), COCO-Stuff-10K (53.46% with BEiTv2-Large), and PASCAL-Context (61.63% with ViT-Large).
  • Significant Computational Efficiency:
    • The ATM decoder is up to 5 times more computationally efficient than UPerNet.
  • The Shrunk++ encoder reduces computational cost by up to 50% compared to standard ViT encoders. For instance, SegViT-Shrunk-BEiT v2 Large achieves 55.7% mIoU with half the GFLOPs of UPerNet.
  • Continual Learning Robustness: SegViT-CL demonstrates nearly zero forgetting in continual learning settings, outperforming existing methods by a significant margin, especially in challenging long-term learning scenarios. For example, it shows a marginal mIoU reduction of only 0.3% in a 100-10 setting with 6 tasks.

Limitations and Future Work

  • Hierarchical vs. Plain ViT: While SegViT is designed for plain ViTs, the paper notes that hierarchical ViTs (like Swin Transformer) are also evaluated, showing SegViT's applicability across different ViT architectures. However, the primary focus and innovation lie in adapting plain ViTs.
  • Computational Cost of Plain ViT: Despite the efficiency gains, plain ViTs still have a higher computational overhead compared to some CNNs. The Shrunk++ structure significantly mitigates this, but further optimizations might be explored.
  • Future Work: The authors suggest that the ATM module's ability to generate masks directly from attention could be further explored for other dense prediction tasks. The forget-free continual learning approach also opens avenues for more robust and adaptable AI systems.

Summary updated

BibTeX
@article{zhang2024segvit,
  author = {Bowen Zhang and Liyang Liu and Minh Hieu Phan and Zhi Tian and Chunhua Shen and Yifan Liu},
  title = {{SegViT v2: Exploring Efficient and Continual Semantic Segmentation with Plain Vision Transformers}},
  journal = {Int. J. Comput. Vis.},
  year = {2024},
  doi = {10.1007/s11263-023-01894-8},
}
Figure