Exploring Token-Level Augmentation in Vision Transformer for Semi-Supervised Semantic Segmentation

Dengke Zhang, Quan Tang, Fagui Liu, Haiqing Mei, C. L. Philip ChenIEEE Signal Processing Letters 2025 · DOI

Abstract

Semi-supervised semantic segmentation has witnessed remarkable advancements in recent years. However, existing algorithms are based on convolutional neural networks and directly applying them to Vision Transformers poses certain limitations due to conceptual disparities. To this end, we propose TokenMix, a data augmentation technique specifically designed for semi-supervised semantic segmentation with Vision Transformers. TokenMix aligns well with the global attention mechanism by mixing images at the token level, enhancing learning capability for contextual information among image patches. We further incorporate image augmentation and feature augmentation to promote the diversity of augmentation. Moreover, to enhance consistency regularization, we propose a dual-branch framework where each branch applies image and feature augmentation to the input image. We conduct extensive experiments across multiple benchmark datasets, including Pascal VOC 2012, Cityscapes, and COCO. Results suggest that the proposed method outperforms state-of-the-art algorithms with notably observed accuracy improvement, especially under limited fine annotations.

Introduction

Semantic segmentation is a fundamental task in computer vision, requiring the assignment of categorical labels to every pixel in an image. While deep learning has achieved remarkable success in this domain, the performance of these models typically hinges on the availability of large-scale, finely annotated datasets. Semi-supervised semantic segmentation (S4) addresses this bottleneck by leveraging a small amount of labeled data alongside a much larger pool of unlabeled images.

Historically, S4 research has been dominated by Convolutional Neural Networks (CNNs). However, the recent shift toward Vision Transformers (ViTs) has introduced new challenges. Standard data augmentation techniques, such as CutMix—which involves swapping rectangular pixel regions between images—often result in "boundary discontinuities." While CNNs can tolerate these artifacts, ViTs process images as sequences of patches (tokens) and are highly sensitive to such distortions. This "conceptual disparity" limits the effectiveness of traditional S4 strategies when applied to transformer-based architectures.

TokenMix: Token-Level Data Augmentation

To address these limitations, we propose TokenMix, a data augmentation strategy specifically tailored for the patch-based nature of Vision Transformers. Unlike CutMix, which operates in the pixel space, TokenMix operates directly on the tokens generated after the initial patch embedding layer.

By swapping tokens between labeled and unlabeled images, TokenMix ensures that the internal structure of each patch remains natural and coherent. This approach aligns with the global self-attention mechanism of ViTs, allowing the model to learn contextual relationships between patches without being distracted by artificial pixel-level edges. This method encourages the model to recognize objects in diverse, synthetic contexts, which significantly improves generalization when labeled data is extremely scarce.

Dual-Branch Consistency Framework

Vision Transformers are often more difficult to optimize than their convolutional counterparts, particularly in semi-supervised settings where the training signal is weaker. To stabilize the learning process, we introduce a dual-branch consistency framework based on the Teacher-Student paradigm.

In this framework, the Student model consists of two parallel branches. Both branches receive the same input image but are subjected to different strong augmentations, including TokenMix and feature-level Dropout. The Teacher model, which is an exponential moving average (EMA) of the Student's weights, generates pseudo-labels for the unlabeled data. The Student is then trained to produce consistent predictions across both of its branches, effectively regularizing the model and preventing it from overfitting to the limited labeled set.

Experimental Evaluation

We evaluated the proposed method on three benchmark datasets: Pascal VOC 2012, Cityscapes, and COCO. Our experiments utilized various partition protocols to simulate different levels of data scarcity, ranging from 1/4 to 1/512 of the total labeled set.

Results on Pascal VOC and COCO

The proposed method consistently outperformed state-of-the-art (SOTA) algorithms like UniMatch and AugSeg. On the Pascal VOC 2012 dataset, using only 92 labeled images (1/16 partition), our method achieved a mean Intersection over Union (mIoU) of 72.90%. This represents a significant improvement over the supervised-only baseline (60.12%) and surpasses previous SOTA methods (68.84%).

On the more challenging COCO dataset, the advantages of TokenMix were even more pronounced. With only 232 labeled images (1/512 partition), the method reached 29.84% mIoU, outperforming the next best method by more than 2%.

Scalability and Robustness

Ablation studies confirmed that the "Respect the Architecture" philosophy is key to these gains. Furthermore, the method demonstrated excellent scalability. It proved effective not only for standard ViTs but also for hierarchical architectures like the Swin Transformer and larger-scale models such as SegFormer-B5.

Discussion and Conclusion

The success of TokenMix highlights the importance of aligning data augmentation strategies with the underlying architecture of the model. By operating in the token space, we mitigate the issues caused by pixel-level discontinuities in ViTs and leverage the strengths of the global attention mechanism.

However, the dual-branch framework does come with a trade-off: it approximately doubles the computational footprint of the student model during training. Additionally, the model's performance is sensitive to the confidence threshold (ρ) used for pseudo-label filtering. If the threshold is set too low, the model may incorporate noisy labels; if set too high, it may discard useful information from the unlabeled pool.

In conclusion, TokenMix provides a robust and effective solution for semi-supervised semantic segmentation with Vision Transformers. Future work will focus on optimizing the computational efficiency of the dual-branch framework and exploring adaptive thresholding techniques to further enhance performance.

Summary updated

BibTeX
@article{zhang2025exploring,
  author = {Dengke Zhang and Quan Tang and Fagui Liu and Haiqing Mei and C. L. Philip Chen},
  title = {{Exploring Token-Level Augmentation in Vision Transformer for Semi-Supervised Semantic Segmentation}},
  journal = {IEEE Signal Processing Letters},
  year = {2025},
  doi = {10.1109/lsp.2025.3562821},
}
Figure