TokenPose: Learning Keypoint Tokens for Human Pose Estimation

Yanjie Li, Shoukui Zhang, Zhicheng Wang, Sen Yang, Wankou Yang, Shu-Tao Xia, Erjin Zhou

TL;DR

TokenPose introduces a novel Transformer-based framework for 2D human pose estimation that treats each anatomical keypoint as an explicit, learnable token. By simultaneously capturing visual appearance cues and anatomical constraints through self-attention, it achieves state-of-the-art accuracy while reducing parameters by up to 80% compared to traditional CNN counterparts.

What Problem Does This Paper Address?

Accurate 2D human pose estimation relies on two pillars: visual cues (what a joint looks like) and anatomical constraints (how joints relate structurally, such as the left ankle connecting to the left knee).

While Convolutional Neural Networks (CNNs) excel at visual representation, they struggle to explicitly model the structural relationships between keypoints. Standard CNN architectures maintain 2D feature maps right up to the output heatmaps, meaning they lack concrete variables to represent individual keypoint entities. Consequently, any constraint modeling remains implicit and sub-optimal. TokenPose addresses this gap by bringing the explicit entity-relation modeling of Transformers to computer vision.

Methods

The authors propose TokenPose, an architecture that leverages the Transformer encoder to explicitly represent keypoints as tokens. The framework operates on two distinct types of tokenizations:

  1. Visual Tokens: Following the Vision Transformer (ViT) paradigm, an image (or a CNN feature map) is split into a grid of patches. Each patch is flattened and linearly projected into a $d$-dimensional embedding, with 2D positional embeddings added to retain spatial awareness.
  2. Keypoint Tokens: The core innovation. These are randomly initialized, learnable embeddings where each token explicitly represents a specific keypoint type (e.g., left ankle, nose, right shoulder).
Figure 2. Schematic illustration of the proposed TokenPose. The feature maps extracted by CNN backbone are uniformly split into patches and flattened to 1D vectors. Visual tokens are yielded by adopting a linear projection to embed the flattened vectors. In addition, keypoint tokens are initialized randomly to represent each specific type of keypoint. Then, the 1D sequence of visual tokens and keypoint tokens are taken as input to Transformer encoder. Both appearance cues and anatomical constraint cues are captured through self-attention interactions in each Transformer layer. Finally, the keypoint tokens outputted by the last Transformer layer are used to predict the keypoints heatmaps via an MLP head.

The combined sequence of visual and keypoint tokens is fed into a Transformer encoder. Through successive self-attention layers, the keypoint tokens interact with visual tokens to learn appearance context, and with other keypoint tokens to learn structural constraints. Finally, a Multilayer Perceptron (MLP) head projects the output keypoint tokens into the final 2D heatmaps.

The paper explores both a Pure Transformer variant (TokenPose-T), which processes raw image patches from scratch, and Hybrid variants (TokenPose-S and TokenPose-L), which use a lightweight CNN backbone (like a shallow stem-net or HRNet) to extract low-level features more efficiently before tokenization.

Datasets

The authors evaluated TokenPose on two widely recognized benchmarks:

  • COCO Keypoint Detection Dataset: Contains over 200,000 images and 250,000 person instances labeled with 17 keypoints.
  • MPII Human Pose Dataset: Contains roughly 40,000 person samples with 16 joint labels reflecting real-world activities.

Key Insights and Ideas

  • Anatomical Priors from Scratch: By calculating the inner product matrix of the input keypoint tokens, the authors found that the model automatically learns human anatomy relationships (e.g., the left hip token naturally shows high similarity to the right hip and left shoulder tokens) purely from data, without any manual rule engineering.
  • Global-to-Local Evolution: Visualizing the attention maps reveals that in early Transformer layers, keypoint tokens focus broadly on global context (the whole body). As the network goes deeper, the attention progressively converges onto precise local regions around the target joint.
  • Smart Occlusion Handling: When a joint is hidden or occluded, the model dynamically shifts its attention. For instance, an occluded left ankle token will pay significantly higher attention to its symmetric counterpart (the right ankle) to infer its position.
Figure 1. The process of predicting the location of the left ankle. For visual cue learning, the proposed TokenPose focuses on the global context in the first few layers, and then gradually converges to some local regions as the network goes deeper. In the last few layers, TokenPose has considered hip and knee in turn which are close to the target keypoint, and finally localizes the position of the left ankle. For constraint cue learning, TokenPose shows that localizing the left ankle mostly relies on the left knee and right ankle, corresponding to adjacency constraint and symmetric con- straint respectively.

Key Results

TokenPose delivers competitive state-of-the-art performance while being drastically more lightweight than fully convolutional networks:

  • TokenPose-S (Small) achieves 72.5 AP on the COCO validation set, matching the accuracy of SimpleBaseline-Res50 while requiring 80.6% fewer parameters (6.6M vs 34.0M) and 75.3% fewer GFLOPs.
  • TokenPose-L (Large) achieves 75.8 AP on COCO validation, matching or outperforming HRNet-W48 while cutting parameters by 56.8% and GFLOPs by 24.7%.
  • TokenPose-T (Pure Transformer) proves that a pure attention-based model trained completely from scratch can perform effectively, achieving 65.6 AP with only 5.8M parameters and 1.3 GFLOPs.

Limitations and Future Work

  • Token Fusion Discrepancy: The authors introduced "keypoint token fusion"—concatenating keypoint tokens from intermediate layers to provide multi-scale supervision. While this boosted the accuracy of large models (TokenPose-L), it caused performance degradation in smaller variants like TokenPose-S.
  • The Pure Transformer Gap: Although TokenPose-T represents a breakthrough for pure Transformer architectures in 2D pose estimation, its performance (65.6 AP) still lags significantly behind hybrid models that utilize a CNN backbone. Eliminating the reliance on CNN pre-extraction without sacrificing accuracy remains an open challenge.

Summary updated

BibTeX
@inproceedings{li2021tokenpose,
  author = {Yanjie Li and Shoukui Zhang and Zhicheng Wang and Sen Yang and Wankou Yang and Shu-Tao Xia and Erjin Zhou},
  title = {{TokenPose: Learning Keypoint Tokens for Human Pose Estimation}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.01112},
}
Figure