Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

A Python FFI of nihui/rife-ncnn-vulkan achieved with SWIG

License

Notifications You must be signed in to change notification settings

styler00dollar/rife-ncnn-vulkan-python

 
 

Repository files navigation

RIFE ncnn Vulkan Python

Information about fork: This fork adds Rife4 and removes PIL. It uses numpy arrays instead.

CI

Introduction

rife-ncnn-vulkan is nihui's ncnn implementation of Real-Time Intermediate Flow Estimation for Video Frame Interpolation.

rife-ncnn-vulkan-python wraps rife-ncnn-vulkan project by SWIG to make it easier to integrate rife-ncnn-vulkan with existing python projects.

Downloads

Linux/Windos/Mac X86_64 binary build releases are available now.

For PyPI supports, we are working on it, and hope will publish it on PyPI in the future.

Build

First, you have to install python, python development package (Python native development libs in Visual Studio), vulkan SDK and SWIG on your platform. And then, there are two ways to build it:

  • Use setuptools to build and install into python package directly. (Currently in developing)
  • Use CMake directly (The old way)

Use setuptools

python setup.py install

Use CMake

Linux

git clone https://github.com/ArchieMeng/rife-ncnn-vulkan-python.git
cd rife-ncnn-vulkan-python
git submodule update --init --recursive
cmake -B build src
cd build
make

Windows

I used Visual Studio 2019 and msvc v142 to build this project for Windows.

Install visual studio and open the project directory, and build. Job done.

The only problem on Windows is that, you cannot use CMake for Windows GUI to generate the Visual Studio solution file and build it. This will make the lib crash on loading.

One way is using Visual Studio to open the project as directory, and build it from Visual Studio. And another way is build it from powershell just like what is written in the release.yml

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

Example Program

from rife_ncnn_vulkan_python import Rife
import cv2

image0 = cv2.imread("frame1.jpg")
image1 = cv2.imread("frame3.jpg")
rife = Rife(gpuid=0, model="rife-v4", tta_mode=False, num_threads=4)
output = rife.process(image0, image1)
cv2.imwrite("output.png", output)

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

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

Original RIFE Project

Other Open-Source Code Used

About

A Python FFI of nihui/rife-ncnn-vulkan achieved with SWIG

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CMake 62.7%
  • Python 24.1%
  • C++ 10.2%
  • SWIG 3.0%