mirror of
https://github.com/k4yt3x/video2x.git
synced 2024-12-29 16:09:10 +00:00
update waifu2x_ncnn_vulkan wrapper for directory as input
add workaround for the double file extension
This commit is contained in:
parent
9429b04528
commit
40a4d3a602
@ -150,6 +150,14 @@ class Ffmpeg:
|
||||
# read FFmpeg input options
|
||||
execute.extend(self._read_configuration(phase='frames_to_video', section='input_options'))
|
||||
|
||||
# WORKAROUND FOR WAIFU2X-NCNN-VULKAN
|
||||
import re
|
||||
import shutil
|
||||
regex = re.compile(r'\.png\.png$')
|
||||
for raw_frame in os.listdir(upscaled_frames):
|
||||
shutil.move(os.path.join(upscaled_frames, raw_frame), os.path.join(upscaled_frames, regex.sub('.png', raw_frame)))
|
||||
# END WORKAROUND
|
||||
|
||||
# append input frames path into command
|
||||
execute.extend([
|
||||
'-i',
|
||||
|
@ -47,7 +47,9 @@
|
||||
"scale-ratio": null,
|
||||
"tile-size": 400,
|
||||
"model-path": null,
|
||||
"gpu": 0
|
||||
"gpu": 0,
|
||||
"load-proc-save_threads": null,
|
||||
"verbose": null
|
||||
},
|
||||
"ffmpeg": {
|
||||
"ffmpeg_path": "C:\\Users\\K4YT3X\\AppData\\Local\\video2x\\ffmpeg-latest-win64-static\\bin",
|
||||
|
@ -67,37 +67,38 @@ class Waifu2xNcnnVulkan:
|
||||
'scale-ratio': '-s',
|
||||
'tile-size': '-t',
|
||||
'model-path': '-m',
|
||||
'gpu': '-g'
|
||||
'gpu': '-g',
|
||||
'load-proc-save_threads': '-j',
|
||||
'verbose': '-v'
|
||||
}
|
||||
|
||||
for raw_frame in os.listdir(input_directory):
|
||||
execute = [self.waifu2x_settings['waifu2x_ncnn_vulkan_path']]
|
||||
for key in self.waifu2x_settings.keys():
|
||||
value = self.waifu2x_settings[key]
|
||||
if key == 'waifu2x_ncnn_vulkan_path':
|
||||
continue
|
||||
elif key == 'input':
|
||||
execute.append(waifu2x_ncnn_vulkan_opt_flag[key])
|
||||
execute.append(os.path.join(input_directory, raw_frame))
|
||||
elif key == 'output':
|
||||
execute.append(waifu2x_ncnn_vulkan_opt_flag[key])
|
||||
execute.append(os.path.join(output_directory, raw_frame))
|
||||
elif key == 'scale-ratio':
|
||||
execute.append(waifu2x_ncnn_vulkan_opt_flag[key])
|
||||
# waifu2x_ncnn_vulkan does not accept an arbitrary scale ratio, max is 2
|
||||
if scale_ratio == 1:
|
||||
execute.append('1')
|
||||
else:
|
||||
execute.append('2')
|
||||
# allow upper if cases to take precedence
|
||||
elif value is None or value is False:
|
||||
continue
|
||||
execute = [self.waifu2x_settings['waifu2x_ncnn_vulkan_path']]
|
||||
for key in self.waifu2x_settings.keys():
|
||||
value = self.waifu2x_settings[key]
|
||||
if key == 'waifu2x_ncnn_vulkan_path':
|
||||
continue
|
||||
elif key == 'input':
|
||||
execute.append(waifu2x_ncnn_vulkan_opt_flag[key])
|
||||
execute.append(input_directory)
|
||||
elif key == 'output':
|
||||
execute.append(waifu2x_ncnn_vulkan_opt_flag[key])
|
||||
execute.append(output_directory)
|
||||
elif key == 'scale-ratio':
|
||||
execute.append(waifu2x_ncnn_vulkan_opt_flag[key])
|
||||
# waifu2x_ncnn_vulkan does not accept an arbitrary scale ratio, max is 2
|
||||
if scale_ratio == 1:
|
||||
execute.append('1')
|
||||
else:
|
||||
execute.append(waifu2x_ncnn_vulkan_opt_flag[key])
|
||||
execute.append(str(value))
|
||||
execute.append('2')
|
||||
# allow upper if cases to take precedence
|
||||
elif value is None or value is False:
|
||||
continue
|
||||
else:
|
||||
execute.append(waifu2x_ncnn_vulkan_opt_flag[key])
|
||||
execute.append(str(value))
|
||||
|
||||
Avalon.debug_info(f'Executing: {execute}')
|
||||
subprocess.run(execute, check=True, stderr=subprocess.DEVNULL)
|
||||
Avalon.debug_info(f'Executing: {execute}')
|
||||
subprocess.run(execute, check=True, stderr=subprocess.DEVNULL)
|
||||
|
||||
# print thread exiting message
|
||||
self.print_lock.acquire()
|
||||
|
Loading…
Reference in New Issue
Block a user