1
mirror of https://github.com/nihui/rife-ncnn-vulkan synced 2024-11-25 08:07:20 +01:00
Go to file
2020-12-05 22:57:55 +08:00
.github Create FUNDING.yml 2020-12-05 22:57:55 +08:00
models HD model 2020-12-03 23:26:38 +08:00
src model path and output filename pattern 2020-12-05 20:29:10 +08:00
.gitmodules wip 2020-11-24 23:28:23 +08:00
LICENSE work in progress 2020-11-24 09:09:01 +08:00
README.md It is suitable for normal use now 2020-12-05 20:50:01 +08:00

RIFE ncnn Vulkan

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/actions

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 Command

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

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_%06d.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/%06d.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
  -m model-path        rife model path (default=rife-HD)
  -g gpu-id            gpu device to use (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
  -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
  • 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

TODO

  • test-time sptial augmentation aka TTA-s
  • test-time temporal augmentation aka TTA-t

Original RIFE Project

Other Open-Source Code Used