From 59344c6c8cb043e21c4b56ee999b558658f18a53 Mon Sep 17 00:00:00 2001 From: tntwise Date: Wed, 15 May 2024 03:10:50 +0000 Subject: [PATCH] add ncnn file lol --- src/torch/rife/NCNN.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/torch/rife/NCNN.py diff --git a/src/torch/rife/NCNN.py b/src/torch/rife/NCNN.py new file mode 100644 index 00000000..2b80e4eb --- /dev/null +++ b/src/torch/rife/NCNN.py @@ -0,0 +1,39 @@ +from rife_ncnn_vulkan_python import Rife +from src.programData.thisdir import thisdir as ts +import os +import numpy as np +thisdir = ts() +class RifeNCNN: + def __init__(self, + interpolation_factor, + interpolate_method, + width, + height, + ensemble, + half, + threads=2, + ncnn_gpu=0,): + + self.interpolation_factor = interpolation_factor + self.interpolation_method = interpolate_method + self.width = width + self.height = height + self.ensemble = ensemble + self.half = half + self.handleModel() + self.createInterpolation(ncnn_gpu=ncnn_gpu,threads=threads) + def handleModel(self): + self.modelPath = os.path.join(thisdir,"models","rife",self.interpolation_method) + def createInterpolation(self, + ncnn_gpu=0, + threads=2): + self.render = Rife(gpuid=ncnn_gpu, + num_threads=threads, + model=self.modelPath, + uhd_mode=False) + def run1(self,i0,i1): + self.i0 = i0 + self.i1 = i1 + def make_inference(self,n): + return np.ascontiguousarray(self.render.process_cv2(self.i0,self.i1,timestep=n)) + \ No newline at end of file