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

View File

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

View File