MSViT: Dynamic Mixed-Scale Tokenization for Vision Transformers

Jakob Drachmann Havtorn, Amelie Royer, Tijmen Blankevoort, Babak Ehteshami Bejnordi
7/5/2023
cs.CV

No official code found. Best implementation: Qualcomm-AI-research/batchshaping (8 stars, last commit 2023-09-05).

Abstract

The input tokens to Vision Transformers carry little semantic meaning as they are defined as regular equal-sized patches of the input image, regardless of its content. However, processing uniform background areas of an image should not necessitate as much compute as dense, cluttered areas. To address this issue, we propose a dynamic mixed-scale tokenization scheme for ViT, MSViT. Our method introduces a conditional gating mechanism that selects the optimal token scale for every image region, such that the number of tokens is dynamically determined per input. In addition, to enhance the conditional behavior of the gate during training, we introduce a novel generalization of the batch-shaping loss. We show that our gating module is able to learn meaningful semantics despite operating locally at the coarse patch-level. The proposed gating module is lightweight, agnostic to the choice of transformer backbone, and trained within a few epochs with little training overhead. Furthermore, in contrast to token pruning, MSViT does not lose information about the input, thus can be readily applied for dense tasks. We validate MSViT on the tasks of classification and segmentation where it leads to improved accuracy-complexity trade-off.

View on arXivView PDF

Code Implementations(1)

81Python, Jupyter NotebookAug 7, 20233 years agoNOASSERTION

Similar Papers

Cite this paper

@article{havtorn2023msvit,
  title  = {MSViT: Dynamic Mixed-Scale Tokenization for Vision Transformers},
  author = {Jakob Drachmann Havtorn and Amelie Royer and Tijmen Blankevoort and Babak Ehteshami Bejnordi},
  year   = {2023},
  eprint = {2307.02321},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2307.02321v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2307.02321.svg)](https://codeofpaper.com/paper/2307.02321)

Discussion