From e3b2624977042a2e4c21c1ed0581aebc9841840e Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Sat, 3 Aug 2019 19:45:22 -0400 Subject: [PATCH] fixed the issue where subprocess tries to execute pathlib.Path --- bin/waifu2x_caffe.py | 6 +++--- bin/waifu2x_converter.py | 7 ++++--- bin/waifu2x_ncnn_vulkan.py | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/bin/waifu2x_caffe.py b/bin/waifu2x_caffe.py index cbec6f2..8d613c8 100644 --- a/bin/waifu2x_caffe.py +++ b/bin/waifu2x_caffe.py @@ -4,7 +4,7 @@ Name: Waifu2x Caffe Driver Author: K4YT3X Date Created: Feb 24, 2018 -Last Modified: July 27, 2019 +Last Modified: August 3, 2019 Description: This class is a high-level wrapper for waifu2x-caffe. @@ -67,9 +67,9 @@ class Waifu2xCaffe: self.print_lock.release() # list to be executed - execute = [] + # initialize the list with waifu2x binary path as the first element + execute = [str(self.waifu2x_settings['waifu2x_caffe_path'])] - execute.append(self.waifu2x_settings['waifu2x_caffe_path']) for key in self.waifu2x_settings.keys(): value = self.waifu2x_settings[key] diff --git a/bin/waifu2x_converter.py b/bin/waifu2x_converter.py index 156b24e..3590570 100644 --- a/bin/waifu2x_converter.py +++ b/bin/waifu2x_converter.py @@ -4,7 +4,7 @@ Name: Waifu2x Converter CPP Driver Author: K4YT3X Date Created: February 8, 2019 -Last Modified: July 27, 2019 +Last Modified: August 3, 2019 Description: This class is a high-level wrapper for waifu2x-converter-cpp. @@ -72,7 +72,8 @@ class Waifu2xConverter: self.print_lock.release() # list to be executed - execute = [] + # initialize the list with waifu2x binary path as the first element + execute = [str(pathlib.Path(self.waifu2x_settings['waifu2x_converter_path']) / 'waifu2x-converter-cpp.exe')] for key in self.waifu2x_settings.keys(): @@ -80,7 +81,7 @@ class Waifu2xConverter: # the key doesn't need to be passed in this case if key == 'waifu2x_converter_path': - execute.append(pathlib.Path(str(value)) / 'waifu2x-converter-cpp.exe') + continue # null or None means that leave this option out (keep default) elif value is None or value is False: diff --git a/bin/waifu2x_ncnn_vulkan.py b/bin/waifu2x_ncnn_vulkan.py index 5b139a2..1620ca6 100644 --- a/bin/waifu2x_ncnn_vulkan.py +++ b/bin/waifu2x_ncnn_vulkan.py @@ -4,7 +4,7 @@ Name: Waifu2x NCNN Vulkan Driver Author: SAT3LL Date Created: June 26, 2019 -Last Modified: July 27, 2019 +Last Modified: August 3, 2019 Dev: K4YT3X @@ -74,17 +74,25 @@ class Waifu2xNcnnVulkan: 'verbose': '-v' } - execute = [self.waifu2x_settings['waifu2x_ncnn_vulkan_path']] + # list to be executed + # initialize the list with waifu2x binary path as the first element + execute = [str(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 @@ -92,9 +100,11 @@ class Waifu2xNcnnVulkan: execute.append('1') else: 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))