Back to rankings

nihui/rife-ncnn-vulkan

C

RIFE, Real-Time Intermediate Flow Estimation for Video Frame Interpolation implemented with ncnn library

ncnngpuvideo-interpolationvulkanrife
Star Growth
Stars
1.1k
Forks
91
Weekly Growth
Issues
43
5001k
Nov 2020Sep 2022Aug 2024Jul 2026
README

RIFE ncnn Vulkan

CI download

ncnn implementation of RIFE, Real-Time Intermediate Flow Estimation for Video Frame Interpolation.

rife-ncnn-vulkan uses ncnn project as the universal neural network inference framework.

Download

Download Windows/Linux/MacOS Executable for Intel/AMD/Nvidia GPU

https://github.com/nihui/rife-ncnn-vulkan/releases

This package includes all the binaries and models required. It is portable, so no CUDA or PyTorch runtime environment is needed :)

About RIFE

RIFE (Real-Time Intermediate Flow Estimation for Video Frame Interpolation)

https://github.com/hzwer/arXiv2020-RIFE

Huang, Zhewei and Zhang, Tianyuan and Heng, Wen and Shi, Boxin and Zhou, Shuchang

https://rife-vfi.github.io

https://arxiv.org/abs/2011.06294

Usages

Input two frame images, output one interpolated frame image.

Example Commands

./rife-ncnn-vulkan -0 0.jpg -1 1.jpg -o 01.jpg
./rife-ncnn-vulkan -i input_frames/ -o output_frames/

Example below runs on CPU, Discrete GPU, and Integrated GPU all at the same time. Uses 2 threads for image decoding, 4 threads for one CPU worker, 4 threads for another CPU worker, 2 threads for discrete GPU, 1 thread for integrated GPU, and 4 threads for image encoding.

./rife-ncnn-vulkan -i input_frames/ -o output_frames/ -g -1,-1,0,1 -j 2:4,4,2,1:4

Video Interpolation with FFmpeg

mkdir input_frames
mkdir output_frames

# find the source fps and format with ffprobe, for example 24fps, AAC
ffprobe input.mp4

# extract audio
ffmpeg -i input.mp4 -vn -acodec copy audio.m4a

# decode all frames
ffmpeg -i input.mp4 input_frames/frame_%08d.png

# interpolate 2x frame count
./rife-ncnn-vulkan -i input_frames -o output_frames

# encode interpolated frames in 48fps with audio
ffmpeg -framerate 48 -i output_frames/%08d.png -i audio.m4a -c:a copy -crf 20 -c:v libx264 -pix_fmt yuv420p output.mp4

Full Usages

Usage: rife-ncnn-vulkan -0 infile -1 infile1 -o outfile [options]...
       rife-ncnn-vulkan -i indir -o outdir [options]...

  -h                   show this help
  -v                   verbose output
  -0 input0-path       input image0 path (jpg/png/webp)
  -1 input1-path       input image1 path (jpg/png/webp)
  -i input-path        input image directory (jpg/png/webp)
  -o output-path       output image path (jpg/png/webp) or directory
  -n num-frame         target frame count (default=N*2)
  -s time-step         time step (0~1, default=0.5)
  -m model-path        rife model path (default=rife-v2.3)
  -g gpu-id            gpu device to use (-1=cpu, default=auto) can be 0,1,2 for multi-gpu
  -j load:proc:save    thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu
  -x                   enable spatial tta mode
  -z                   enable temporal tta mode
  -u                   enable UHD mode
  -f pattern-format    output image filename pattern format (%08d.jpg/png/webp, default=ext/%08d.png)
  • input0-path, input1-path and output-path accept file path
  • input-path and output-path accept file directory
  • num-frame = target frame count
  • time-step = interpolation time
  • load:proc:save = thread count for the three stages (image decoding + rife interpolation + image encoding), using larger values may increase GPU usage and consume more GPU memory. You can tune this configuration with "4:4:4" for many small-size images, and "2:2:2" for large-size images. The default setting usually works fine for most situations. If you find that your GPU is hungry, try increasing thread count to achieve faster processing.
  • pattern-format = the filename pattern and format of the image to be output, png is better supported, however webp generally yields smaller file sizes, both are losslessly encoded

If you encounter a crash or error, try upgrading your GPU driver:

Build from Source

  1. Download and setup the Vulkan SDK from https://vulkan.lunarg.com/
  • For Linux distributions, you can either get the essential build requirements from package manager
dnf install vulkan-headers vulkan-loader-devel
apt-get install libvulkan-dev
pacman -S vulkan-headers vulkan-icd-loader
  1. Clone this project with all submodules
