|
| 1 | +<p align="center"> |
| 2 | + <h1 align="center">MEMFOF: High-Resolution Training for Memory-Efficient Multi-Frame Optical Flow Estimation</h1> |
| 3 | + <p align="center"> |
| 4 | + <a href="https://github.com/VladBargin">Vladislav Bargatin</a> |
| 5 | + · |
| 6 | + <a href="http://github.com/egorchistov">Egor Chistov</a> |
| 7 | + · |
| 8 | + <a href="https://github.com/AlexanderYakovenko1">Alexander Yakovenko</a> |
| 9 | + · |
| 10 | + <a href="https://linkedin.com/in/dmitriyvatolin">Dmitriy Vatolin</a> |
| 11 | + </p> |
| 12 | + <h3 align="center">ICCV 2025</h3> |
| 13 | + <h3 align="center"><a href="https://arxiv.org/abs/2506.23151">📄 Paper</a> | <a href="https://msu-video-group.github.io/memfof">🌐 Project Page</a> | <a href="https://colab.research.google.com/github/msu-video-group/memfof/blob/dev/demo.ipynb">🚀 Colab</a> | <a href="https://huggingface.co/spaces/egorchistov/MEMFOF">🤗 Demo</a></h3> |
| 14 | +</p> |
| 15 | + |
| 16 | +## 🛠️ Installation |
| 17 | + |
| 18 | +Our code is developed with pytorch >= 2.5.0, CUDA >= 12.6 and python >= 3.10. |
| 19 | + |
| 20 | +```shell |
| 21 | +git clone https://github.com/msu-video-group/memfof.git |
| 22 | +cd memfof |
| 23 | +pip3 install -r requirements.txt |
| 24 | +``` |
| 25 | + |
| 26 | +## 🚀 Demo |
| 27 | + |
| 28 | +Given a video sequence, our code supports generating prediction results of optical flow. |
| 29 | + |
| 30 | +> 🏞️ Prefer MEMFOF-Tartan-T-TSKH model for real-world videos — it is trained with higher diversity and robustness in mind. |
| 31 | +
|
| 32 | +Refer to [demo.ipynb](https://colab.research.google.com/github/msu-video-group/memfof/blob/dev/demo.ipynb) for examle usage or run the following command to host a [demo page](https://huggingface.co/spaces/egorchistov/MEMFOF). |
| 33 | + |
| 34 | +```shell |
| 35 | +python3 demo.py |
| 36 | +``` |
| 37 | + |
| 38 | +## 📦 Models |
| 39 | + |
| 40 | +- [`MEMFOF-Tartan`](https://huggingface.co/egorchistov/MEMFOF-Tartan) |
| 41 | +- [`MEMFOF-Tartan-T`](https://huggingface.co/egorchistov/MEMFOF-Tartan-T) |
| 42 | +- [`MEMFOF-Tartan-T-TSKH`](https://huggingface.co/egorchistov/MEMFOF-Tartan-T-TSKH) (✅ Recommended for real-world videos) |
| 43 | +- [`MEMFOF-Tartan-T-TSKH-kitti`](https://huggingface.co/egorchistov/MEMFOF-Tartan-T-TSKH-kitti) |
| 44 | +- [`MEMFOF-Tartan-T-TSKH-sintel`](https://huggingface.co/egorchistov/MEMFOF-Tartan-T-TSKH-sintel) |
| 45 | +- [`MEMFOF-Tartan-T-TSKH-spring`](https://huggingface.co/egorchistov/MEMFOF-Tartan-T-TSKH-spring) |
| 46 | + |
| 47 | +## 🗂️ Datasets |
| 48 | + |
| 49 | +To train MEMFOF, you will need to download the required datasets: [FlyingThings3D](https://lmb.informatik.uni-freiburg.de/resources/datasets/SceneFlowDatasets.en.html), [Sintel](http://sintel.is.tue.mpg.de/), [KITTI](http://www.cvlibs.net/datasets/kitti/eval_scene_flow.php?benchmark=flow), [HD1K](http://hci-benchmark.iwr.uni-heidelberg.de/), [TartanAir](https://theairlab.org/tartanair-dataset/), and [Spring](https://spring-benchmark.org/). |
| 50 | + |
| 51 | +By default `datasets.py` will search for the datasets in these locations. You can create symbolic links to wherever the datasets were downloaded in the `datasets` folder. |
| 52 | + |
| 53 | +```shell |
| 54 | +├── datasets |
| 55 | + ├── Sintel |
| 56 | + ├── KITTI |
| 57 | + ├── FlyingThings3D |
| 58 | + ├── HD1K |
| 59 | + ├── Spring |
| 60 | + ├── test |
| 61 | + ├── train |
| 62 | + ├── TartanAir |
| 63 | +``` |
| 64 | + |
| 65 | +## 📊 Evaluation and Submission |
| 66 | + |
| 67 | +Please refer to [eval.sh](eval.sh) and [submission.sh](submission.sh) for more details. |
| 68 | + |
| 69 | +## 🏋️ Training |
| 70 | + |
| 71 | +Our training setup is configured for **4 nodes with 8 GPUs each**, using a fixed effective batch size. |
| 72 | +If you run the script on fewer resources, the per-device batch size may become too large and lead to **out-of-memory (OOM)** errors. |
| 73 | + |
| 74 | +In such cases, you’ll need to manually lower the `effective_batch_size` in the config — **note that this will affect the final results**, as training dynamics and convergence may change. |
| 75 | + |
| 76 | +Our training script is optimized for use with the slurm workload manager. A typical submission script looks like this: |
| 77 | + |
| 78 | +```shell |
| 79 | +# (submit.sh) |
| 80 | +#!/bin/bash |
| 81 | + |
| 82 | +#SBATCH --nodes=4 |
| 83 | +#SBATCH --gres=gpu:8 |
| 84 | +#SBATCH --ntasks-per-node=8 |
| 85 | +#SBATCH --cpus-per-task=16 |
| 86 | + |
| 87 | +srun bash train.sh |
| 88 | +``` |
| 89 | + |
| 90 | +Alternatively, multi-node training is also supported via other launch methods, such as torchrun: |
| 91 | + |
| 92 | +```shell |
| 93 | +OMP_NUM_THREADS=16 torchrun \ |
| 94 | +--nproc_per_node=8 \ |
| 95 | +--nnodes=4 \ |
| 96 | +--node_rank <NODE_RANK> \ |
| 97 | +--master_addr <MASTER_ADDR> \ |
| 98 | +--master_port <MASTER_PORT> \ |
| 99 | +--no-python bash train.sh |
| 100 | +``` |
| 101 | + |
| 102 | +For more details, refer to the [PyTorch Lightning documentation](https://lightning.ai/docs/pytorch/2.5.1/clouds/cluster.html). |
| 103 | + |
| 104 | +We use Weights & Biases (WandB) for experiment tracking by default. To disable logging, set the environment variable: |
| 105 | + |
| 106 | +```shell |
| 107 | +export WANDB_MODE=disabled |
| 108 | +``` |
| 109 | + |
| 110 | +## ❓ Need Help? |
| 111 | + |
| 112 | +Feel free to open an issue if you have any questions. |
| 113 | + |
| 114 | +## 📚 Citation |
| 115 | + |
| 116 | +``` |
| 117 | +@article{bargatin2025memfof, |
| 118 | + title={MEMFOF: High-Resolution Training for Memory-Efficient Multi-Frame Optical Flow Estimation}, |
| 119 | + author={Bargatin, Vladislav and Chistov, Egor and Yakovenko, Alexander and Vatolin, Dmitriy}, |
| 120 | + journal={arXiv preprint arXiv:2506.23151}, |
| 121 | + year={2025} |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +## 🙏 Acknowledgements |
| 126 | + |
| 127 | +This project relies on code from existing repositories: [SEA-RAFT](https://github.com/princeton-vl/SEA-RAFT), [VideoFlow](https://github.com/XiaoyuShi97/VideoFlow), and [GMA](https://github.com/zacjiang/GMA). We thank the original authors for their excellent work. |
0 commit comments