Superpixel Tokenization for Vision Transformers: Preserving Semantic Integrity in Visual Tokens

Jaihyun Lew, Soohyuk Jang, Jaehoon Lee, Seungryong Yoo, Eunji Kim, Saehyung Lee, Jisoo Mok, Siwon Kim, Sungroh YoonarXiv 2024 · DOI

Introduction

The transition of the Transformer architecture from Natural Language Processing (NLP) to Computer Vision (CV) was marked by the introduction of the Vision Transformer (ViT). While NLP tokens typically represent semantically meaningful units like words or sub-words, standard ViTs adopt a rigid "grid-based" tokenization strategy, partitioning images into fixed $16 \times 16$ square patches.

This approach, though computationally convenient, introduces "semantic noise." A single square patch often straddles the boundaries of multiple objects or textures—for instance, containing a fragment of a bird's wing, a leaf, and background sky simultaneously. This "semantic mixing" forces the transformer backbone to disentangle unrelated concepts within a single token, potentially limiting the model's efficiency and representational power.

The SuiT Framework

To address these limitations, we introduce SuiT (Superpixel Tokenized ViT), a novel pipeline that replaces arbitrary grid patches with semantically cohesive superpixels. By ensuring that tokens respect the natural boundaries of visual objects, SuiT preserves semantic integrity from the very first stage of processing.

The SuiT-Tokenizer operates in a two-stage process:

  1. Pixel-level Embedding: Rather than projecting coarse patches, SuiT generates high-dimensional embeddings for every pixel. This is achieved through a convolutional block that captures local context, followed by the addition of sinusoidal positional encodings. Unlike the fixed learnable embeddings used in standard ViTs, sinusoidal encodings allow the model to generalize to the irregular and image-dependent spatial distributions of superpixels.
  2. Superpixel-aware Aggregation: The image is partitioned into superpixels using the Fast-SLIC algorithm. To aggregate the pixel-level embeddings within each superpixel into a single token, SuiT employs a dual-pooling strategy. It concatenates Average Pooling (capturing global semantic essence) and Max Pooling (preserving salient local features). The resulting vector is projected to the transformer's hidden dimension.
The SuiT-Tokenizer architecture, featuring pixel-level embedding and superpixel-aware aggregation stages.

This architecture is "plug-and-play," allowing the generated superpixel tokens to be processed by any standard ViT backbone without internal modifications.

Experimental Results

SuiT was evaluated across diverse benchmarks, including ImageNet-1K classification, transfer learning on specialized datasets (iNaturalist, Oxford Flowers), and zero-shot segmentation.

Performance and Efficiency

SuiT demonstrates superior performance and efficiency compared to both standard grid-based models (DeiT) and previous superpixel-based attempts (SPiT). On ImageNet-1K, SuiT-Tiny achieved 75.7% Top-1 accuracy, a +3.5% improvement over the DeiT-Tiny baseline.

A key advantage of SuiT is its adaptive inference capability. Because the number of superpixels is a controllable parameter, the model can dynamically adjust its token count at test time. As shown in the performance analysis, a SuiT-Tiny model utilizing only 100 tokens can match the accuracy of a standard DeiT-Tiny model using 196 tokens, representing nearly a 2x improvement in token efficiency.

Top-1 Accuracy vs. Number of Tokens on ImageNet-1K, comparing SuiT variants against DeiT and SPiT baselines.

Robustness and Generalization

Beyond raw accuracy, SuiT exhibits enhanced robustness. It outperformed baselines on ImageNet-A (natural adversarial examples) and ImageNet-O (out-of-distribution), suggesting that semantically pure tokens prevent the model from over-relying on brittle, coincidental textures found in arbitrary grid squares. Furthermore, in zero-shot salient object segmentation tasks, SuiT improved the Intersection over Union (IoU) by 9.4 points on the ECSSD dataset, highlighting its superior ability to capture object boundaries.

Conclusion

SuiT demonstrates that respecting the semantic structure of images during tokenization leads to more robust, accurate, and efficient vision models. By moving away from rigid grids toward object-aware superpixels, we align visual tokenization more closely with the semantic principles of NLP. Future work will explore the integration of superpixel tokenization into hierarchical architectures and its potential for improving visual-textual alignment in large multi-modal models.

Summary updated

BibTeX
@misc{lew2024superpixel,
  author = {Jaihyun Lew and Soohyuk Jang and Jaehoon Lee and Seungryong Yoo and Eunji Kim and Saehyung Lee and Jisoo Mok and Siwon Kim and Sungroh Yoon},
  title = {{Superpixel Tokenization for Vision Transformers: Preserving Semantic Integrity in Visual Tokens}},
  year = {2024},
  eprint = {2412.04680},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.04680},
}
Figure