moving wrappers into a sub-directory

This commit is contained in:
k4yt3x 2020-05-03 19:18:39 -04:00
parent b1e844dcad
commit 43a2078330
5 changed files with 15 additions and 20 deletions

0
src/ffmpeg.py → src/wrappers/ffmpeg.py Executable file → Normal file
View File

15
src/waifu2x_caffe.py → src/wrappers/waifu2x_caffe.py Executable file → Normal file
View File

@ -4,7 +4,7 @@
Name: Waifu2x Caffe Driver
Author: K4YT3X
Date Created: Feb 24, 2018
Last Modified: February 22, 2020
Last Modified: May 3, 2020
Description: This class is a high-level wrapper
for waifu2x-caffe.
@ -29,14 +29,12 @@ class Waifu2xCaffe:
the upscale function.
"""
def __init__(self, driver_settings, process, model_dir, bit_depth):
def __init__(self, driver_settings, model_dir, bit_depth):
self.driver_settings = driver_settings
self.driver_settings['process'] = process
self.driver_settings['model_dir'] = model_dir
self.driver_settings['output_depth'] = bit_depth
# arguments passed through command line overwrites config file values
self.process = process
self.model_dir = model_dir
self.print_lock = threading.Lock()
@ -64,21 +62,24 @@ class Waifu2xCaffe:
# list to be executed
# initialize the list with waifu2x binary path as the first element
execute = [str(self.driver_settings['path'])]
execute = [self.driver_settings.pop('path')]
for key in self.driver_settings.keys():
value = self.driver_settings[key]
# is executable key or null or None means that leave this option out (keep default)
if key == 'path' or value is None or value is False:
if value is None or value is False:
continue
else:
if len(key) == 1:
execute.append(f'-{key}')
else:
execute.append(f'--{key}')
execute.append(str(value))
# true means key is an option
if value is not True:
execute.append(str(value))
# return the Popen object of the new process created
self.print_lock.acquire()

View File

@ -4,7 +4,7 @@
Name: Waifu2x Converter CPP Driver
Author: K4YT3X
Date Created: February 8, 2019
Last Modified: February 22, 2020
Last Modified: May 3, 2020
Description: This class is a high-level wrapper
for waifu2x-converter-cpp.
@ -21,7 +21,7 @@ import threading
from avalon_framework import Avalon
class Waifu2xConverter:
class Waifu2xConverterCpp:
"""This class communicates with waifu2x cui engine
An object will be created for this class, containing information
@ -56,22 +56,18 @@ class Waifu2xConverter:
# models_rgb must be specified manually for waifu2x-converter-cpp
# if it's not specified in the arguments, create automatically
if self.driver_settings['model-dir'] is None:
self.driver_settings['model-dir'] = pathlib.Path(self.driver_settings['path']) / 'models_rgb'
self.driver_settings['model-dir'] = pathlib.Path(self.driver_settings['path']).parent / 'models_rgb'
# list to be executed
# initialize the list with waifu2x binary path as the first element
execute = [str(pathlib.Path(self.driver_settings['path']) / 'waifu2x-converter-cpp.exe')]
execute = [self.driver_settings.pop('path')]
for key in self.driver_settings.keys():
value = self.driver_settings[key]
# the key doesn't need to be passed in this case
if key == 'path':
continue
# null or None means that leave this option out (keep default)
elif value is None or value is False:
if value is None or value is False:
continue
else:
if len(key) == 1:
@ -80,10 +76,8 @@ class Waifu2xConverter:
execute.append(f'--{key}')
# true means key is an option
if value is True:
continue
execute.append(str(value))
if value is not True:
execute.append(str(value))
# return the Popen object of the new process created
self.print_lock.acquire()

View File