← Back to Research

SCMerge: Spatial-Consistency-Aware Token Pair Merging for Efficient Semantic Segmentation

Junfeng Ren1, Yi Gong1, Yuan Zeng2

  • 1 Southern University of Science and Technology
  • 2 Shenzhen Technology University

arXiv preprint, arXiv:2610.21642

Overview

Vision Transformers are effective for semantic segmentation, but self-attention scales quadratically with the number of tokens. Most training-free token merging methods pair tokens by feature similarity alone, which can merge tokens that look alike but are spatially inconsistent—for example, mixing boundary tokens with neighboring interiors, or merging interiors of different objects.

We propose SCMerge, a training-free, plug-and-play token merging method for ViT-based segmentation. It jointly considers feature similarity and spatial consistency when pairing tokens, merges the selected pairs inside the encoder, and reconstructs the decoded tokens back onto the original patch grid. The module can be inserted into existing pipelines without retraining.

On ADE20K, Pascal Context, and Cityscapes with Segmenter backbones, SCMerge consistently improves the accuracy–efficiency trade-off over feature-similarity-only baselines. On ADE20K with Segmenter-B/16, SCMerge reaches 48.42 mIoU—within 0.06 of the unmerged baseline (48.48)—while reducing computation from 258.80 to 181.21 GFLOPs and latency from 29.77 ms to 20.82 ms.

Framework

Overview of SCMerge. The module is inserted into ViT encoder blocks, merges token pairs, and reconstructs the result onto the original prediction grid after the decoder.
Overview of SCMerge. SCMerge is a plug-and-play module that can be inserted into multiple ViT encoder blocks to reduce the token sequence length while maintaining a merge map. It combines feature similarity with a spatial-consistency penalty to guide similar token pairing and merging. The reduced token sequence remains compact throughout decoding and is reconstructed onto the original dense prediction grid only after the decoder.

The pairing score combines feature similarity with a spatial-consistency penalty. The penalty has a boundary-sensitive term \(B_{ij}\) and a neighborhood consistency term \(D_{ij}\). Mutual nearest-neighbor pairs are merged inside the encoder. A merge map records which token represents each original patch so that decoder outputs can be reconstructed onto the original grid. The method adds no learnable parameters and leaves the segmentation decoder unchanged.

Key Contributions

  • We propose a training-free token-pair merging method that adds a spatial-consistency penalty to feature-similarity matching, avoiding merges of locally similar but spatially incompatible tokens and improving the accuracy–efficiency trade-off.
  • We design a local feature variation metric to identify boundary-sensitive tokens, and a spatial-consistency penalty with a boundary-sensitive term and a neighborhood consistency term, to reduce incorrect merges near semantic boundaries and preserve fine spatial detail.
  • Extensive experiments show that the method can be integrated into ViT-based semantic segmentation models and achieves a better accuracy–efficiency trade-off than baselines that rely only on feature similarity.

Experimental Results

Latency is measured on an NVIDIA RTX 3090 with batch size 1 in FP32. The paper’s accuracy–latency trade-off ratio is

\[ R = \frac{\mathrm{Latency}_{\mathrm{full}} - \mathrm{Latency}_{\mathrm{method}}}{\mathrm{mIoU}_{\mathrm{full}} - \mathrm{mIoU}_{\mathrm{method}}}. \]

A larger \(R\) means more latency reduction per unit of accuracy drop.

Quantitative comparison

On ADE20K with Segmenter-B/16, SCMerge reaches 48.42 mIoU, within 0.06 of the unmerged baseline (48.48), while reducing computation from 258.80 to 181.21 GFLOPs and latency from 29.77 ms to 20.82 ms.

Quantitative comparison results on ADE20K, Pascal Context, and Cityscapes with Segmenter backbones. \(N_{\mathrm{final}}\) and GFLOPs are averaged over the validation set when token reduction is input-dependent.
Method mIoU Nfinal GFLOPs Latency (ms) R ↑
ADE20K, Segmenter-B/16
Segmenter 48.48 1024.00 258.80 29.77 –
ToMe (r=200) 48.01 624.00 193.65 20.13 20.51
MPM 47.81 563.29 182.75 19.58 15.21
MPM-top (76%) 48.22 655.46 198.36 22.90 26.42
SCMerge 48.42 653.98 181.21 20.82 149.17
ADE20K, Segmenter-B/8
Segmenter 49.57 4096.00 1319.38 158.80 –
ToMe 49.15 2496.00 854.96 100.33 139.21
MPM 49.20 2247.40 802.61 91.81 181.05
MPM-top 49.26 2621.96 911.04 110.23 156.68
SCMerge 49.38 2639.09 908.26 107.86 268.11
ADE20K, Segmenter-L/16
Segmenter 51.81 1600.00 1343.32 134.13 –
ToMe 51.48 976.00 886.72 80.58 162.27
MPM 51.02 876.40 818.72 73.89 76.25
MPM-top 51.45 1020.21 919.94 89.29 124.56
SCMerge 51.64 1040.61 892.82 87.43 274.71
Pascal Context, Segmenter-L/16
Segmenter 58.08 900.00 685.67 56.89 –
ToMe 57.74 548.00 461.34 38.69 53.53
MPM 57.46 486.28 418.49 34.87 35.52
MPM-top 57.78 567.75 470.45 41.00 52.97
SCMerge 57.94 581.48 456.49 39.51 124.14
Cityscapes, Segmenter-S/16
Segmenter 76.35 2304.00 232.07 35.98 –
ToMe 75.43 1404.00 161.97 24.90 12.04
MPM 75.30 1334.67 159.70 24.42 11.01
MPM-top 75.52 1530.32 174.66 28.72 8.75
SCMerge 75.68 1565.60 162.22 26.52 14.12
Cityscapes, Segmenter-L/16
Segmenter 79.01 2304.00 2010.69 208.92 –
ToMe 78.03 1404.00 1266.86 125.36 85.27
MPM 77.72 1299.06 1190.04 118.68 69.95
MPM-top 78.23 1498.76 1346.05 133.54 96.64
SCMerge 78.48 1535.59 1337.82 132.80 143.62
Token-reduction and spatial-consistency visualization comparing SCMerge with other token-merging methods.
Token-reduction and spatial-consistency visualization. SCMerge selects spatial-consistency token pairs with lower boundary sensitivity \(B_{ij}\) and neighborhood consistency \(D_{ij}\) than competing methods.
Qualitative segmentation comparison on ADE20K, with prediction and error maps.
Qualitative segmentation comparison on ADE20K. Prediction and error maps show that SCMerge produces fewer segmentation errors than the baseline token-merging methods, achieving the lowest pixel error rate.
Accuracy versus latency trade-off of MPM and SCMerge on ADE20K.
Accuracy–latency trade-off of MPM and SCMerge on ADE20K. Labels denote zero-based encoder-block indices. SCMerge consistently achieves a higher mIoU and a better accuracy–latency trade-off than MPM.

My Contributions

First author.

← Back to Research