2022-07-04 11:53:37 +08:00
# Real-Time Intermediate Flow Estimation for Video Frame Interpolation
2022-07-13 12:01:44 +08:00
## Introduction
This project is the implement of [Real-Time Intermediate Flow Estimation for Video Frame Interpolation ](https://arxiv.org/abs/2011.06294 ). Currently, our model can run 30+FPS for 2X 720p interpolation on a 2080Ti GPU. It supports arbitrary-timestep interpolation between a pair of images.
2023-10-23 15:39:19 +08:00
**2023.10 - We recently release new [v4.7-4.8 ](https://github.com/hzwer/Practical-RIFE/tree/main#model-list ) optimized for anime scenes!** 🎉
2023-09-25 16:37:41 +08:00
2022.7.4 - Our paper is accepted by ECCV2022. Thanks to all relevant authors, contributors and users!
2022-07-04 11:53:37 +08:00
2023-03-24 18:46:37 +08:00
From 2020 to 2022, we submitted RIFE for five submissions( rejected by CVPR21 ICCV21 AAAI22 CVPR22). Thanks to all anonymous reviewers, your suggestions have helped to significantly improve the paper!
2022-07-04 11:53:37 +08:00
2023-05-24 16:02:07 +08:00
[ECCV Poster ](https://drive.google.com/file/d/1xCXuLUCSwhN61kvIF8jxDvQiUGtLK0kN/view?usp=sharing ) | [ECCV 5-min presentation ](https://youtu.be/qdp-NYqWQpA ) | [论文中文介绍 ](https://zhuanlan.zhihu.com/p/568553080 ) | [rebuttal (2WA1WR->3WA) ](https://drive.google.com/file/d/16IVjwRpwbTuJbYyTn4PizKX8I257QxY-/view?usp=sharing )
2022-10-02 22:12:33 +08:00
2022-07-26 18:45:44 +08:00
## [YouTube](https://www.youtube.com/results?search_query=rife+interpolation&sp=CAM%253D) | [BiliBili](https://search.bilibili.com/all?keyword=SVFI&order=stow&duration=0&tids_1=0) | [Colab](https://colab.research.google.com/github/hzwer/ECCV2022-RIFE/blob/main/Colab_demo.ipynb) | [Tutorial](https://www.youtube.com/watch?v=gf_on-dbwyU&feature=emb_title)
2021-12-16 12:37:23 +08:00
**Pinned Software: [RIFE-App ](https://grisk.itch.io/rife-app ) | [FlowFrames ](https://nmkd.itch.io/flowframes ) | [SVFI (中文) ](https://github.com/YiWeiHuang-stack/Squirrel-Video-Frame-Interpolation )**
2020-11-14 14:05:02 +08:00
2021-12-08 18:02:21 +08:00
16X interpolation results from two input images:


2021-06-17 11:39:31 +08:00
## Software
2022-11-27 19:28:20 +01:00
[Flowframes ](https://nmkd.itch.io/flowframes ) | [SVFI(中文) ](https://github.com/YiWeiHuang-stack/Squirrel-Video-Frame-Interpolation ) | [Waifu2x-Extension-GUI ](https://github.com/AaronFeng753/Waifu2x-Extension-GUI ) | [Autodesk Flame ](https://vimeo.com/505942142 ) | [SVP ](https://www.svp-team.com/wiki/RIFE_AI_interpolation ) | [MPV_lazy ](https://github.com/hooke007/MPV_lazy ) | [enhancr ](https://github.com/mafiosnik777/enhancr )
2021-03-10 15:11:31 +08:00
2021-12-09 14:01:21 +08:00
[RIFE-App(Paid) ](https://grisk.itch.io/rife-app ) | [Steam-VFI(Paid) ](https://store.steampowered.com/app/1692080/SVFI/ )
We are not responsible for and participating in the development of above software. According to the open source license, we respect the commercial behavior of other developers.
2021-12-09 14:24:44 +08:00
2022-08-19 11:34:22 +08:00
[VapourSynth-RIFE ](https://github.com/HolyWu/vs-rife ) | [RIFE-ncnn-vulkan ](https://github.com/nihui/rife-ncnn-vulkan ) | [VapourSynth-RIFE-ncnn-Vulkan ](https://github.com/HomeOfVapourSynthEvolution/VapourSynth-RIFE-ncnn-Vulkan )
2021-12-16 12:28:41 +08:00
2023-07-20 20:47:19 +08:00
<img src="https://api.star-history.com/svg?repos=megvii-research/ECCV2022-RIFE,Justin62628/Squirrel-RIFE,n00mkrad/flowframes,nihui/rife-ncnn-vulkan,hzwer/Practical-RIFE&type=Date" height="320" width="480" />
2022-08-18 18:55:08 +08:00
2021-12-16 12:33:14 +08:00
If you are a developer, welcome to follow [Practical-RIFE ](https://github.com/hzwer/Practical-RIFE ), which aims to make RIFE more practical for users by adding various features and design new models with faster speed.
2023-01-19 12:21:34 +08:00
You may check [this pull request ](https://github.com/megvii-research/ECCV2022-RIFE/pull/300 ) for supporting macOS.
2021-06-17 11:39:31 +08:00
## CLI Usage
2020-11-26 09:49:42 +08:00
### Installation
2020-11-12 20:27:43 +08:00
```
2022-07-26 18:45:44 +08:00
git clone git@github .com:megvii-research/ECCV2022-RIFE.git
cd ECCV2022-RIFE
2020-12-02 19:05:01 +08:00
pip3 install -r requirements.txt
2020-11-12 20:27:43 +08:00
```
2020-11-15 16:40:43 -08:00
2021-06-17 18:02:06 +08:00
* Download the pretrained **HD ** models from [here ](https://drive.google.com/file/d/1APIzVeI-4ZZCEuIRE1m6WYfSCaOsi_7_/view?usp=sharing ). (百度网盘链接:https://pan.baidu.com/share/init?surl=u6Q7-i4Hu4Vx9_5BJibPPA 密码:hfk3, 把压缩包解开后放在 train_log/\*)
2020-11-13 01:44:56 +08:00
2021-05-15 17:42:04 +08:00
* Unzip and move the pretrained parameters to train_log/\*
2020-11-12 23:39:28 +08:00
2022-07-26 18:45:44 +08:00
* This model is not reported by our paper, for our paper model please refer to [evaluation ](https://github.com/hzwer/ECCV2022-RIFE#evaluation ).
2021-05-15 22:32:20 +08:00
2020-11-26 09:49:42 +08:00
### Run
2020-11-26 11:34:11 +08:00
**Video Frame Interpolation**
2020-11-15 16:40:43 -08:00
2020-12-02 18:57:12 +08:00
You can use our [demo video ](https://drive.google.com/file/d/1i3xlKb7ax7Y70khcTcuePi6E7crO_dFc/view?usp=sharing ) or your own video.
2020-11-16 05:27:06 +08:00
```
2020-12-02 18:55:14 +08:00
python3 inference_video.py --exp=1 --video=video.mp4
2020-11-16 05:27:06 +08:00
```
2020-11-23 15:05:29 +08:00
(generate video_2X_xxfps.mp4)
2020-11-16 05:27:06 +08:00
```
2020-12-02 18:55:14 +08:00
python3 inference_video.py --exp=2 --video=video.mp4
2020-11-16 05:27:06 +08:00
```
2020-11-23 15:05:29 +08:00
(for 4X interpolation)
2020-11-16 05:27:06 +08:00
```
2021-02-27 17:00:53 +08:00
python3 inference_video.py --exp=1 --video=video.mp4 --scale=0.5
2020-12-13 23:55:04 +08:00
```
2021-02-27 17:48:21 +08:00
(If your video has very high resolution such as 4K, we recommend set --scale=0.5 (default 1.0). If you generate disordered pattern on your videos, try set --scale=2.0. This parameter control the process resolution for optical flow model.)
2020-12-13 23:55:04 +08:00
```
2020-12-03 18:04:13 +08:00
python3 inference_video.py --exp=2 --img=input/
```
(to read video from pngs, like input/0.png ... input/612.png, ensure that the png names are numbers)
```
2020-12-02 18:55:14 +08:00
python3 inference_video.py --exp=2 --video=video.mp4 --fps=60
2020-11-16 05:27:06 +08:00
```
2020-11-26 11:34:11 +08:00
(add slomo effect, the audio will be removed)
2020-11-18 11:29:08 +08:00
```
2020-12-02 18:55:14 +08:00
python3 inference_video.py --video=video.mp4 --montage --png
2020-11-17 19:19:21 +08:00
```
2021-11-10 12:15:51 +08:00
(if you want to montage the origin video and save the png format output)
2020-11-16 05:29:36 +08:00
2022-08-17 11:22:12 +08:00
**Optical Flow Estimation**
You may refer to [#278 ](https://github.com/megvii-research/ECCV2022-RIFE/issues/278#event-7199085190 ).
2020-11-13 23:28:32 +08:00
**Image Interpolation**
2020-11-12 23:39:28 +08:00
```
2020-12-02 18:55:14 +08:00
python3 inference_img.py --img img0.png img1.png --exp=4
2020-11-16 21:37:23 +08:00
```
2020-11-14 02:54:24 +08:00
(2^4=16X interpolation results)
2020-11-16 21:37:23 +08:00
After that, you can use pngs to generate mp4:
```
2020-12-02 18:55:14 +08:00
ffmpeg -r 10 -f image2 -i output/img%d.png -s 448x256 -c:v libx264 -pix_fmt yuv420p output/slomo.mp4 -q:v 0 -q:a 0
2020-11-16 21:37:23 +08:00
```
You can also use pngs to generate gif:
```
2020-12-02 18:55:14 +08:00
ffmpeg -r 10 -f image2 -i output/img%d.png -s 448x256 -vf "split[s0][s1];[s0]palettegen=stats_mode=single[p];[s1][p]paletteuse=new=1" output/slomo.gif
2020-11-13 23:28:32 +08:00
```
2021-01-17 15:24:57 +01:00
### Run in docker
2021-01-17 16:07:54 +01:00
Place the pre-trained models in `train_log/\*.pkl` (as above)
2021-01-17 15:24:57 +01:00
Building the container:
```
docker build -t rife -f docker/Dockerfile .
```
Running the container:
```
2021-01-17 16:05:48 +01:00
docker run --rm -it -v $PWD:/host rife:latest inference_video --exp=1 --video=untitled.mp4 --output=untitled_rife.mp4
```
```
docker run --rm -it -v $PWD:/host rife:latest inference_img --img img0.png img1.png --exp=4
2021-01-17 15:24:57 +01:00
```
2021-01-17 16:11:24 +01:00
Using gpu acceleration (requires proper gpu drivers for docker):
```
docker run --rm -it --gpus all -v /dev/dri:/dev/dri -v $PWD:/host rife:latest inference_video --exp=1 --video=untitled.mp4 --output=untitled_rife.mp4
```
2020-11-16 05:27:06 +08:00
## Evaluation
2021-11-15 23:41:04 +08:00
Download [RIFE model ](https://drive.google.com/file/d/1h42aGYPNJn2q8j_GVkS_yDu__G_UZ2GX/view?usp=sharing ) or [RIFE_m model ](https://drive.google.com/file/d/147XVsDXBfJPlyct2jfo9kpbL944mNeZr/view?usp=sharing ) reported by our paper.
2021-03-04 12:33:56 +08:00
**UCF101**: Download [UCF101 dataset ](https://liuziwei7.github.io/projects/VoxelFlow ) at ./UCF101/ucf101_interp_ours/
2020-11-14 14:56:13 +08:00
2020-11-26 19:11:17 +08:00
**Vimeo90K**: Download [Vimeo90K dataset ](http://toflow.csail.mit.edu/ ) at ./vimeo_interp_test
2020-11-26 19:12:36 +08:00
2020-11-26 19:11:17 +08:00
**MiddleBury**: Download [MiddleBury OTHER dataset ](https://vision.middlebury.edu/flow/data/ ) at ./other-data and ./other-gt-interp
2021-03-04 12:33:56 +08:00
2021-04-13 16:36:35 +08:00
**HD**: Download [HD dataset ](https://github.com/baowenbo/MEMC-Net ) at ./HD_dataset. We also provide a [google drive download link ](https://drive.google.com/file/d/1iHaLoR2g1-FLgr9MEv51NH_KQYMYz-FA/view?usp=sharing ).
2020-11-14 17:02:45 +08:00
```
2021-05-07 11:27:46 +08:00
# RIFE
2021-03-04 12:33:56 +08:00
python3 benchmark/UCF101.py
2021-08-13 16:34:41 +08:00
# "PSNR: 35.282 SSIM: 0.9688"
2020-12-02 18:55:14 +08:00
python3 benchmark/Vimeo90K.py
2021-08-13 16:34:41 +08:00
# "PSNR: 35.615 SSIM: 0.9779"
2021-03-09 17:52:10 +08:00
python3 benchmark/MiddleBury_Other.py
2021-08-13 16:49:25 +08:00
# "IE: 1.956"
2021-03-04 12:33:56 +08:00
python3 benchmark/HD.py
2021-08-13 16:34:41 +08:00
# "PSNR: 32.14"
2021-11-15 23:41:04 +08:00
# RIFE_m
python3 benchmark/HD_multi_4X.py
2021-11-15 23:44:09 +08:00
# "PSNR: 22.96(544*1280), 31.87(720p), 34.25(1080p)"
2020-11-14 17:02:45 +08:00
```
2020-12-02 19:12:48 +08:00
## Training and Reproduction
2021-08-13 16:36:05 +08:00
Download [Vimeo90K dataset ](http://toflow.csail.mit.edu/ ).
2020-12-02 18:40:39 +08:00
We use 16 CPUs, 4 GPUs and 20G memory for training:
```
2020-12-14 11:50:43 +08:00
python3 -m torch.distributed.launch --nproc_per_node=4 train.py --world_size=4
2020-12-02 18:40:39 +08:00
```
2022-04-15 15:45:22 +08:00
## Revision History
2022-04-15 15:45:55 +08:00
2022-04-15 15:45:22 +08:00
2021.3.18 [arXiv ](https://arxiv.org/pdf/2011.06294v5.pdf ): Modify the main experimental data, especially the runtime related issues.
2022-04-15 15:45:55 +08:00
2022-07-04 11:53:37 +08:00
2021.8.12 [arXiv ](https://arxiv.org/pdf/2011.06294v6.pdf ): Remove pre-trained model dependency and propose privileged distillation scheme for frame interpolation. Remove [census loss ](https://github.com/hzwer/arXiv2021-RIFE/blob/0e241367847a0895748e64c6e1604c94db54d395/model/loss.py#L20 ) supervision.
2022-04-15 15:45:55 +08:00
2022-04-15 15:45:22 +08:00
2021.11.17 [arXiv ](https://arxiv.org/pdf/2011.06294v11.pdf ): Support arbitrary-time frame interpolation, aka RIFEm and add more experiments.
2022-07-04 11:53:37 +08:00
## Recommend
We sincerely recommend some related papers:
CVPR22 - [Optimizing Video Prediction via Video Frame Interpolation ](https://openaccess.thecvf.com/content/CVPR2022/html/Wu_Optimizing_Video_Prediction_via_Video_Frame_Interpolation_CVPR_2022_paper.html )
CVPR22 - [Video Frame Interpolation with Transformer ](https://openaccess.thecvf.com/content/CVPR2022/html/Lu_Video_Frame_Interpolation_With_Transformer_CVPR_2022_paper.html )
CVPR22 - [IFRNet: Intermediate Feature Refine Network for Efficient Frame Interpolation ](https://openaccess.thecvf.com/content/CVPR2022/html/Kong_IFRNet_Intermediate_Feature_Refine_Network_for_Efficient_Frame_Interpolation_CVPR_2022_paper.html )
2023-03-29 11:12:08 +08:00
CVPR23 - [A Dynamic Multi-Scale Voxel Flow Network for Video Prediction ](https://huxiaotaostasy.github.io/DMVFN/ )
CVPR23 - [Extracting Motion and Appearance via Inter-Frame Attention for Efficient Video Frame Interpolation ](https://arxiv.org/abs/2303.00440 )
2020-11-13 11:16:57 +08:00
## Citation
2023-03-29 11:13:25 +08:00
If you think this project is helpful, please feel free to leave a star or cite our paper:
2020-11-13 23:28:32 +08:00
2020-11-13 10:27:30 +08:00
```
2022-07-11 16:01:17 +08:00
@inproceedings {huang2022rife,
title={Real-Time Intermediate Flow Estimation for Video Frame Interpolation},
2020-11-13 10:27:30 +08:00
author={Huang, Zhewei and Zhang, Tianyuan and Heng, Wen and Shi, Boxin and Zhou, Shuchang},
2022-07-11 16:01:17 +08:00
booktitle={Proceedings of the European Conference on Computer Vision (ECCV)},
year={2022}
2020-11-13 10:27:30 +08:00
}
```
## Reference
2020-12-02 19:00:32 +08:00
2020-11-13 11:16:57 +08:00
Optical Flow:
2020-11-26 11:34:11 +08:00
[ARFlow ](https://github.com/lliuz/ARFlow ) [pytorch-liteflownet ](https://github.com/sniklaus/pytorch-liteflownet ) [RAFT ](https://github.com/princeton-vl/RAFT ) [pytorch-PWCNet ](https://github.com/sniklaus/pytorch-pwc )
2020-11-13 11:16:57 +08:00
2020-12-02 19:02:47 +08:00
Video Interpolation:
2021-03-09 10:59:38 +08:00
[DVF ](https://github.com/lxx1991/pytorch-voxel-flow ) [TOflow ](https://github.com/Coldog2333/pytoflow ) [SepConv ](https://github.com/sniklaus/sepconv-slomo ) [DAIN ](https://github.com/baowenbo/DAIN ) [CAIN ](https://github.com/myungsub/CAIN ) [MEMC-Net ](https://github.com/baowenbo/MEMC-Net ) [SoftSplat ](https://github.com/sniklaus/softmax-splatting ) [BMBC ](https://github.com/JunHeum/BMBC ) [EDSC ](https://github.com/Xianhang/EDSC-pytorch ) [EQVI ](https://github.com/lyh-18/EQVI )