M2Flow: A Motion Information Fusion Framework for Enhanced Unsupervised Optical Flow Estimation in Autonomous Driving
Estimating optical flow in occluded regions is a crucial challenge in unsupervised settings. In this work, we introduce M2Flow, a novel framework for unsupervised optical flow estimation that integrates motion information from multiple frames to address occlusions. By modeling inter-frame motion information and employing Motion Information Propagation (MIP) module, M2Flow effectively propagates and integrates motion information across frames, while concurrently estimating bidirectional optical flows for multiple frames. In addition, to handle occlusions across multiple frames, we provide two augmentation modules specifically designed for our multi-frame model to further refine optical flow. The experiments on KITTI and Sintel datasets demonstrate that M2Flow outperforms other state-of-the-art unsupervised approaches, especially in solving occlusions.
This code has been tested under Python 3.7.16, PyTorch 1.12.1, Torchvision 0.13.1, and CUDA 11.3 on Ubuntu 18.04. The environment can be built by the following:
# Install python packages
pip3 install -r requirements.txt
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
# Compile the coorelation package
cd ./core/Networks/correlation_package
python3 setup.py install
If you cannot compile the correlation package, please check whether you have stated the correct gcc and CUDA version in core/Networks/correlation_package/setup.py. There is also an alternative implementation (See core/Networks/pwclite_**.py; uncomment to switch implementations '# from core.Networks.correlation_native import Correlation').
-
KITTI: The following sets are required.
- KITTI-raw: Follow the instructions on KITTI raw data page to download.
- KITTI-2015 Go to KITTI flow 2015 page. Download "stereo 2015/flow 2015/scene flow 2015 data set (2 GB)" and "multi-view extension (20 frames per scene) (14 GB)".
- KITTI-2012 Go to KITTI flow 2012 page. Download "stereo/optical flow data set (2 GB)" and "multi-view extension (20 frames per scene, all cameras) (17 GB)".
-
Cityscapes: Go to Cityscapes official website. Download "leftImg8bit_sequence_trainvaltest.zip (324GB)".
-
Sintel: Go to Sintel official website. For Sintel Raw, please refer to the ARFlow repository.
Modify the file paths in the [core\flow_datasets.py] [core\flow_datasets_sintel.py] according to the unzip path.
For KITTI, We use an off-the-shelf network by Yi Zhu et al. to infer semantic segmentation inputs for our experiments. Their official code is here. Please follow their instructions to infer semantic maps. For all KITTI images, we use their "pretrained_models/kitti_best.pth[1071MB, WideResNet38 backbone]" model; for Cityscapes images, we use their "pretrained_models/cityscapes_best.pth[1071MB, WideResNet38 backbone]" model. The output semantic maps should have the same directory structure and file names as in KITTI or Cityscapes.
For Sintel, we obtained the initial masks using SAM2 (Segment Anything Model 2)(https://github.com/facebookresearch/sam2). Please refer to [flow_datasets/my_test_stam_2sintel.py]
Training on the KITTI raw dataset.
python -u train.py --config KITTI_Raw_m2flowThen use the file path of the first-stage model as the parameter for "restore_ckpt" in KITTI_MV_m2flow.py to begin fine-tuning on the MV dataset.
python -u train.py --config KITTI_MV_m2flowTrain on the Sintel dataset using similar commands.
Please refer to the parameter settings in the configuration file and the model selection in the core/Networks folder for the implementation of the ablation experiment
We have provided the final model(/checkpoints).
python -u evaluate.py --config KITTI_MV_m2flowIn this project, we use parts of codes in:
-
ARFlow github repo of Liang Liu et al., appeared in their publication Learning by Analogy: Reliable Supervision from Transformations for Unsupervised Optical Flow Estimation.
-
RAFT github repo of Zachary Teed and Jia Deng, appeared in their publication RAFT: Recurrent All Pairs Field Transforms for Optical Flow.
-
SemARFlow github repo of Shuai Yuan et al., appeared in their publication SemARFlow: Injecting Semantics into Unsupervised Optical Flow Estimation for Autonomous Driving.
-
VideoFlow github repo of Xiaoyu Shi et al., appeared in their publication VideoFlow: Exploiting Temporal Cues for Multi-frame Optical Flow Estimation.
-
Our semantic segmentation inputs are computed using two methods: 1. github repo of Yi Zhu et al., appeared in their publication Improving Semantic Segmentation via Video Propagation and Label Relaxation. 2. github repo of Nikhila Ravi et al., appeared in their publication SAM 2: Segment Anything in Images and Videos
@inproceedings{sun2025m2flow,
title={M2Flow: A Motion Information Fusion Framework for Enhanced Unsupervised Optical Flow Estimation in Autonomous Driving},
author={Sun, Xunpei and Chen, Gang and Hou, Zuoxun},
booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
volume={39},
number={7},
pages={7140--7148},
year={2025}
}