Learning by Aligning Videos in Time

Sanjay Haresh, Sateesh Kumar, Huseyin Coskun, Shahram Najam Syed, Andrey Konin, M. Zeeshan Zia, Quoc-Huy Tran

Abstract

We present a self-supervised approach for learning video representations using temporal video alignment as a pretext task, while exploiting both frame-level and video-level information. We leverage a novel combination of temporal alignment loss and temporal regularization terms, which can be used as supervision signals for training an encoder network. Specifically, the temporal alignment loss (i.e., Soft-DTW) aims for the minimum cost for temporally aligning videos in the embedding space. However, optimizing solely for this term leads to trivial solutions, particularly, one where all frames get mapped to a small cluster in the embedding space. To overcome this problem, we propose a temporal regularization term (i.e., Contrastive-IDM) which encourages different frames to be mapped to different points in the embedding space. Extensive evaluations on various tasks, including action phase classification, action phase progression, and fine-grained frame retrieval, on three datasets, namely Pouring, Penn Action, and IKEA ASM, show superior performance of our approach over state-of-the-art methods for self-supervised representation learning from videos. In addition, our method provides significant performance gain where labeled data is lacking.

Introduction

Deep learning for video understanding, such as action recognition or surgical phase analysis, typically requires dense, frame-by-frame annotations. Manually labeling every second of thousands of videos is prohibitively expensive and slow. Self-supervised learning (SSL) aims to solve this by creating "pretext tasks" where the data provides its own supervision.

While previous methods have attempted to use temporal order or local cycle consistency (e.g., matching a frame from Video A to Video B and back), they often fail to capture the global progression of the entire sequence. However, simply minimizing the distance between two videos through global alignment often leads to a trivial solution: the neural network learns to map every single frame to the exact same point in the embedding space, resulting in zero alignment cost but non-discriminative features.

The Learning by Aligning Videos (LAV) framework learns representations by aligning pairs of videos in an embedding space using a combination of alignment loss and temporal regularization.

Methodology: Learning by Aligning Videos (LAV)

The proposed LAV framework utilizes a dual-component loss function to train an encoder (comprising a ResNet-50 backbone and 3D convolutions) to map video frames into a robust embedding space.

1. Temporal Alignment Loss (Soft-DTW)

LAV employs a differentiable version of Dynamic Time Warping (Soft-DTW). Unlike standard linear matching, DTW finds the optimal non-linear path to align two sequences that may progress at different speeds. This encourages the model to identify visual similarities across different instances of the same action.

2. Temporal Regularization (Contrastive-IDM)

To prevent the collapse into trivial solutions where all embeddings are identical, the authors introduce a novel temporal regularization term called Contrastive-IDM, adapted from the Inverse Difference Moment (IDM) used in texture analysis.

As shown in the architecture diagram, Contrastive-IDM defines a temporal window ($\sigma$): frames within the window are treated as "positives," while frames outside are "negatives." Crucially, it weights these pairs based on their temporal distance, forcing frames that are far apart in time to be distant in the embedding space while keeping neighboring frames close. This ensures that the embedding space captures the linear flow of time.

Detailed architecture of the LAV encoder and the dual-component loss function consisting of Soft-DTW and Contrastive-IDM.

Experimental Evaluation

The model was evaluated on three datasets: Pouring (simple hand actions), Penn Action (diverse sports), and IKEA ASM (complex furniture assembly). For Penn Action, the authors contributed dense per-frame labels for over 2,000 videos to the research community.

Key Results

LAV consistently outperformed state-of-the-art SSL methods like Temporal Cycle Consistency (TCC) and Time-Contrastive Networks (TCN):

  • Phase Classification: On the challenging IKEA ASM dataset, LAV achieved 29.78% accuracy, significantly higher than TCC’s 24.74%.
  • Label Efficiency: The representations are highly effective even with limited data. On the Penn Action "Bowling" task, LAV trained with only one labeled video performed comparably to a fully supervised model.
  • Fine-Grained Retrieval: In frame-retrieval tasks, LAV achieved an Average Precision (AP@5) of 89.13% on the Pouring dataset.

Discussion and Conclusion

The success of LAV highlights that global alignment provides a stronger supervision signal than local frame matching. A critical insight is the necessity of regularization; without the Contrastive-IDM term, the model fails to learn useful features. Furthermore, the time-aware weighting in the contrastive loss creates a smoother, more organized embedding space than standard contrastive approaches.

Current limitations include the assumption that videos are roughly trimmed to the action's start and end and that aligned pairs contain the same general activity. Future work will explore local alignment strategies to handle untrimmed sequences and missing action segments.

Summary updated

BibTeX
@inproceedings{haresh2021learning,
  author = {Sanjay Haresh and Sateesh Kumar and Huseyin Coskun and Shahram Najam Syed and Andrey Konin and M. Zeeshan Zia and Quoc-Huy Tran},
  title = {{Learning by Aligning Videos in Time}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2021},
  url = {https://openreview.net/forum?id=r75UpoJzcEW},
}
Figure