CapsFlow: Optical Flow Estimation with Capsule Networks

Rahul Chand, Rajat Arora, K. Ram Prabhakar, R. Venkatesh Babu · OpenReview

Abstract

We present a framework to use recently introduced Capsule Networks for solving the problem of Optical Flow, one of the fundamental computer vision tasks. Most existing state-of-the-art deep architectures use a correlation operation to match features. While correlation layers are sensitive to hyperparameter choices and do not impose a prior on the underlying structure of objects, spatio-temporal features are limited by the network's receptive field. Humans perceive moving objects as cohesive wholes, a property not easily encoded by correlation or local spatio-temporal features. Capsules, however, are specialized to model separate entities and their poses as continuous matrices. We demonstrate that a simple linear operation over the poses of objects detected by capsules is sufficient to model flow. Our results on synthetic datasets show that CapsFlow outperforms established models like FlowNetC and PWC-Net with significantly fewer parameters.

Introduction

Optical flow estimation—calculating per-pixel motion between consecutive frames—is a cornerstone of computer vision. Current dominance by Convolutional Neural Networks (CNNs) often relies on "correlation layers" to search for pixel correspondences. However, these layers suffer from hyperparameter sensitivity (e.g., search window size) and a lack of structural priors, treating pixels as independent units rather than parts of a cohesive object.

CapsFlow addresses these limitations by leveraging Capsule Networks. Instead of exhaustive pixel matching, it models entities and their spatial relationships (poses) directly. This approach aligns more closely with human perception, where motion is understood through the displacement of whole objects.

Methodology

CapsFlow utilizes a Siamese architecture to process image pairs ($I_1$ and $I_2$). The pipeline consists of a convolutional encoder, capsule layers, and specialized decoders.

The CapsFlow architecture: A Siamese network extracting capsules and calculating motion as the difference between pose matrices.

The core innovation lies in treating Motion as Pose Difference. Features from the encoder are converted into capsules, where each capsule's output is a $4 \times 4$ pose matrix encoding position, orientation, and scale. Motion is calculated by subtracting the pose matrix of an object in $I_1$ from its pose in $I_2$. This linear operation replaces complex correlation searches. A convolutional decoder then produces the dense flow map, while a reconstruction decoder ensures capsules learn meaningful object structures during training.

Experiments and Results

The model was evaluated on custom synthetic datasets (Toy Shape and MultiShape) and the standard Flying Chairs benchmark.

Qualitative comparison of optical flow estimation between Ground Truth, FlowNet-C, and CapsFlow across various shapes.

On the single-shape toy dataset, CapsFlow achieved an End-Point Error (EPE) of 0.39, outperforming FlowNetC (0.50) and PWC-Net (0.47). Remarkably, CapsFlow achieved this with only 1.62 million parameters, roughly 1/24th the size of FlowNetC (39.17 million). Furthermore, CapsFlow demonstrated superior generalization; when tested on motion magnitudes 1.5x larger than those in the training set, its error remained stable while FlowNetC's error tripled.

Discussion and Conclusion

CapsFlow successfully disentangles flow from structure. Flow is derived from pose differences, while shape is reconstructed from absolute poses. This separation allows for excellent generalization to unseen motion scales because the model treats motion as a continuous matrix transformation rather than a discrete search.

However, challenges remain. The iterative EM routing in Capsule Networks makes CapsFlow slower than traditional CNNs (13.39ms vs 3.1ms for FlowNetC). Additionally, the current reliance on explicit object classes limits performance on complex, "unmasked" real-world scenes like Flying Chairs (EPE of 3.6 vs FlowNetC's 2.0). Future work will focus on extending capsules to latent entities without requiring explicit class supervision, potentially unlocking the full power of structural priors for general optical flow tasks.

Summary updated

BibTeX
@misc{chand2023capsflow,
  author = {Rahul Chand and Rajat Arora and K. Ram Prabhakar and R. Venkatesh Babu},
  title = {{CapsFlow: Optical Flow Estimation with Capsule Networks}},
  year = {2023},
  eprint = {2304.00306},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.00306},
}
Figure