Skip to content

Commit

Permalink
fix time apparently and start move to ncnn python for rife
Browse files Browse the repository at this point in the history
  • Loading branch information
TNTwise committed May 15, 2024
1 parent 494d127 commit f5e8b93
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion modules/Rife.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def modelOptions(self):
except:
pass
self.ui.RifeStart.clicked.connect(
lambda: interpolate.start_interpolation(self, "rife-ncnn-vulkan")
lambda: interpolate.start_interpolation(self, "rife-ncnn-python")
)
models2 = self.get_models_from_dir("rife")
models = []
Expand Down
1 change: 1 addition & 0 deletions requirements-CUDA-Linux.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
https://github.com/TNTwise/realcugan-ncnn-py/releases/download/2024-04-22-rve/realcugan_ncnn_py-2.0.0-cp310-none-manylinux1_x86_64.whl
https://github.com/TNTwise/Universal-NCNN-upscaler-python/releases/download/2024-05-11-rve/upscale_ncnn_py-1.2.0-cp310-none-manylinux1_x86_64.whl
https://download.pytorch.org/whl/cu121/torch-2.2.0%2Bcu121-cp310-cp310-linux_x86_64.whl
https://github.com/TNTwise/rife-ncnn-vulkan-python-test/releases/download/fastebs/rife_ncnn_vulkan_python-1.2.1-cp310-cp310-linux_x86_64.whl
spandrel
torchvision==0.17
cupy-cuda12x
Expand Down
3 changes: 2 additions & 1 deletion requirements-MAC.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
https://github.com/TNTwise/Universal-NCNN-upscaler-python/releases/download/2024-05-11-rve/upscale_ncnn_py-1.2.0-cp311-none-macosx_11_0_universal2.whl
https://github.com/TNTwise/realcugan-ncnn-py/releases/download/2024-04-22-rve/realcugan_ncnn_py-2.0.0-cp311-none-macosx_11_0_universal2.whl
https://github.com/TNTwise/realcugan-ncnn-py/releases/download/2024-04-22-rve/realcugan_ncnn_py-2.0.0-cp311-none-macosx_11_0_universal2.whl
https://github.com/TNTwise/rife-ncnn-vulkan-python-test/releases/download/fastebs/rife_ncnn_vulkan_python-1.2.1-cp38-cp38-linux_x86_64.whl
3 changes: 2 additions & 1 deletion requirements-NCNN-Linux.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
https://github.com/TNTwise/realcugan-ncnn-py/releases/download/2024-04-22-rve/realcugan_ncnn_py-2.0.0-cp38-none-manylinux1_x86_64.whl
https://github.com/TNTwise/Universal-NCNN-upscaler-python/releases/download/2024-05-11-rve/upscale_ncnn_py-1.2.0-cp38-none-manylinux1_x86_64.whl
https://github.com/TNTwise/Universal-NCNN-upscaler-python/releases/download/2024-05-11-rve/upscale_ncnn_py-1.2.0-cp38-none-manylinux1_x86_64.whl
https://github.com/TNTwise/rife-ncnn-vulkan-python-test/releases/download/fastebs/rife_ncnn_vulkan_python-1.2.1-cp38-cp38-linux_x86_64.whl
25 changes: 22 additions & 3 deletions src/runAI/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ def run(self):
stdout_lines = result.stdout.splitlines()
resolutions_list = []
self.dict_res_id_fps = {}
fps_list = []
for line in stdout_lines:
if "FPS" in line:
fps_index = line.find("FPS")
Expand Down Expand Up @@ -540,7 +539,7 @@ def finishRenderSetup(self): # 3rd and final call, called from interpolate.py
self.main.ui.FPSTo.value() / self.main.ui.FPSFrom.value()
)
setupTransitions(self)
self.main.start_time = time.time()

self.Render(
self.model, self.main.times, self.main.input_file, self.main.output_folder
)
Expand Down Expand Up @@ -658,6 +657,24 @@ def Render(self, model, times, videopath, outputpath):
)
log("After output")
if "cuda" in self.main.AI or "ncnn-python" in self.main.AI:
if self.main.AI == "rife-ncnn-python":
output_file = returnOutputFile(
self.main, self.main.videoName, self.main.encoder
)
self.main.renderAI = RenderCUDA.Interpolation(
self.main,
"rife-ncnn-python",
self.main.input_file,
output_file,
self.main.ui.Rife_Model.currentText(),
self.main.times,
self.main.ui.EnsembleCheckBox.isChecked(),
bool(self.main.ui.halfPrecisionCheckBox.isChecked()),
benchmark=self.main.benchmark,
threads=int(settings.VRAM),
ncnn_gpu=self.main.ui.gpuIDSpinBox.value(),
)

if self.main.AI == "rife-cuda":
output_file = returnOutputFile(
self.main, self.main.videoName, self.main.encoder
Expand Down Expand Up @@ -705,6 +722,7 @@ def Render(self, model, times, videopath, outputpath):
bool(self.main.ui.halfPrecisionCheckBox.isChecked()),
benchmark=self.main.benchmark,
)
self.main.start_time = time.time()
self.main.renderAI.extractFramesToBytes()
readThread1 = Thread(target=self.main.renderAI.readThread)
procThread1 = Thread(target=self.main.renderAI.procInterpThread)
Expand All @@ -714,6 +732,7 @@ def Render(self, model, times, videopath, outputpath):
renderThread1.start()
self.main.renderAI.log()
self.main.output_file = output_file


log("Done")
self.main.currentRenderFPS = 0
Expand Down Expand Up @@ -955,7 +974,7 @@ def realESRGAN(self):
threads=int(settings.VRAM),
benchmark=self.main.benchmark,
)

self.main.start_time = time.time()
self.main.renderAI.extractFramesToBytes()
readThread1 = Thread(target=self.main.renderAI.readThread)
procThread1 = Thread(target=self.main.renderAI.procUpscaleThread)
Expand Down
18 changes: 17 additions & 1 deletion src/torch/RenderCUDA.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
except Exception as e:
log("Cant import UpscaleTRT!" + str(e))

from src.torch.rife.NCNN import RifeNCNN



Expand Down Expand Up @@ -144,6 +144,7 @@ def log(self):
for line in iter(self.writeProcess.stderr.readline, b""):
if not self.main.CudaRenderFinished:
log(line)

# print(line)
else:
break
Expand Down Expand Up @@ -264,6 +265,8 @@ def __init__(
ensemble,
half,
benchmark,
ncnn_gpu=0,
threads=2,
):
super(Interpolation, self).__init__(
main,
Expand All @@ -277,9 +280,21 @@ def __init__(
self.model = model
self.ensemble = ensemble
self.half = half
self.ncnn_gpu = ncnn_gpu
self.threads = threads
self.handleMethod()

def handleMethod(self):
if "rife-ncnn-python" == self.method:
self.interpolate_process = RifeNCNN(
interpolation_factor=self.interpolation_factor,
interpolate_method=self.model,
width=self.originalWidth,
height=self.originalHeight,
ensemble=self.ensemble,
half=self.half,
ncnn_gpu=self.ncnn_gpu
)
if "rife-cuda" == self.method:
self.interpolate_process = Rife(
interpolation_factor=self.interpolation_factor,
Expand All @@ -306,6 +321,7 @@ def handleMethod(self):
half=self.half,
)
self.main.start_time = time.time()
print('starting render')

def proc_image(self, frame0, frame1):
self.interpolate_process.run1(frame0, frame1)
Expand Down

0 comments on commit f5e8b93

Please sign in to comment.