[Paper Review] SPFormer: Enhancing Vision Transformer with Superpixel Representation
SPFormer integrates a learnable superpixel representation with a Vision Transformer via Superpixel Cross Attention, improving accuracy, efficiency, and explainability, including strong ImageNet gains and better segmentation robustness.
In this work, we introduce SPFormer, a novel Vision Transformer enhanced by superpixel representation. Addressing the limitations of traditional Vision Transformers' fixed-size, non-adaptive patch partitioning, SPFormer employs superpixels that adapt to the image's content. This approach divides the image into irregular, semantically coherent regions, effectively capturing intricate details and applicable at both initial and intermediate feature levels. SPFormer, trainable end-to-end, exhibits superior performance across various benchmarks. Notably, it exhibits significant improvements on the challenging ImageNet benchmark, achieving a 1.4% increase over DeiT-T and 1.1% over DeiT-S respectively. A standout feature of SPFormer is its inherent explainability. The superpixel structure offers a window into the model's internal processes, providing valuable insights that enhance the model's interpretability. This level of clarity significantly improves SPFormer's robustness, particularly in challenging scenarios such as image rotations and occlusions, demonstrating its adaptability and resilience.
Motivation & Objective
- Motivate bridging pixel/patch representations by leveraging adaptive superpixels to preserve local details and enable efficient global modeling.
- Develop a trainable, end-to-end SPFormer architecture that integrates superpixel representations with ViT via cross-attention.
- Show that superpixel-based representation improves accuracy on ImageNet and enhances interpretability and robustness to rotations and occlusions.
- Evaluate SPFormer on image classification and semantic segmentation tasks to demonstrate versatility and efficiency.
Proposed method
- Introduce superpixel representation that aggregates pixels into semantically coherent regions with an association matrix A between pixels and neighboring superpixels.
- Propose Superpixel Cross Attention (SCA) with two cross-attention directions: Pixel-to-Superpixel (P2S) and Superpixel-to-Pixel (S2P), iteratively refining S and A across t iterations.
- Incorporate Convolution Position Embedding (CPE) to inject spatial information into pixel and superpixel features.
- Adopt a dual-branch SPFormer architecture where a high-resolution dense pixel branch is complemented by a low-resolution superpixel branch for efficiency.
- Use a multi-head SCA to generate multiple semantically rich superpixel representations, followed by MHSA for global context, and a gradual refinement across stages with 1x1 convolutions to propagate context.
Experimental results
Research questions
- RQ1Can adaptive, learnable superpixel representations coupled with cross-attention outperform fixed patch-based ViTs on ImageNet and segmentation tasks?
- RQ2Does the SCA module improve alignment between superpixels and semantic boundaries, leading to better generalization on unseen data?
- RQ3How does SPFormer fare in terms of efficiency and robustness to rotations and occlusions compared to traditional ViTs?
- RQ4To what extent does the high-resolution pixel branch preserve details while the superpixel branch enables global context?
Key findings
- SPFormer yields ImageNet gains over DeiT baselines, e.g., SPFormer-S/32 † achieves 77.9% Top-1 with 22M params and 1.3G FLOPs, surpassing DeiT-S/32 and DeiT-T.
- On ImageNet, SPFormer-S/56 reaches 72.3% Top-1 with 22M params and 0.5G FLOPs, while SPFormer-S/32 and SPFormer-S/32 † achieve 76.4% and 77.9% Top-1 respectively.
- SPFormer-B and SPFormer-S variants achieve Top-1 scores up to 82.7% with 87M params and 19.2G FLOPs, outperforming DeiT-B (81.8%) and DeiT-S (79.9%).
- The learned superpixel associations align with image boundaries even without training on segmentation datasets, enabling zero-shot transfer to COCO and part/object segmentation tasks.
- Ablation studies show multiple SCA iterations, multi-head attention, and strategic placement of SCA layers are crucial for performance gains.
- SPFormer improves segmentation mIoU on ADE20K and Pascal Context, especially with ImageNet-pretrained models (up to +4.2% and +2.8% respectively) and also benefits from scratch training (+3.0% and +3.1%).
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.