Motion Guided Token Compression for Efficient Masked Video Modeling

Yukun Feng, Yangming Shi, Fengze Liu, Tan YanarXiv 2024 · DOI

Abstract

Video Transformers face significant computational challenges due to the quadratic complexity of their attention mechanisms, often necessitating low frame rates that compromise temporal resolution. We present Motion Guided Token Compression (MGTC), a plug-and-play method that identifies and masks redundant video patches based on temporal pixel differences. By focusing computation on regions with significant motion, MGTC enables models to process higher-resolution temporal data with reduced computational overhead and improved accuracy.

Introduction: The Computational Tax of Video Transformers

Transformers have revolutionized video understanding, yet their deployment is hindered by a "computational tax." The attention mechanism's complexity grows quadratically ($O(N^2)$) with the number of input tokens. To maintain feasibility, researchers often resort to low Frames Per Second (FPS), which can lead to a "strobe effect" where fast-moving objects appear disjointed, making it difficult for models to recognize subtle actions. While increasing FPS improves temporal resolution, it introduces substantial redundancy—such as static backgrounds—that consumes hardware resources without providing novel information.

Methodology: Motion Guided Token Compression (MGTC)

MGTC addresses this redundancy by drawing inspiration from traditional video compression techniques like H.264. The process involves four key steps:

  1. Sub-block Division: The input video is partitioned into 3D spatiotemporal "cubes" or tokens.
  2. Motion-Guided Masking: Unlike standard random masking, MGTC calculates the Mean Squared Error (MSE) between a patch and its corresponding patch in the subsequent frame to quantify motion.
  3. Dynamic Thresholding: Recognizing that activity levels vary across videos, MGTC calculates a unique threshold ($\lambda$) for each video, masking the "upper $N$ percent" of tokens with the least motion.
  4. Appearance Preservation: To maintain object recognition, a "key frame" is randomly selected where all patches are retained, ensuring the model preserves static appearance information.
The MGTC pipeline: calculating frame differences, applying a dynamic threshold, and generating the final motion-guided mask.

Experimental Setup and Datasets

The effectiveness of MGTC was evaluated on three major video recognition benchmarks:

  • Kinetics-400: A large-scale dataset featuring ~240k videos across 400 action classes.
  • UCF101: A dataset focused on 101 human action categories.
  • HMDB51: A dataset containing 51 distinct action categories.

Key Insights

Temporal Resolution vs. Redundancy

Analysis of pixel-residual distributions reveals that 25% to 40% of video patches exhibit near-zero change between frames. MGTC leverages this by treating redundancy as a feature to be exploited rather than a bug. By masking these static regions, the method acts as a de-noising mechanism, allowing the model to prioritize informative, high-motion areas.

The Efficiency-Accuracy Trade-off

A critical finding is that higher FPS provides a significant accuracy boost if the computational cost can be managed. MGTC makes high-FPS processing affordable. For instance, a high-FPS model with 50% masking can outperform a low-FPS model using all its tokens, suggesting that temporal resolution is often more valuable than exhaustive spatial coverage of static pixels.

Results and Performance

MGTC consistently outperforms alternative masking strategies such as Random Masking or Cell Running Masking across various masking ratios. On Kinetics-400, MGTC with a 25% masking ratio reduced computational costs (GFLOPs) by over 31% while slightly increasing Top-1 accuracy by 0.1%.

Comparison of Top-1 Accuracy across different masking ratios for Random masking, Cell Running masking, and MGTC.

When integrated with a ViT-L backbone, MGTC achieved a state-of-the-art 85.5% Top-1 accuracy on Kinetics-400, surpassing established models like VideoSwin and MViTv1.

Limitations and Future Directions

While MGTC demonstrates significant gains, several areas for future work remain:

  • Pre-training Integration: This study applied MGTC post-pre-training. Incorporating it during the initial pre-training phase could further accelerate the learning process.
  • Sophisticated Motion Metrics: The current use of pixel-wise MSE is efficient but simple. Future research could explore more intuitive or semantic-aware methods for identifying informative patches.
  • Hardware Optimization: While GFLOPs are reduced, actual wall-clock speedups are dependent on the efficiency of sparse masking implementations in specific GPU kernels.

Summary updated

BibTeX
@misc{feng2024motion,
  author = {Yukun Feng and Yangming Shi and Fengze Liu and Tan Yan},
  title = {{Motion Guided Token Compression for Efficient Masked Video Modeling}},
  year = {2024},
  eprint = {2402.18577},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.18577},
}
Figure