TransRAC: Encoding Multi-scale Temporal Correlation with Transformers for Repetitive Action Counting

Huazhang Hu, Sixun Dong, Yiqun Zhao, Dongze Lian, Zhengxin Li, Shenghua Gao · DOI

Abstract

Counting repetitive actions is widely seen in human activities such as physical exercise. Existing methods focus on performing repetitive action counting in short videos, which is tough for dealing with longer videos in more realistic scenarios. In the data-driven era, the degradation of such generalization capability is mainly attributed to the lack of long video datasets. To complement this margin, we introduce a new large-scale repetitive action counting dataset covering a wide variety of video lengths, along with more realistic situations where action interruption or action inconsistencies occur in the video. Besides, we also provide a fine-grained annotation of the action cycles instead of just counting annotation along with a numerical value. Such a dataset contains 1,451 videos with about 20,000 annotations, which is more challenging. For repetitive action counting towards more realistic scenarios, we further propose encoding multi-scale temporal correlation with transformers that can take into account both performance and efficiency. Furthermore, with the help of fine-grained annotation of action cycles, we propose a density map regression-based method to predict the action period, which yields better performance with sufficient interpretability. Our proposed method outperforms state-of-the-art methods on all datasets and also achieves better performance on the unseen dataset without fine-tuning.

Introduction

Repetitive action counting (RAC) is essential for applications like fitness tracking and industrial monitoring. However, the field has been held back by two major issues. First, existing datasets (like Countix or UCFRep) mostly consist of short, "clean" clips where actions are uniform and uninterrupted. Real-world videos are often long and "messy," featuring pauses, varying speeds, and internal/external interruptions. Second, most models are trained to predict a single numerical value (e.g., "15 push-ups"). This "black box" approach lacks interpretability; the model might get the total count right but fail to identify where individual cycles actually occur.

TransRAC aims to bridge this gap by providing a model that handles multi-scale temporal dynamics and a dataset that reflects the complexity of real-life scenarios.

Methodology

The authors propose TransRAC, an architecture built on three core stages:

Multi-scale Feature Extraction

Instead of looking at a fixed number of frames, the model uses three sliding windows of different lengths (1, 4, and 8 frames). This allows the encoder (a Video Swin Transformer) to capture features for both high-frequency actions (like jumping rope) and low-frequency actions (like slow squats).

Transformer-based Temporal Correlation

To find the "rhythm" of a video, the model calculates a temporal correlation matrix. While previous methods used simple similarity metrics like Euclidean distance, TransRAC uses self-attention mechanisms. This allows the model to learn complex dependencies across the entire video sequence more effectively, attending to periodic patterns even when the visual environment changes slightly due to camera shake or lighting shifts.

Density Map Regression

Instead of predicting a single integer, the model outputs a density map. This map represents the probability of an action cycle occurring at any specific point in time. The final count is derived by integrating (summing) this map. This approach provides high interpretability, as researchers can visualize exactly which frames the model identified as part of a cycle.

The RepCount Dataset

The paper introduces RepCount, a new benchmark that is significantly more demanding than its predecessors. It contains 1,451 videos with approximately 20,000 fine-grained annotations, split into Part-A (diverse YouTube videos) and Part-B (standardized student exercise videos).

Challenges in repetitive action counting addressed by the RepCount dataset, including interruptions, inconsistent cycles, long-form videos, and fine-grained cycle annotations.

Unlike older datasets, RepCount includes "anomaly" cases like interruptions and inconsistent periods. The average video length is nearly 30 seconds—4 to 5 times longer than previous benchmarks. By moving to density map regression, the authors treat RAC more like a localization problem than a simple regression problem.

Key Results

TransRAC set a new standard across multiple metrics, specifically Mean Absolute Error (MAE) and Off-By-One (OBO) error:

  • On RepCount Part-A: TransRAC achieved an MAE of 0.4431, nearly doubling the performance of the previous best model, RepNet (MAE 0.9950).
  • Generalization: When trained on RepCount and tested on the unseen UCFRep dataset, TransRAC achieved an OBO of 0.324, significantly better than RepNet’s 0.009 (where higher OBO in this specific context indicates better accuracy in the "off-by-one" category).
  • Ablation Studies: The authors showed that the multi-scale approach (fusing scales 1, 4, and 8) performed better than any single-scale version of the model, proving that a single temporal scale cannot capture the diversity of human movement.

Limitations and Future Work

Despite its strengths, the authors noted a few "bad cases":

  • Multi-person Confusion: The model struggles when multiple people are moving in the frame, as it may conflate their movements into a single count.
  • Temporal Imbalance: If a video has a very long lead-in or a long period of inactivity followed by a burst of actions, the density map can occasionally become imbalanced.
  • Future Directions: Improving the model's ability to isolate a single "actor" in a crowded scene and further optimizing the Transformer for even longer video sequences (minutes instead of seconds) are logical next steps.

Summary updated

BibTeX
@misc{hu2022transrac,
  author = {Huazhang Hu and Sixun Dong and Yiqun Zhao and Dongze Lian and Zhengxin Li and Shenghua Gao},
  title = {{TransRAC: Encoding Multi-scale Temporal Correlation with Transformers for Repetitive Action Counting}},
  year = {2022},
  eprint = {2204.01018},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.01018},
}
Figure