• Stars
    star
    775
  • Rank 58,632 (Top 2 %)
  • Language
    C
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

waifu2x-ncnn-vulkan

waifu2x converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan
C
2,963
star
2

opencv-mobile

The minimal opencv for Android, iOS, ARM Linux, Windows, Linux, MacOS, WebAssembly
C++
2,325
star
3

realsr-ncnn-vulkan

RealSR super resolution implemented with ncnn library
C
1,077
star
4

realcugan-ncnn-vulkan

real-cugan converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan
C
751
star
5

ncnn-android-yolov5

The YOLOv5 object detection android example
C++
621
star
6

dain-ncnn-vulkan

DAIN, Depth-Aware Video Frame Interpolation implemented with ncnn library
C
506
star
7

ncnn-android-nanodet

C++
355
star
8

srmd-ncnn-vulkan

SRMD super resolution implemented with ncnn library
C
324
star
9

ruapu

Detect CPU features with single-file
C
268
star
10

ncnn-android-scrfd

C++
208
star
11

ncnn-assets

Python
186
star
12

ncnn-small-board

ncnn benchmark on various single board computers
157
star
13

ncnn-android-squeezenet

The squeezenet image classification android example
C++
141
star
14

ncnn-webassembly-yolov5

Deploy YOLOv5 in your web browser with ncnn and webassembly
C++
138
star
15

cain-ncnn-vulkan

CAIN, Channel Attention Is All You Need for Video Frame Interpolation implemented with ncnn library
C
130
star
16

ncnn-webassembly-nanodet

Deploy nanodet, the super fast and lightweight object detection, in your web browser with ncnn and webassembly
C++
118
star
17

vkpeak

A tool which profiles Vulkan devices to find their peak capacities
C++
96
star
18

ifrnet-ncnn-vulkan

IFRNet: Intermediate Feature Refine Network for Efficient Frame Interpolation implemented with ncnn library
C
92
star
19

ncnn-android-mobilenetssd

The mobilenetssd object detection android example
Java
89
star
20

ncnn-android-styletransfer

The style transfer android example
C
84
star
21

ncnn-android-benchmark

ncnn android benchmark app
C++
83
star
22

ncnn_on_esp32

C
65
star
23

stable-diffusion-ncnn-vulkan

60
star
24

nihui

57
star
25

valgrind-android

55
star
26

ncnn-webassembly-scrfd

Deploy SCRFD, an efficient high accuracy face detection approach, in your web browser with ncnn and webassembly
C++
52
star
27

ncnn-webassembly-portrait-segmentation

Portrait segmentation in your web browser with ncnn and webassembly
C++
33
star
28

riscv-v-toolchain

prebuild package for cross compiling riscv
18
star
29

ncnn-android-vkpeak

C++
17
star
30

styletransfer-ncnn-vulkan

C
17
star
31

ncnn_on_xr806

C++
14
star
32

ncnn-vulkan-compute-sample

CMake
13
star
33

fxxk-tensorflow-lite-note

add custom op in both tensorflow and tensorflow-lite
Jupyter Notebook
7
star
34

zzzz

C++
6
star
35

milkv-duo-test

C
5
star
36

kuaide

A fast desktop environment based on KDE technology
C++
5
star
37

InferXLite

C++
4
star
38

eva-qq-protocol

qq protocol document for eva
3
star
39

action-protobuf

CMake
3
star
40

libnofetion

next generation of ofetion library
C
3
star
41

oxygenspread

C
3
star
42

xf86-video-siska

xf86 Driver for SIS Chipset
C
3
star
43

playground

C++
2
star
44

ksaolaji

C++
2
star
45

VulkanOnMetal

Vulkan On Metal
C
2
star
46

kio-kuaipan

C++
2
star
47

kfuseiso

C++
1
star
48

eva-qt4

C++
1
star
49

action-xmwk

1
star
50

kopete-qq

C++
1
star
51

kiconedit

C++
1
star
52

kde-thumbnailer

C++
1
star
53

kcm-fontadjust

C++
1
star
54

choqok-sina

C++
1
star
55

qsopcast

C++
1
star
56

choqok-tencent

C++
1
star
57

nihui-patch

nihui's patch collection
1
star
58

dozen

1
star
59

estelle

C++
1
star
60

kamule

C++
1
star
61

kdoubanfm

C++
1
star
62

kopete-fetion

C++
1
star
63

vendor-rockchip-common

common
C
1
star
64

plasma-webqq

C++
1
star
65

choqok-netease

C++
1
star