All models

flowformer_official

Optical flow from a transformer that encodes the 4D cost volume into a latent cost memory.

Depth estimation · 120 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (26 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
50K
Operations
120
Framework
PyTorch
Recurrent
No
Published
Lecture Notes in Computer Science (arXiv 2022)
Authors
Zhaoyang Huang, Xiaoyu Shi, Chao Zhang and others
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m11874
Graph hash
f88a9ef348934823b908fab9a52d8ee4f3d77ce5a39cd4c54db54509e6cceb33
Skeleton hash
c2631b71f79047f94a58c69c9fb9e694838f46912a33e5a7a798920fc7542cec
Architecture hash
f2d243978bb3817f326e731ccb8795c6aee5d1175bedbf1b757bf05c0436bd13
Diagram SHA-256
f0193c418a64758ccdec892671d7469e13949101334973361ac13b6566ba741d
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

menagerie.classics.flowformer:build_flowformer_official: build({})

What it is

FlowFormer is a transformer built for optical flow, the per-pixel displacement field that maps every location in a source image to its match in a target image. Rather than feeding raw pixels to a transformer, it keeps the 4D cost volume that CNN-based flow methods rely on: the dot-product similarities between all pixel pairs of the source and target feature maps. The question the paper sets itself is whether one can enjoy both advantages of transformers and the cost volume from the previous milestones.

Tokenizing a 4D cost volume directly would need thousands of tokens, which the authors call computationally unbearable. So the cost volume encoder patchifies each 2D cost map and projects its patches into K latent cost tokens, turning an H × W × H × W volume into H × W × K tokens. Alternate-group transformer (AGT) layers then attend alternately over tokens within the same cost map and tokens across different cost maps, producing what the paper calls the cost memory. Decoding is recurrent and inspired by RAFT: based on current estimated flows, the decoder queries the cost memory with dynamic positional cost queries and regresses flow residuals. Cost features fetched by cross-attention go into a shared gated recurrent unit (GRU) head for residual flow regression.

The image feature encoder is the first two stages of ImageNet-pretrained Twins-SVT. The cost tokens pass through 3 AGT layers.

On the Sintel benchmark FlowFormer reaches 1.159 and 2.088 AEPE on the clean and final pass, a 16.5% and 15.5% error reduction from the best published result. Without being trained on Sintel, it achieves 1.01 AEPE on the clean pass of the Sintel training set, outperforming the best published result (1.29) by 21.7%. The authors also claim to validate for the first time that an ImageNet-pretrained transformer can benefit the estimation of optical flow. Training follows the usual flow recipe: FlyingChairs and FlyingThings first, then finetuning for the Sintel and KITTI benchmarks.

Key idea. Encoding the 4D cost volume into a compact latent cost memory with alternate-group transformer layers, then decoding flow recurrently with dynamic positional cost queries.

  • FlowFormer
  • optical Flow transFormer
  • optical flow
  • cost volume
  • cost memory
  • alternate-group transformer
  • AGT
  • Sintel
  • KITTI
  • RAFT
  • dense correspondence

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{huang2022flowformertransformerarchitectureoptical,
      title={FlowFormer: A Transformer Architecture for Optical Flow}, 
      author={Zhaoyang Huang and Xiaoyu Shi and Chao Zhang and Qiang Wang and Ka Chun Cheung and Hongwei Qin and Jifeng Dai and Hongsheng Li},
      year={2022},
      eprint={2203.16194},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2203.16194}, 
}