Memory Efficient Matting with Adaptive Token Routing

Yiheng Lin, Yihan Hu, Chenyi Zhang, Ting Liu, Xiaochao Qu, Luoqi Liu, Yao Zhao, Yunchao Wei

Abstract Vision Transformers (ViTs) have significantly advanced image matting but are limited by the quadratic complexity of global self-attention, which hinders processing of high-resolution images. We present MEMatte, a framework that replaces standard global attention with an Adaptive Token Routing (BATR) mechanism. MEMatte dynamically identifies informative tokens for global processing while routing others to a lightweight refinement module. This strategy reduces memory usage by up to 88% and latency by over 50%, enabling state-of-the-art 8K resolution matting on consumer-grade hardware.

Introduction: The High-Resolution Bottleneck

Image matting requires extreme precision to extract foreground objects with fine details like hair or translucent edges. While Vision Transformers (ViTs) provide the necessary long-range modeling, their computational cost scales quadratically with resolution. Standard workarounds, such as downsampling or crop-and-stitch methods, often result in loss of detail or visible artifacts. Existing token pruning methods are often too rigid, permanently discarding information that might be crucial for matting.

Methods: Adaptive Token Routing

MEMatte introduces a dynamic approach to token management through three primary components:

  • Adaptive Token Routing (BATR): Instead of pruning, a router evaluates tokens at each attention block. "Informative" tokens (e.g., those near complex boundaries) are sent to the Global Attention branch, while "uninformative" tokens (e.g., solid backgrounds) are handled by a cheaper branch. Tokens are re-evaluated at every layer, allowing the model to recover previously bypassed information.
  • Lightweight Token Refinement Module (LTRM): This efficient branch utilizes depth-wise convolutions and channel attention to approximate global context at a fraction of the cost.
  • Local-Global Routing Strategy: The router makes content-aware decisions by comparing local token features against a global average.
Overview of the MEMatte architecture featuring the Vision Transformer with the BATR and LTRM modules.

The UHR-395 Dataset

To address the lack of high-resolution benchmarks, the authors introduced UHR-395. This dataset contains 36,500 images with an average resolution of approximately 4872 × 6017 pixels. It covers 395 unique foreground objects across 11 diverse categories, providing a rigorous testbed for ultra-high-resolution matting.

Key Results and Performance

MEMatte demonstrates exceptional efficiency without sacrificing accuracy. On the Composition-1K benchmark, the MEMatte-S variant reduced memory consumption by 88.5% and latency by 54.3% compared to the ViTMatte baseline.

Comparison of memory usage across different resolutions. MEMatte (Ours) maintains a low memory footprint and avoids OOM errors at 4K and 8K resolutions.

Crucially, MEMatte is capable of processing 8K images on a single RTX 3090 GPU, a feat that causes "Out of Memory" (OOM) errors in standard ViT-based models. On the UHR-395 dataset, MEMatte outperformed existing methods like SparseMat and Matteformer across all key metrics, including SAD and MSE.

Conclusion

MEMatte successfully bridges the gap between the high-performance capabilities of Vision Transformers and the practical constraints of high-resolution image processing. By focusing computational power where it is most needed through adaptive routing, it sets a new standard for efficient, high-quality image matting. Future work will explore extending this routing mechanism to other dense prediction tasks such as semantic segmentation.

Summary updated

BibTeX
@inproceedings{lin2025memory,
  author = {Yiheng Lin and Yihan Hu and Chenyi Zhang and Ting Liu and Xiaochao Qu and Luoqi Liu and Yao Zhao and Yunchao Wei},
  title = {{Memory Efficient Matting with Adaptive Token Routing}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i5.32563},
}
Figure