From 82715ade1865b234f6deedffc8c948ce8091a95a Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Tue, 5 May 2020 02:49:10 -0400 Subject: [PATCH] addressed srmd-ncnn-vulkan and waifu2x-ncnn-vulkan model path issues --- src/wrappers/srmd_ncnn_vulkan.py | 14 +++++++------- src/wrappers/waifu2x_ncnn_vulkan.py | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/wrappers/srmd_ncnn_vulkan.py b/src/wrappers/srmd_ncnn_vulkan.py index 882128c..cd369a0 100644 --- a/src/wrappers/srmd_ncnn_vulkan.py +++ b/src/wrappers/srmd_ncnn_vulkan.py @@ -13,6 +13,8 @@ for srmd_ncnn_vulkan. # built-in imports import argparse import os +import pathlib +import platform import shlex import subprocess import threading @@ -32,13 +34,6 @@ class WrapperMain: def __init__(self, driver_settings): self.driver_settings = driver_settings - - # arguments passed through command line overwrites config file values - - # srmd_ncnn_vulkan can't find its own model directory if its not in the current dir - # so change to it - os.chdir(os.path.join(self.driver_settings['path'], '..')) - self.print_lock = threading.Lock() @staticmethod @@ -71,6 +66,11 @@ class WrapperMain: self.driver_settings['o'] = output_directory self.driver_settings['s'] = scale_ratio + # by default, srmd-ncnn-vulkan will look for the models under the current working directory + # change the working directory to its containing folder if model directory not specified + if self.driver_settings['m'] is None and platform.system() == 'Windows': + os.chdir(pathlib.Path(self.driver_settings['path']).parent) + # list to be executed # initialize the list with the binary path as the first element execute = [self.driver_settings.pop('path')] diff --git a/src/wrappers/waifu2x_ncnn_vulkan.py b/src/wrappers/waifu2x_ncnn_vulkan.py index 8b62a65..31556c3 100644 --- a/src/wrappers/waifu2x_ncnn_vulkan.py +++ b/src/wrappers/waifu2x_ncnn_vulkan.py @@ -4,7 +4,7 @@ Name: Waifu2x NCNN Vulkan Driver Creator: SAT3LL Date Created: June 26, 2019 -Last Modified: May 4, 2020 +Last Modified: May 5, 2020 Editor: K4YT3X Last Modified: February 22, 2020 @@ -16,6 +16,8 @@ for waifu2x_ncnn_vulkan. # built-in imports import argparse import os +import pathlib +import platform import shlex import subprocess import threading @@ -35,13 +37,6 @@ class WrapperMain: def __init__(self, driver_settings): self.driver_settings = driver_settings - - # arguments passed through command line overwrites config file values - - # waifu2x_ncnn_vulkan can't find its own model directory if its not in the current dir - # so change to it - os.chdir(os.path.join(self.driver_settings['path'], '..')) - self.print_lock = threading.Lock() @staticmethod @@ -74,6 +69,11 @@ class WrapperMain: self.driver_settings['o'] = output_directory self.driver_settings['s'] = int(scale_ratio) + # by default, waifu2x-ncnn-vulkan will look for the models under the current working directory + # change the working directory to its containing folder if model directory not specified + if self.driver_settings['m'] is None and platform.system() == 'Windows': + os.chdir(pathlib.Path(self.driver_settings['path']).parent) + # list to be executed # initialize the list with waifu2x binary path as the first element execute = [self.driver_settings.pop('path')]