E-RAFT: Dense Optical Flow from Event Cameras

Related tags

Deep Learning E-RAFT
Overview

E-RAFT: Dense Optical Flow from Event Cameras

E-RAFT

This is the code for the paper E-RAFT: Dense Optical Flow from Event Cameras by Mathias Gehrig, Mario Millhäusler, Daniel Gehrig and Davide Scaramuzza.

We also introduce DSEC-Flow (download here), the optical flow extension of the DSEC dataset. We are also hosting an automatic evaluation server and a public benchmark!

Visit our project webpage or download the paper directly here for more details. If you use any of this code, please cite the following publication:

@InProceedings{Gehrig3dv2021,
  author = {Mathias Gehrig and Mario Millh\"ausler and Daniel Gehrig and Davide Scaramuzza},
  title = {E-RAFT: Dense Optical Flow from Event Cameras},
  booktitle = {International Conference on 3D Vision (3DV)},
  year = {2021}
}

Download

Download the network checkpoints and place them in the folder checkpoints/:

Checkpoint trained on DSEC

Checkpoint trained on MVSEC 20 Hz

Checkpoint trained on MVSEC 45 Hz

Installation

Please install conda. Then, create new conda environment with python3.7 and all dependencies by running

conda env create --file environment.yml

Datasets

DSEC

The DSEC dataset for optical flow can be downloaded here. We prepared a script download_dsec_test.py for your convenience. It downloads the dataset directly into the OUTPUT_DIRECTORY with the expected directory structure.

download_dsec_test.py OUTPUT_DIRECTORY

MVSEC

To use the MVSEC dataset for our approach, it needs to be pre-processed into the right format. For your convenience, we provide the pre-processed dataset here:

MVSEC Outdoor Day 1 for 20 Hz evaluation

MVSEC Outdoor Day 1 for 45 Hz evaluation

Experiments

DSEC Dataset

For the evaluation of our method with warm-starting, execute the following command:

python3 main.py --path 
   

   

For the evaluation of our method without warm-starting, execute the following command:

python3 main.py --path 
   
     --type standard

   

MVSEC Dataset

For the evaluation of our method with warm-starting, trained on 20Hz MVSEC data, execute the following command:

python3 main.py --path 
   
     --dataset mvsec --frequency 20

   

For the evaluation of our method with warm-starting, trained on 45Hz MVSEC data, execute the following command:

python3 main.py --path 
   
     --dataset mvsec --frequency 45

   

Arguments

--path : Path where you stored the dataset

--dataset : Which dataset to use: ([dsec]/mvsec)

--type : Evaluation type ([warm_start]/standard)

--frequency : Evaluation frequency of MVSEC dataset ([20]/45) Hz

--visualize : Provide this argument s.t. DSEC results are visualized. MVSEC experiments are always visualized.

--num_workers : How many sub-processes to use for data loading (default=0)

Comments
  • Reproducing training code

    Reproducing training code

    Hi,

    Thanks for your amazing work!! I am currently trying to reproduce train.py (mainly copy from RAFT project). Some training details are listed as following:

    1. learning rate: 1e-4.
    2. epochs: 40.
    3. loss: sequence loss from RAFT (https://github.com/princeton-vl/RAFT/blob/master/train.py#L47) with gamma equals to 0.8.
    4. random crop size [288, 384]

    However, the performance is not satisfying even on training set (e.g. 1.207 epe on croped image/events and 2.913 epe on full image/events).

    Did this happen to you while training? Looking forward to your reply.

    The following are screenshots of my training status. Notice that 1px/3px/5px means the ratio of pixels whose epe is smaller than xx px compared with all valid pixels.

    image image
    opened by eugenelyj 10
  • Training usingDSEC-Flow dataset

    Training usingDSEC-Flow dataset

    I'm trying to train the model using desc-flow dataset. While trying, I got some questions about it.

    In this page (https://dsec.ifi.uzh.ch/dsec-datasets/download/), I could check that gt flow is consisted of png.

    • png : ( 480, 640, 3 , uint8) _ like below
    • Is it correct gt flow? Or Should i transform that png file for using in training? image

    And In 'dsec_loader.py', there is an function "load_flow" and I thought that function makes the flow & valid2d from png. But When i apply the training dataset(.png flow) to the function('load_flow'), I get the tensor filled with only 0. And also that function require uint16 data type, but the png file that i downloaded in above link is uint8.

    So I want to ask : How can i generate the correct GT Flow & Mask(valid2d) from training dataset(.png flow)? And If i want to train the E-Raft model using dsec dataset, should i train the model by comparing the flow generated from png and predictions?

    Also When i debugged the 'dsec_loader.py', flow_timestamp variable is entered the image timestamps in "image_timestamp.txt". Why should we put the image timestamp value in flow timestamp variable? Is it because the test dataset generate the gt flow as a image and measures the metric? If then, When i want to train the model using training dataset(dsec) in above link, should flow timestamp.txt value be entered as the flow timestamp variable?

    Your reply will help me a lot. Thank you so much:)

    opened by Harin99 7
  • How to find  the  ground truth  flow corresponding to events?

    How to find the ground truth flow corresponding to events?

    Hi, thanks a lot for your work. I am confused about how to find the ground truth flow corresponding to events during training. The ground truth flows are give with timestamps, should I use the timestamps to relate them to events? And what's the usage of ' ms_to_idx' in the events.h5 file ? Can you give me some introductions and suggestions? Thanks a lot.

    opened by Hazeliii 7
  • Some questions about training a model on DSEC dataset.

    Some questions about training a model on DSEC dataset.

    Hi,Mathias

    Thanks for your cooperation!

    The problem about the calibration between the event camera and the frame camera has solved with your help! Thanks again!

    The test code for the E-RAFT has published in github, it’s a wonderful work!

    In addition, I’d like to ask some questions about training the model for estimating the optical flow on DSEC dataset.

    1. During supervision training on the model for E-RAFT, how to preprocess the ground truth of optical flow.

    2. Currently, the network I proposed can converge on MVSEC dataset and get reasonable results. But it cannot converge on the DSEC dataset with the same network and the loss falls into local optimizaiton. I have tried many solutions (BN, Data Augmentation and so on), but still don’t work. What’s the reason do you think cause this problem.

    3. How to prepare the trianing data of DSEC for optical flow estimation. My current approach is that choose the RGB frame and events according to the timestamps of optical flow maps. For example, the t1 and t2 is the timestamps of the optical flow map. Then the RGB_frame_1 and RGB_frame_2 which the t1 and t2 in theis exposure timestamps respectively. As for choose the events, just run the code that “event_data = eventslice.get_events(t1,t2)”.

    I am not sure if the appoach mentioned above is correct.

    Looking forward to receiving your reply!

    Best regards,

    Chi

    opened by bestrivenzc 3
  • Problem with extracting parts of sequences that contain static scenes

    Problem with extracting parts of sequences that contain static scenes

    Hi Mathias, Thank you for publishing this project. It is very helpful.

    I am trying to do the data manipulation of the dataset but I found that you have removed some parts manually since they are static. I found that my results for training is not good at all, and I suspect doing something wrong in this truncation part.

    My method works as follows:

    1. I compare the elements one by one from both lists "file" and "self.timestamps_flow" from class "Sequence".
    2. Since I compare after you created "self.timestamps_flow", When I find mismatch between the two lists, I remove the current element from "self.timestamps_flow" then continue deleting elements from it until I find the current element from both lists are equal, and so on.
    3. For some sequences, I found that a part at the end of the file should be deleted as well, so I wrote an extra condition that in case that I reach the end of the "file" list, then I delete the rest of elements from "self.timestamps_flow" after that index.

    After applying the above algorithm, I had more than 8000 samples, but you mentioned that they are 7800 samples only.

    I would be grateful if you enlightened me with what might be the problem.

    Thanks in advance

    opened by LuckyShrek 2
  • The experiments results given in the paper

    The experiments results given in the paper

    Hi,Mathias

    There are 4 tables in the paper showing the experiment results. I assume they are all evaluation results.

    The table 2 and table 3 are the MVSEC results. In my opinion, the EV-FLOW and E-RAFT are trained and evaluated with MVSEC dataset. Am I right?

    table1

    table3

    Are results in table 4 achieved by training EV-FLOW and E-RAFT both on DSEC dataset ? Or are they just trained on MVSEC but evaluated with DSEC?If they are trained and evaluated both on DSEC, why are the results of E-RAFT not good as the results trained on MVSEC?

    table4

    The ablation study are trained and evaluated separately on DSEC and MVSEC, right ?

    table5

    I hope that I express my problem clearly.

    opened by Hazeliii 2
  • About training EV-FlowNet using DSEC dataset

    About training EV-FlowNet using DSEC dataset

    Hi Mathias, I notice that you trained EV-FlowNet on DSEC for Comparison, but I am not sure the parameters setting. I want to know if the data setting is always consistent with the one used on training E-RAFT. (e.g. the voxel bins ==15 in loader-dsec.py)

    By the way, since the GT flow in test dataset is unavailable, I randomly split the training set for training and testing, and found that the domain gap caused by day/night sequential difference is obvious. Does that influence the training result a lot ?

    opened by HTLeoo 2
  • Sequence_length meaning

    Sequence_length meaning

    Hello, I'm implementing the training code of E-RAFT. But there's a sequence_length variable in the paper and code, so what exactly does that mean?

    If i set a sequence_length = 2, it seemed like 2 sequential data were being loaded on the code. ( like below ) e.g) [ 0, 1 ]

    If so, by any chance, Can i think of sequence_length as the number of applying warm_start at once?

    For example, if i set the batch_size = 2 & sequence_length = 5, the sequence data will be loaded by 2 batches of 5 each like below. 1 batch : [0, 1, 2, 3, 4] 2 batch : [10, 11, 12, 13, 14] In each batch, the first "flow_init" variable will be initialized to 0, then warm start will be applied.

    Is it right way that i understood it now?

    Thank you for your great work!!

    opened by Harin99 1
  • How to pre-process the MVSEC dataset for training?

    How to pre-process the MVSEC dataset for training?

    Hi,Mathias

    I want to train the E-RAFT on the MVSEC dataset but I don't know how to pre-process the dataset .

    I downloaded the MVSEC Outdoor Day 1 for 20 Hz evaluation that you released, but it is so different from the original data set. I don't know how to split the data into so many files and how to generate the 3 different timestamps_XXX.txt files.

    Would it be possible for you to release the code for processing it ?

    Thanks a lot.

    opened by Hazeliii 1
  • Having some unexpected results with the test code

    Having some unexpected results with the test code

    Greetings, I am trying to load my checkpoint in the test code to get the results and submit on the benchmark but I encountered some problems, I would be grateful for your help.

    1. I found that the test code saves in two folders called "submission" and "visualizations" and I followed the code and found that you don't save a flow file in the "submission" folder for each sample of the input sequences, does this mean that evaluation in the benchmark doesn't use all of the GT flow of the test sequences?

    2. I was trying to run the test code on my GPU but I got an error in. I debugged the error and found that using the GPU will use the following line from test.py in the _test function batch = self.move_batch_to_cuda(batch) After this line, the variables in the batch changes from int to float, which resulted in having the following values for the first sample in the function "visualize_events" in visualization.py when using the cpu:

    The t_start_us is: 49740000566 The t_end_us os: 49740100566

    and in case I used the GPU, those values became:

    The t_start_us is: 49740001280.0 The t_end_us os: 49740101280.0

    which results in an error at the last sample of the first sequence in the function "visualize_flow_colours" in visualization.py.

    I am using the latest version of the test code, but I added only the following line in the main.py due to having some error:

    os.environ["GIT_PYTHON_REFRESH"] = "quiet"

    Do you have an idea about what might be the problem? is it necessary to use the CPU?

    1. Is it better any way in having the batch number greater than 1 while running the test code?

    2. I am getting bad results when I load my checkpoint, the flow images in the submission folder are like the one below: 000020

    I am not sure about what the problem might be, given that the validation and training epe graphs are very good. I save the whole model in my checkpoint in the train code (with extension .pth) and then load it back in the test code. Do you have any advice regarding this?

    Thanks in advance for your help

    opened by LuckyShrek 1
  • Questions about evaluation

    Questions about evaluation

    Hi,Mathias

    I noticed that there are no ground truth flow in the evaluation or test sequences of DSEC dataset, and some training sequences neither. Did you just split the sequences with ground truth into training and test sequence to get the EPE score?

    opened by Hazeliii 2
  • Plan to release training source code

    Plan to release training source code

    Is there any plan to release the source code for training? It will be greatly beneficial for the community and later works for a comparison in the future.

    enhancement 
    opened by wponghiran 2
Owner
Robotics and Perception Group
Robotics and Perception Group
Official PyTorch implementation of N-ImageNet: Towards Robust, Fine-Grained Object Recognition with Event Cameras (ICCV 2021)

N-ImageNet: Towards Robust, Fine-Grained Object Recognition with Event Cameras Official PyTorch implementation of N-ImageNet: Towards Robust, Fine-Gra

null 32 Dec 26, 2022
Demo code for paper "Learning optical flow from still images", CVPR 2021.

Depthstillation Demo code for "Learning optical flow from still images", CVPR 2021. [Project page] - [Paper] - [Supplementary] This code is provided t

null 130 Dec 25, 2022
Learning Optical Flow from a Few Matches (CVPR 2021)

Learning Optical Flow from a Few Matches This repository contains the source code for our paper: Learning Optical Flow from a Few Matches CVPR 2021 Sh

Shihao Jiang (Zac) 159 Dec 16, 2022
A lightweight deep network for fast and accurate optical flow estimation.

FastFlowNet: A Lightweight Network for Fast Optical Flow Estimation The official PyTorch implementation of FastFlowNet (ICRA 2021). Authors: Lingtong

Tone 161 Jan 3, 2023
Unsupervised Learning of Multi-Frame Optical Flow with Occlusions

This is a Pytorch implementation of Janai, J., Güney, F., Ranjan, A., Black, M. and Geiger, A., Unsupervised Learning of Multi-Frame Optical Flow with

Anurag Ranjan 110 Nov 2, 2022
Pytorch implementation of FlowNet 2.0: Evolution of Optical Flow Estimation with Deep Networks

flownet2-pytorch Pytorch implementation of FlowNet 2.0: Evolution of Optical Flow Estimation with Deep Networks. Multiple GPU training is supported, a

NVIDIA Corporation 2.8k Dec 27, 2022
a reimplementation of Optical Flow Estimation using a Spatial Pyramid Network in PyTorch

pytorch-spynet This is a personal reimplementation of SPyNet [1] using PyTorch. Should you be making use of this work, please cite the paper according

Simon Niklaus 269 Jan 2, 2023
A fast model to compute optical flow between two input images.

DCVNet: Dilated Cost Volumes for Fast Optical Flow This repository contains our implementation of the paper: @InProceedings{jiang2021dcvnet, title={

Huaizu Jiang 8 Sep 27, 2021
Demo code for ICCV 2021 paper "Sensor-Guided Optical Flow"

Sensor-Guided Optical Flow Demo code for "Sensor-Guided Optical Flow", ICCV 2021 This code is provided to replicate results with flow hints obtained f

null 10 Mar 16, 2022
A project that uses optical flow and machine learning to detect aimhacking in video clips.

waldo-anticheat A project that aims to use optical flow and machine learning to visually detect cheating or hacking in video clips from fps games. Che

waldo.vision 542 Dec 3, 2022
A project that uses optical flow and machine learning to detect aimhacking in video clips.

waldo-anticheat A project that aims to use optical flow and machine learning to visually detect cheating or hacking in video clips from fps games. Che

waldo.vision 383 Nov 1, 2021
MMFlow is an open source optical flow toolbox based on PyTorch

Documentation: https://mmflow.readthedocs.io/ Introduction English | 简体中文 MMFlow is an open source optical flow toolbox based on PyTorch. It is a part

OpenMMLab 688 Jan 6, 2023
UnFlow: Unsupervised Learning of Optical Flow with a Bidirectional Census Loss

UnFlow: Unsupervised Learning of Optical Flow with a Bidirectional Census Loss This repository contains the TensorFlow implementation of the paper UnF

Simon Meister 270 Nov 6, 2022
Traditional deepdream with VQGAN+CLIP and optical flow. Ready to use in Google Colab

VQGAN-CLIP-Video cat.mp4 policeman.mp4 schoolboy.mp4 forsenBOG.mp4

null 23 Oct 26, 2022
[CVPR 2022] Deep Equilibrium Optical Flow Estimation

Deep Equilibrium Optical Flow Estimation This is the official repo for the paper Deep Equilibrium Optical Flow Estimation (CVPR 2022), by Shaojie Bai*

CMU Locus Lab 136 Dec 18, 2022
Weakly Supervised Dense Event Captioning in Videos, i.e. generating multiple sentence descriptions for a video in a weakly-supervised manner.

WSDEC This is the official repo for our NeurIPS paper Weakly Supervised Dense Event Captioning in Videos. Description Repo directories ./: global conf

Melon(Xuguang Duan) 96 Nov 1, 2022
Generic Event Boundary Detection: A Benchmark for Event Segmentation

Generic Event Boundary Detection: A Benchmark for Event Segmentation We release our data annotation & baseline codes for detecting generic event bound

null 47 Nov 22, 2022
Scikit-event-correlation - Event Correlation and Forecasting over High Dimensional Streaming Sensor Data algorithms

scikit-event-correlation Event Correlation and Changing Detection Algorithm Theo

Intellia ICT 5 Oct 30, 2022
Event-forecasting - Event Forecasting Algorithms With Python

event-forecasting Event Forecasting Algorithms Theory Correlating events in comp

Intellia ICT 4 Feb 15, 2022