Skip to content
/ GAFlow Public

PyTorch implementation of GAFlow: Incorporating Gaussian Attention into Optical Flow (ICCV-2023)

Notifications You must be signed in to change notification settings

LA30/GAFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[ICCV 2023] GAFlow: Incorporating Gaussian Attention into Optical Flow

Ao Luo1, Fan Fang2, Xin Li2, Lang Nie3, Chunyu Lin3, Haoqiang Fan1, and Shuaicheng Liu4,1

1. Megvii Research   2. Group 42   3.Beijing Jiaotong University

4. University of Electronic Science and Technology of China

This project provides the official implementation of 'GAFlow: Incorporating Gaussian Attention into Optical Flow'.

Abstract

Optical flow, or the estimation of motion fields from image sequences, is one of the fundamental problems in computer vision. Unlike most pixel-wise tasks that aim at achieving consistent representations of the same category, optical flow raises extra demands for obtaining local discrimination and smoothness, which yet is not fully explored by existing approaches. In this paper, we push Gaussian Attention (GA) into the optical flow models to accentuate local properties during representation learning and enforce the motion affinity during matching. Specifically, we introduce a novel Gaussian-Constrained Layer (GCL) which can be easily plugged into existing Transformer blocks to highlight the local neighborhood that contains fine-grained structural information. Moreover, for reliable motion analysis, we provide a new Gaussian-Guided Attention Module (GGAM) which not only inherits properties from Gaussian distribution to instinctively revolve around the neighbor fields of each point but also is empowered to put the emphasis on contextually related regions during matching. Our fully-equipped model, namely Gaussian Attention Flow network (GAFlow), naturally incorporates a series of novel Gaussian-based modules into the conventional optical flow framework for reliable motion analysis. Extensive experiments on standard optical flow datasets consistently demonstrate the exceptional performance of the proposed approach in terms of both generalization ability evaluation and online benchmark testing.

Overview

Our GAFlow contains two pivotal modules: i) Gaussian-Constrained Layer (GCL) to enhance the local information. It help capture more discriminative features for optical flow estimation. ii) Gaussian-Guided Attention Module, which is flexible to refine motion features by learning the deformable Gaussian attention.

fig_2

Requirements

Python 3.8 with following packages

pytorch  1.11.0+cu102
torchvision  0.12.0
numpy  1.23.5
matplotlib  3.7.1
opencv-python  4.7.0.72
einops  0.6.1
easydict  1.10 
scipy  1.10.1
timm  0.9.2
tensorboard  2.13.0
cupy-cuda100  9.6.0

pip3 install natten -f https://shi-labs.com/natten/wheels/cu102/torch1.11/index.html

(The code has been tested on Cuda 12.0.)

Usage

  1. The trained weights are available on GoogleDrive. Put *.pth files into folder ./weights.

  2. Download Sintel and KITTI dataset, and set the root path of each class in ./core/datasets.py.

  3. Evaluation on Sintel and KITTI

./eval_sintel_kitti.sh

Citation

If you think this work is helpful, please cite

@inproceedings{luo2023gaflow,
  title={Gaflow: Incorporating gaussian attention into optical flow},
  author={Luo, Ao and Yang, Fan and Li, Xin and Nie, Lang and Lin, Chunyu and Fan, Haoqiang and Liu, Shuaicheng},
  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
  pages={9642--9651},
  year={2023}
}

If you have any questions, please contact me at ([email protected]).

Acknowledgement

The code is built based on RAFT, GMFlowNet and SKFlow. We thank the authors for their contributions.

About

PyTorch implementation of GAFlow: Incorporating Gaussian Attention into Optical Flow (ICCV-2023)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages