Skip to content

Commit

Permalink
fix ncnn scdetect
Browse files Browse the repository at this point in the history
  • Loading branch information
TNTwise committed Oct 12, 2024
1 parent 5dc5a67 commit a07dd6a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 10 additions & 1 deletion backend/src/InterpolateNCNN.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from rife_ncnn_vulkan_python import Rife
from rife_ncnn_vulkan_python import Rife, wrapped
from time import sleep


Expand Down Expand Up @@ -41,5 +41,14 @@ def process(self, img0, img1, timestep) -> bytes:
frame = self.render.process_bytes(img0, img1, timestep)
return frame

def normFrame(self,frame:bytes):
return frame
frame = bytearray(frame)
frame = wrapped.Image(
frame, self.width, self.height, 3
)
return frame

def uncacheFrame(self):
return
self.render.uncache_frame()
12 changes: 10 additions & 2 deletions backend/src/RenderVideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def __init__(
self.sharedMemoryID = sharedMemoryID
self.trt_optimization_level = trt_optimization_level
self.rife_trt_mode = rife_trt_mode
self.uncacheNextFrame = False
# get video properties early
self.getVideoProperties(inputFile)

Expand Down Expand Up @@ -202,6 +203,13 @@ def renderInterpolate(self, frame, transition=False):
img1=self.setupFrame1,
timestep=timestep,
)
elif self.ncnn:
self.interpolate(
img0=self.setupFrame0,
img1=self.setupFrame1,
timestep=.5,
)

self.writeQueue.put(frame)

self.onEndOfInterpolateCall()
Expand All @@ -220,7 +228,7 @@ def render(self):
self.renderInterpolate(frame, self.scDetectFunc(frame))
else:
self.renderInterpolate(frame, False)

self.writeQueue.put(frame)
else:
sleep(1)
Expand Down Expand Up @@ -307,7 +315,7 @@ def setupInterpolate(self):
width=self.width,
height=self.height,
)
self.frameSetupFunction = self.returnFrame
self.frameSetupFunction = interpolateRifeNCNN.normFrame
self.undoSetup = interpolateRifeNCNN.uncacheFrame
self.interpolate = interpolateRifeNCNN.process
self.hotReload = interpolateRifeNCNN.hotReload
Expand Down

0 comments on commit a07dd6a

Please sign in to comment.