Token Summarisation for Efficient Vision Transformers via Graph-based Token Propagation [WACV2024 Oral] [](https://arxiv.org/abs/2311.03035)

June 23, 2026 · View on GitHub

This is the official repository for GTP-ViT

GTP-ViT Architecture Overview

Architecture Overview

Environment Installation

Please install the following dependencies:

conda create -y -n gtp python=3.8.13
conda activate gtp
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
pip install timm==0.9.2 torchprofile==0.0.4

[Note] Newer versions of PyTorch and timm have not been tested with this repository, and might need adjustments.

Dataset Preparation

Please download and extract ImageNet train and val images from http://image-net.org/. The directory structure is the standard layout for the torchvision datasets.ImageFolder, and the training and validation data is expected to be in the train/ folder and val/ folder respectively:

/path/to/imagenet/
  train/
    class1/
      img1.jpeg
    class2/
      img2.jpeg
  val/
    class1/
      img3.jpeg
    class2/
      img4.jpeg

Model Weights Preparation

Please download ViT pre-trained models and place them in the weights/ folder. This repository currently supports .pth and .safetensors weight types. You can find the pre-trained model weights from their original repositories or Hugging Face. Below are some links to the pre-trained models used in our paper:

Base modelURL
DeiT-Ti-Patch16-224Model download
DeiT-S-Patch16-224Model download
DeiT-B-Patch16-224Model download
LVViT-S-Patch16-224Model download
LVViT-B-Patch16-224Model download
ViT-B-Patch8-224Check link availability
ViT-L-Patch16-224Check link availability
EVA-L-Patch14-196Model download

Other pre-trained models can be used as well, but please make sure to include model definition in models_v3.py and adjust evaluation command accordingly. You can also refer to the end of models_v3.py to find all the backbones we support at the moment and download their model weights by yourself. These weights are usually available on HuggingFace.

Optimal Hyperparameters

hyperparameter_search.py contains the code for searching optimal hyperparameters. You can adjust the hyperparameter ranges and run it with:

python hyperparameter_search.py

It will evaluate the model with different hyperparameter combinations and print the results. The results can be found under the outputs/ folder.

For example, taking DeiT-B as the backbone, the optimal hyperparameters with MixedAttnMax token selection strategy, Mixed graph type, GraphProp propagation method, and token scale are:

# Propagated tokens PPSparsity θ\thetaMagnitude α\alphaAccuracy
10.80.181.93
20.70.181.85
30.90.481.76
41.00.481.76
50.60.1581.70
60.60.1581.67
70.60.181.57
80.60.181.46
90.70.281.37
100.50.281.22
110.80.381.04
120.80.380.81
130.70.380.52
140.80.380.11

Reference

If our code or models help your work, please cite GTP-ViT:

@inproceedings{xu2024gtp,
  title={GTP-ViT: Efficient Vision Transformers via Graph-based Token Propagation},
  author={Xu, Xuwei and Wang, Sen and Chen, Yudong and Zheng, Yanping and Wei, Zhewei and Liu, Jiajun},
  booktitle={Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)},
  pages={86--95},
  year={2024}
}