hzwer / arXiv2020-RIFE
- среда, 18 ноября 2020 г. в 00:32:26
Python
RIFE: Real-Time Intermediate Flow Estimation for Video Frame Interpolation
2020.11.17 News: Try our 4 road parallel to process video, got 100% speedup!
Date of recent model update: 2020.11.16, v1.1
You can easily use colaboratory to have a try and generate the above youtube demo.
Our model can run 30+FPS for 2X 720p interpolation on a 2080Ti GPU. Currently our method supports 2X/4X interpolation for video, and multi-frame interpolation between a pair of images. Everyone is welcome to use this alpha version and make suggestions!
16X interpolation results from two input images:
We propose RIFE, a Real-time Intermediate Flow Estimation algorithm for Video Frame Interpolation (VFI). Most existing methods first estimate the bi-directional optical flows and then linearly combine them to approximate intermediate flows, leading to artifacts on motion boundaries. RIFE uses a neural network named IFNet that can directly estimate the intermediate flows from images. With the more precise flows and our simplified fusion process, RIFE can improve interpolation quality and have much better speed. Based on our proposed leakage distillation loss, RIFE can be trained in an end-to-end fashion. Experiments demonstrate that our method is significantly faster than existing VFI methods and can achieve state-of-the-art performance on public benchmarks.
$ pip3 install tqdm
$ pip3 install torch
$ pip3 install numpy
$ pip3 install opencv-python
(我们也提供了百度网盘链接:https://pan.baidu.com/s/1YVUsusJFhZ2rWg1Zs5sOkQ 密码:88bu,把压缩包解开后放在 train_log/*.pkl)
The models under different setting is coming soon.
Video 2x Interpolation
You can use our demo video or use your own video to run our model.
$ python3 inference_mp4_2x.py --video video.mp4 --fps=60
(generate video_2x.mp4, you can use this script recursively)
$ python3 inference_mp4_4x.py --video video.mp4 --fps=60
(if you want 4x interpolation)
$ python3 inference_mp4_4x_parallel.py --video video.mp4 --fps=60
(Try our parallel process to get 100% speedup!)
$ python3 inference_mp4_2x.py --video video.mp4 --montage --png
(if you want to montage the origin video, and save the png format output)
The warning info, 'Warning: Your video has *** static frames, it may change the duration of the generated video.' means that your video has changed the frame rate by adding static frames, it is common if you have processed 24FPS video to 30FPS.
**Image Interpolation**
$ python3 inference_img.py --img img0.png img1.png --times=4
(2^4=16X interpolation results)
After that, you can use pngs to generate mp4:
$ 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
You can also use pngs to generate gif:
$ 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
## Evaluation
First you should download [RIFE model reported by our paper](https://drive.google.com/file/d/1c1R7iF-ypN6USo-D2YH_ORtaH3tukSlo/view?usp=sharing).
We will release our training and benchmark validation code soon.
**Vimeo90K**
Download [Vimeo90K dataset](http://toflow.csail.mit.edu/) at ./vimeo_interp_test
$ python3 Vimeo90K_benchmark.py (You will get 35.695PSNR and 0.9788SSIM)
## Citation
<img src="demo/intro.png" alt="img" width=350 />
@article{huang2020rife, title={RIFE: Real-Time Intermediate Flow Estimation for Video Frame Interpolation}, author={Huang, Zhewei and Zhang, Tianyuan and Heng, Wen and Shi, Boxin and Zhou, Shuchang}, journal={arXiv preprint arXiv:2011.06294}, year={2020} }
## Reference
Optical Flow:
[ARFlow](https://github.com/lliuz/ARFlow) [pytorch-liteflownet](https://github.com/sniklaus/pytorch-liteflownet) [RAFT](https://github.com/princeton-vl/RAFT)
Video Interpolation:
[DAIN](https://github.com/baowenbo/DAIN) [CAIN](https://github.com/myungsub/CAIN) [AdaCoF-pytorch](https://github.com/HyeongminLEE/AdaCoF-pytorch)