TransFlow: Transformer as Flow Learner

Yawen Lu, Qifan Wang, Siqi Ma, Tong Geng, Yingjie Victor Chen, Huaijin G. Chen, Dongfang Liu

TL;DR

This paper introduces TransFlow, a novel optical flow estimation model that leverages a pure Transformer architecture. By employing spatial self-attention and temporal associations, TransFlow achieves state-of-the-art results on standard benchmarks and demonstrates improved handling of occlusions and motion blur, all while simplifying the training pipeline.

What Problem Does This Paper Address?

Estimating optical flow, which involves predicting the motion of pixels between consecutive frames in a video, is a fundamental task in computer vision with applications in object tracking, motion estimation, and more. Traditional methods often rely on Convolutional Neural Networks (CNNs). However, these CNN-based approaches face limitations: they struggle to capture long-range spatial dependencies due to the inherent locality of convolutions, often fail to effectively model temporal associations across multiple frames (especially in dynamic or occluded scenes), and typically require extensive, multi-stage pre-training on large synthetic datasets, making the training process complex and time-consuming. This paper aims to overcome these limitations by proposing a Transformer-based architecture for optical flow.

Methods

TransFlow is built upon a pure Transformer architecture, moving away from traditional CNNs. Its core components are:

  • Spatial-Temporal Encoder: This module uses a series of Multi-head Self-Attention (MSA) and Multi-head Cross-Attention (MCA) layers. MSA captures global pixel dependencies within a single frame, while MCA facilitates communication between adjacent frames. This allows TransFlow to effectively model global spatial dependencies and recover information from occluded or blurred regions. The encoder also incorporates temporal association, learning from multiple frames to capture long-range temporal information, which is crucial for handling dynamic scenes.
  • Flow Decoder: This component decodes the feature maps from multiple frames to generate the final optical flow. Unlike traditional Transformer decoders, it generates multiple feature maps simultaneously, avoiding autoregressive decoding and simplifying the process.
  • Self-supervised Pre-training Module: Inspired by Masked Autoencoders (MAE), TransFlow introduces a concise self-learning paradigm. It adaptively masks out patch tokens and learns to reconstruct clean signals from corrupted inputs. This significantly reduces the need for laborious multi-stage pre-training on external datasets, making the training pipeline more efficient.

Datasets

The paper uses the following datasets for training and evaluation:

  • FlyingChairs: Used for pre-training.
  • FlyingThings: Used for pre-training.
  • Sintel: A standard benchmark for optical flow evaluation, used for both training and testing (clean and final passes).
  • KITTI-15: Another standard benchmark for optical flow, used for training and testing (with Fl-epe and Fl-all metrics).
  • ImageNet VID: Used for evaluating downstream tasks like video object detection.
  • GoPro: Used for evaluating downstream tasks like video frame interpolation.
  • DeepStab: Used for evaluating downstream tasks like video stabilization.

Key Insights and Ideas

  • Transformers for Global Dependencies: The paper demonstrates that Transformers, with their self-attention mechanisms, are inherently well-suited for capturing long-range spatial dependencies in optical flow, a task where CNNs often struggle due to their local receptive fields.
  • Temporal Association for Robustness: Explicitly modeling temporal associations across multiple frames allows TransFlow to recover information from occluded or motion-blurred regions, leading to more robust flow estimation in challenging scenarios.
  • Simplified Training: The self-supervised pre-training strategy significantly reduces the reliance on extensive, multi-stage pre-training, making the overall training pipeline more efficient and accessible.
  • Unified Architecture: TransFlow's pure Transformer design offers a unified approach to optical flow, potentially paving the way for more generalizable vision models.

Key Results

TransFlow achieves state-of-the-art results on the Sintel and KITTI-15 benchmarks.

  • Sintel: Achieves 0.93 AEPE on the clean pass and 2.33 AEPE on the final pass, outperforming previous methods like RAFT by 0.50 and 0.38 respectively, without extensive pre-training.
  • KITTI-15: Reduces the Fl-all error by 17.2% compared to RAFT.
  • Downstream Tasks: When used as a feature extractor, TransFlow improves performance on video object detection (e.g., 3.7% mAP increase with RDN), video frame interpolation (e.g., 0.29 dB PSNR increase with SuperSloMo), and video stabilization.
  • Qualitative Results: TransFlow shows superior capability in distinguishing occluded regions and handling small, thin objects, as visualized in qualitative comparisons.

Limitations and Future Work

  • Positional Embeddings: While the paper explores different positional embeddings, it notes that learnable absolute positional embeddings perform slightly better than fixed ones, suggesting that absolute position encoding is important for object motion. Further research could explore more advanced positional encoding strategies.
  • Temporal Length: The paper finds that increasing temporal length improves performance up to a point, but saturates around 5-7 frames. Future work could investigate more efficient ways to leverage longer temporal contexts.
  • Generalizability: The paper demonstrates strong generalization capabilities, but further exploration into the limits of its transferability to even more diverse and challenging scenarios could be beneficial.
  • Future Work: The authors express hope that TransFlow can serve as a flexible baseline for optical flow estimation and provide valuable insights for future research in Transformer-based vision tasks.

Summary updated

BibTeX
@inproceedings{lu2023transflow,
  author = {Yawen Lu and Qifan Wang and Siqi Ma and Tong Geng and Yingjie Victor Chen and Huaijin G. Chen and Dongfang Liu},
  title = {{TransFlow: Transformer as Flow Learner}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
  url = {https://openreview.net/forum?id=mVmNrcVo0g},
}
Figure