mirror of
https://github.com/k4yt3x/video2x.git
synced 2025-01-01 10:29:09 +00:00
deduplicate code
This commit is contained in:
parent
eda5d70773
commit
5a2b387b9d
@ -70,48 +70,26 @@ class Waifu2xNcnnVulkan:
|
|||||||
'gpu': '-g'
|
'gpu': '-g'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
# waifu2x_ncnn_vulkan does not accept an arbitrary scale ratio, max is 2
|
||||||
if scale_ratio == 1:
|
if scale_ratio == 1:
|
||||||
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])
|
|
||||||
execute.append('1')
|
execute.append('1')
|
||||||
# allow upper if cases to take precedence
|
|
||||||
elif value is None or value is False:
|
|
||||||
continue
|
|
||||||
else:
|
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)
|
|
||||||
else:
|
|
||||||
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])
|
|
||||||
execute.append('2')
|
execute.append('2')
|
||||||
|
# allow upper if cases to take precedence
|
||||||
elif value is None or value is False:
|
elif value is None or value is False:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user