Content-aware Token Sharing for Efficient Semantic Segmentation with Vision Transformers

Chenyang Lu, Daan de Geus, Gijs Dubbelman

Abstract

Vision Transformers (ViTs) achieve state-of-the-art performance in semantic segmentation but suffer from high computational costs due to the quadratic complexity of self-attention. This paper introduces Content-aware Token Sharing (CTS), a framework that identifies and merges redundant, semantically uniform image regions into single tokens. By reducing the token count before processing with a ViT backbone and subsequently "unsharing" them for dense prediction, CTS achieves up to a 64% increase in throughput with minimal impact on accuracy across standard benchmarks like ADE20K and Cityscapes.

Introduction

While Vision Transformers have set new records in computer vision, their self-attention mechanism remains a significant bottleneck. Computational cost grows quadratically with the number of input tokens, making high-resolution tasks like semantic segmentation particularly demanding. Unlike image classification, where "unimportant" tokens can be discarded, segmentation requires a prediction for every pixel. Previous attempts at token merging often struggled with spatial reversibility or introduced complex multi-stage overhead. The challenge lies in reducing token density in a way that is both computationally cheap and spatially reversible.

Content-aware Token Sharing (CTS)

The CTS framework addresses these challenges by identifying neighboring patches that belong to the same semantic class (e.g., a patch of blue sky or a stretch of gray road) and merging them into a single token.

Conceptual comparison between a standard Vision Transformer and the proposed CTS framework.

The system operates in three primary stages:

  1. Policy Network: A lightweight, class-agnostic CNN (EfficientNet-Lite0) predicts which 2x2 "superpatches" are semantically uniform. Because it only detects "sameness" rather than specific object classes, its overhead is negligible.
  2. Token Sharing ($t_s$): Based on the policy, uniform superpatches are downsampled into a single token, significantly reducing the total number of tokens fed into the heavy ViT backbone.
  3. Token Unsharing ($t_u$): After the ViT processes the reduced set of tokens, the shared tokens are upsampled back to their original 2x2 configuration so the segmentation decoder can produce a full-resolution map.

The policy network is trained using existing segmentation labels. If a 2x2 block in the ground truth has only one label, the network is taught to mark it as "sharable."

Key Insights and Results

The core motivation for CTS is the inherent redundancy in segmentation datasets. Analysis of benchmarks reveals that in many cases, over 25% of all 2x2 superpatches contain only a single semantic class. CTS turns this redundancy into a computational shortcut while preserving the spatial integrity required for dense prediction.

Visualization of the CTS policy. From left to right: input image with grid, ground truth labels, superpatch labels, and the resulting sharing mask (black indicates shared tokens).

Performance Benchmarks

CTS was evaluated across three standard datasets: ADE20K, Pascal Context, and Cityscapes. Key results include:

  • Efficiency Gains: On the Cityscapes dataset, CTS reduced the number of processed tokens by 44%, resulting in a 110% increase in throughput (images per second).
  • Accuracy Preservation: On ADE20K, reducing tokens by 30% actually resulted in a slight increase in mIoU (45.1 vs. 45.0), suggesting that the reduction might act as a form of regularization.
  • State-of-the-Art Boost: When applied to a massive BEiT-L backbone with a UPerNet decoder, CTS increased throughput by 64% while maintaining a nearly identical mIoU (56.6 vs. 56.8).

Conclusion and Future Work

Content-aware Token Sharing demonstrates that spatial redundancy can be effectively leveraged to accelerate Vision Transformers without sacrificing accuracy. While the current implementation uses a fixed reduction rate per dataset, future work could involve dynamic, per-image token sharing to further optimize efficiency based on image complexity. Additionally, the principles of CTS could be extended to other dense tasks such as depth estimation, optical flow, or video-based segmentation where temporal redundancy offers further opportunities for token sharing.

Summary updated

BibTeX
@inproceedings{lu2023content,
  author = {Chenyang Lu and Daan de Geus and Gijs Dubbelman},
  title = {{Content-aware Token Sharing for Efficient Semantic Segmentation with Vision Transformers}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
  doi = {10.1109/cvpr52729.2023.02263},
}
Figure