git clone https://github.com/nihui/rife-ncnn-vulkan.git
cd rife-ncnn-vulkan
git submodule update --init --recursive
  1. Build with CMake
  • You can pass -DUSE_STATIC_MOLTENVK=ON option to avoid linking the vulkan loader library on MacOS
mkdir build
cd build
cmake ../src
cmake --build . -j 4

Model

model upstream version
rife 1.2
rife-HD 1.5
rife-UHD 1.6
rife-anime 1.8
rife-v2 2.0
rife-v2.3 2.3
rife-v2.4 2.4
rife-v3.0 3.0
rife-v3.1 3.1
rife-v4 4.0
rife-v4.6 4.6

Sample Images

Original Image

origin0 origin1

Interpolate with rife rife-anime model

rife-ncnn-vulkan.exe -m models/rife-anime -0 0.png -1 1.png -o out.png

rife

Interpolate with rife rife-anime model + TTA-s

rife-ncnn-vulkan.exe -m models/rife-anime -x -0 0.png -1 1.png -o out.png

rife

Original RIFE Project

Other Open-Source Code Used

Related repositories
Tencent/ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform

C++Otherinferencehigh-preformance
23.6k4.5k
AaronFeng753/Waifu2x-Extension-GUI

Video, Image and GIF upscale/enlarge(Super-Resolution) and Video frame interpolation. Achieved with Waifu2x, Real-ESRGAN, Real-CUGAN, RTX Video Super Resolution VSR, SRMD, RealSR, Anime4K, RIFE, IFRNet, CAIN, DAIN, and ACNet.

C++Otherwaifu2xanime4k
patreon.com/aaronfeng
16.8k1k
DayBreak-u/chineseocr_lite

超轻量级中文ocr,支持竖排文字识别, 支持ncnn、mnn、tnn推理 ( dbnet(1.8M) + crnn(2.5M) + anglenet(378KB)) 总模型仅4.7M

C++GNU General Public License v2.0ncnnocr
12.3k2.3k
Baiyuetribe/paper2gui

Convert AI papers to GUI,Make it easy and convenient for everyone to use artificial intelligence technology。让每个人都简单方便的使用前沿人工智能技术

Jupyter NotebookMIT Licensedainhuoshan-tts
xiaobaituai.com
10.7k878
Megvii-BaseDetection/YOLOX

YOLOX is a high-performance anchor-free YOLO, exceeding yolov3~v5 with MegEngine, ONNX, TensorRT, ncnn, and OpenVINO supported. Documentation: https://yolox.readthedocs.io/

PythonPyPIApache License 2.0yoloxyolov3
10.5k2.5k
Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB

💎1MB lightweight face detection model (1MB轻量级人脸检测模型)

PythonPyPIMIT Licenseface-detectionarm
7.5k1.5k
RangiLyu/nanodet

NanoDet-Plus⚡Super fast and lightweight anchor-free object detection model. 🔥Only 980 KB(int8) / 1.8MB (fp16) and run 97FPS on cellphone🔥

PythonPyPIApache License 2.0deep-neural-networksdeep-learning
6.2k1.1k
Tohrusky/Final2x

2^x Image Super-Resolution

TypeScriptnpmBSD 3-Clause "New" or "Revised" Licensecross-platformelectron
6.2k477
Tencent/TNN

TNN: developed by Tencent Youtu Lab and Guangying Lab, a uniform deep learning inference framework for mobile、desktop and server. TNN is distinguished by several outstanding features, including its cross-platform capability, high performance, model compression and code pruning. Based on ncnn and Rapidnet, TNN further strengthens the support and performance optimization for mobile devices, and also draws on the advantages of good extensibility and high performance from existed open source efforts. TNN has been deployed in multiple Apps from Tencent, such as Mobile QQ, Weishi, Pitu, etc. Contributions are welcome to work in collaborative with us and make TNN a better framework.

C++Otherdeep-learningmnn
4.6k772
xlite-dev/lite.ai.toolkit

🛠A lite C++ AI toolkit: 100+ models with MNN, ORT and TRT, including Det, Seg, Stable-Diffusion, Face-Fusion, etc.🎉

C++GNU General Public License v3.0yoloxonnxruntime
github.com/xlite-dev/lite.ai.toolkit
4.4k782
DefTruth/lite.ai.toolkit

🛠 A lite C++ toolkit of 100+ Awesome AI models, support ORT, MNN, NCNN, TNN and TensorRT. 🎉🎉

C++GNU General Public License v3.0yoloxonnxruntime
4k731
zjhellofss/KuiperInfer

校招、秋招、春招、实习好项目!带你从零实现一个高性能的深度学习推理库,支持大模型 llama2 、Unet、Yolov5、Resnet等模型的推理。Implement a high-performance deep learning inference library step by step

C++MIT Licenseinferenceinference-engine
3.5k369