FlowFormer

Huang 2022 · Paper

One-line summary — First Transformer architecture built around the 4D cost volume for optical flow: it tokenizes the cost volume, encodes the tokens into a latent “cost memory” with alternate-group attention, and decodes flow recurrently with dynamic positional cost queries.

Problem

Optical flow estimates a per-pixel displacement field f:R2R2\mathbf{f}:\mathbb{R}^{2}\rightarrow\mathbb{R}^{2} mapping each source-image location x\mathbf{x} to its target-image correspondence p=x+f(x)\mathbf{p}=\mathbf{x}+\mathbf{f}(\mathbf{x}). RAFT builds an H×W×H×WH \times W \times H \times W 4D cost volume of all-pairs similarities but retrieves costs only from local windows, which struggles with large displacements and occlusions. Transformers offer global reasoning, but naive self-attention over thousands of cost-volume tokens is computationally unbearable — Perceiver IO attends over raw pixels instead and needs roughly 80×80\times more training examples. FlowFormer asks how to keep the compact cost volume and gain Transformer-style global aggregation.

Method & architecture

Three stages: build a 4D cost volume, encode it into cost memory, decode flow recurrently.

Kx=Conv1×1(Concat(Fx,PE)),Vx=Conv1×1(Concat(Fx,PE)),Tx=Attention(C,Kx,Vx)\mathbf{K_x}=\mathrm{Conv}_{1\times 1}(\mathrm{Concat}(\mathbf{F_x},\mathrm{PE})),\quad \mathbf{V_x}=\mathrm{Conv}_{1\times 1}(\mathrm{Concat}(\mathbf{F_x},\mathrm{PE})),\quad \mathbf{T_x}=\mathrm{Attention}(\mathbf{C},\mathbf{K_x},\mathbf{V_x})

turning the 4D volume into an H×W×KH \times W \times K token grid (K×DH×WK \times D \ll H \times W; 8 tokens of dimension 128 in the final model).

Δf(x)=ConvGRU(Concat(cx,qx),tx,f(x))\Delta\mathbf{f}(\mathbf{x})=\mathrm{ConvGRU}(\mathrm{Concat}(\mathbf{c_x},\mathbf{q_x}),\,\mathbf{t_x},\,\mathbf{f}(\mathbf{x}))

and flows are convex-upsampled to full resolution, supervised at every iteration with increasing weights.

Results

Why it matters for SLAM

Dense optical flow is the correspondence engine inside modern learned SLAM front-ends (DROID-SLAM, DPVO descendants), and FlowFormer demonstrated that global attention over matching costs resolves the long-range, ambiguous correspondences that matter most for wide-baseline motion — precisely the hard cases (large displacement, occlusion) its cost memory targets. It established the Transformer side of today’s trade-off — Transformer accuracy (FlowFormer) versus convolutional efficiency (SEA-RAFT) — that SLAM engineers weigh when picking a flow backbone.