mirror of
https://github.com/k4yt3x/video2x.git
synced 2025-01-01 10:29:09 +00:00
renamed waifu2x_settings to driver_settings
This commit is contained in:
parent
e812c228c3
commit
732288f075
10
src/anime4k.py
Normal file → Executable file
10
src/anime4k.py
Normal file → Executable file
@ -4,7 +4,7 @@
|
|||||||
Name: Anime4K Driver
|
Name: Anime4K Driver
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: August 15, 2019
|
Date Created: August 15, 2019
|
||||||
Last Modified: August 15, 2019
|
Last Modified: October 6, 2019
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for Anime4k.
|
for Anime4k.
|
||||||
@ -27,8 +27,8 @@ class Anime4k:
|
|||||||
the upscale function.
|
the upscale function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, waifu2x_settings):
|
def __init__(self, driver_settings):
|
||||||
self.waifu2x_settings = waifu2x_settings
|
self.driver_settings = driver_settings
|
||||||
self.print_lock = threading.Lock()
|
self.print_lock = threading.Lock()
|
||||||
|
|
||||||
def upscale(self, input_directory, output_directory, scale_ratio, upscaler_exceptions, push_strength=None, push_grad_strength=None):
|
def upscale(self, input_directory, output_directory, scale_ratio, upscaler_exceptions, push_strength=None, push_grad_strength=None):
|
||||||
@ -57,9 +57,9 @@ class Anime4k:
|
|||||||
for image in extracted_frame_files:
|
for image in extracted_frame_files:
|
||||||
|
|
||||||
execute = [
|
execute = [
|
||||||
self.waifu2x_settings['java_path'],
|
self.driver_settings['java_path'],
|
||||||
'-jar',
|
'-jar',
|
||||||
self.waifu2x_settings['anime4k_path'],
|
self.driver_settings['anime4k_path'],
|
||||||
str(image.absolute()),
|
str(image.absolute()),
|
||||||
str(output_directory / image.name),
|
str(output_directory / image.name),
|
||||||
str(scale_ratio)
|
str(scale_ratio)
|
||||||
|
14
src/upscaler.py
Normal file → Executable file
14
src/upscaler.py
Normal file → Executable file
@ -4,7 +4,7 @@
|
|||||||
Name: Video2X Upscaler
|
Name: Video2X Upscaler
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: December 10, 2018
|
Date Created: December 10, 2018
|
||||||
Last Modified: August 21, 2019
|
Last Modified: October 6, 2019
|
||||||
|
|
||||||
Dev: SAT3LL
|
Dev: SAT3LL
|
||||||
|
|
||||||
@ -51,12 +51,12 @@ class Upscaler:
|
|||||||
ArgumentError -- if argument is not valid
|
ArgumentError -- if argument is not valid
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, input_video, output_video, method, waifu2x_settings, ffmpeg_settings):
|
def __init__(self, input_video, output_video, method, driver_settings, ffmpeg_settings):
|
||||||
# mandatory arguments
|
# mandatory arguments
|
||||||
self.input_video = input_video
|
self.input_video = input_video
|
||||||
self.output_video = output_video
|
self.output_video = output_video
|
||||||
self.method = method
|
self.method = method
|
||||||
self.waifu2x_settings = waifu2x_settings
|
self.driver_settings = driver_settings
|
||||||
self.ffmpeg_settings = ffmpeg_settings
|
self.ffmpeg_settings = ffmpeg_settings
|
||||||
|
|
||||||
# optional arguments
|
# optional arguments
|
||||||
@ -165,7 +165,7 @@ class Upscaler:
|
|||||||
# it's easier to do multi-threading with waifu2x_converter
|
# it's easier to do multi-threading with waifu2x_converter
|
||||||
# the number of threads can be passed directly to waifu2x_converter
|
# the number of threads can be passed directly to waifu2x_converter
|
||||||
if self.waifu2x_driver == 'waifu2x_converter':
|
if self.waifu2x_driver == 'waifu2x_converter':
|
||||||
w2 = Waifu2xConverter(self.waifu2x_settings, self.model_dir)
|
w2 = Waifu2xConverter(self.driver_settings, self.model_dir)
|
||||||
|
|
||||||
progress_bar = threading.Thread(target=self._progress_bar, args=([self.extracted_frames],))
|
progress_bar = threading.Thread(target=self._progress_bar, args=([self.extracted_frames],))
|
||||||
progress_bar.start()
|
progress_bar.start()
|
||||||
@ -222,7 +222,7 @@ class Upscaler:
|
|||||||
|
|
||||||
# create a separate w2 instance for each thread
|
# create a separate w2 instance for each thread
|
||||||
if self.waifu2x_driver == 'waifu2x_caffe':
|
if self.waifu2x_driver == 'waifu2x_caffe':
|
||||||
w2 = Waifu2xCaffe(copy.deepcopy(self.waifu2x_settings), self.method, self.model_dir, self.bit_depth)
|
w2 = Waifu2xCaffe(copy.deepcopy(self.driver_settings), self.method, self.model_dir, self.bit_depth)
|
||||||
if self.scale_ratio:
|
if self.scale_ratio:
|
||||||
thread = threading.Thread(target=w2.upscale,
|
thread = threading.Thread(target=w2.upscale,
|
||||||
args=(thread_info[0],
|
args=(thread_info[0],
|
||||||
@ -244,7 +244,7 @@ class Upscaler:
|
|||||||
|
|
||||||
# if the driver being used is waifu2x_ncnn_vulkan
|
# if the driver being used is waifu2x_ncnn_vulkan
|
||||||
elif self.waifu2x_driver == 'waifu2x_ncnn_vulkan':
|
elif self.waifu2x_driver == 'waifu2x_ncnn_vulkan':
|
||||||
w2 = Waifu2xNcnnVulkan(copy.deepcopy(self.waifu2x_settings))
|
w2 = Waifu2xNcnnVulkan(copy.deepcopy(self.driver_settings))
|
||||||
thread = threading.Thread(target=w2.upscale,
|
thread = threading.Thread(target=w2.upscale,
|
||||||
args=(thread_info[0],
|
args=(thread_info[0],
|
||||||
self.upscaled_frames,
|
self.upscaled_frames,
|
||||||
@ -253,7 +253,7 @@ class Upscaler:
|
|||||||
|
|
||||||
# if the driver being used is anime4k
|
# if the driver being used is anime4k
|
||||||
elif self.waifu2x_driver == 'anime4k':
|
elif self.waifu2x_driver == 'anime4k':
|
||||||
w2 = Anime4k(copy.deepcopy(self.waifu2x_settings))
|
w2 = Anime4k(copy.deepcopy(self.driver_settings))
|
||||||
thread = threading.Thread(target=w2.upscale,
|
thread = threading.Thread(target=w2.upscale,
|
||||||
args=(thread_info[0],
|
args=(thread_info[0],
|
||||||
self.upscaled_frames,
|
self.upscaled_frames,
|
||||||
|
32
src/waifu2x_caffe.py
Normal file → Executable file
32
src/waifu2x_caffe.py
Normal file → Executable 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: August 3, 2019
|
Last Modified: October 6, 2019
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for waifu2x-caffe.
|
for waifu2x-caffe.
|
||||||
@ -27,11 +27,11 @@ class Waifu2xCaffe:
|
|||||||
the upscale function.
|
the upscale function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, waifu2x_settings, process, model_dir, bit_depth):
|
def __init__(self, driver_settings, process, model_dir, bit_depth):
|
||||||
self.waifu2x_settings = waifu2x_settings
|
self.driver_settings = driver_settings
|
||||||
self.waifu2x_settings['process'] = process
|
self.driver_settings['process'] = process
|
||||||
self.waifu2x_settings['model_dir'] = model_dir
|
self.driver_settings['model_dir'] = model_dir
|
||||||
self.waifu2x_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.process = process
|
||||||
@ -50,16 +50,16 @@ class Waifu2xCaffe:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# overwrite config file settings
|
# overwrite config file settings
|
||||||
self.waifu2x_settings['input_path'] = input_directory
|
self.driver_settings['input_path'] = input_directory
|
||||||
self.waifu2x_settings['output_path'] = output_directory
|
self.driver_settings['output_path'] = output_directory
|
||||||
|
|
||||||
if scale_ratio:
|
if scale_ratio:
|
||||||
self.waifu2x_settings['scale_ratio'] = scale_ratio
|
self.driver_settings['scale_ratio'] = scale_ratio
|
||||||
elif scale_width and scale_height:
|
elif scale_width and scale_height:
|
||||||
self.waifu2x_settings['scale_width'] = scale_width
|
self.driver_settings['scale_width'] = scale_width
|
||||||
self.waifu2x_settings['scale_height'] = scale_height
|
self.driver_settings['scale_height'] = scale_height
|
||||||
|
|
||||||
self.waifu2x_settings['output_extention'] = image_format
|
self.driver_settings['output_extention'] = image_format
|
||||||
|
|
||||||
# print thread start message
|
# print thread start message
|
||||||
self.print_lock.acquire()
|
self.print_lock.acquire()
|
||||||
@ -68,14 +68,14 @@ 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.waifu2x_settings['waifu2x_caffe_path'])]
|
execute = [str(self.driver_settings['path'])]
|
||||||
|
|
||||||
for key in self.waifu2x_settings.keys():
|
for key in self.driver_settings.keys():
|
||||||
|
|
||||||
value = self.waifu2x_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 == 'waifu2x_caffe_path' or value is None or value is False:
|
if key == 'path' or value is None or value is False:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if len(key) == 1:
|
if len(key) == 1:
|
||||||
|
30
src/waifu2x_converter.py
Normal file → Executable file
30
src/waifu2x_converter.py
Normal file → Executable 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: August 3, 2019
|
Last Modified: October 6, 2019
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for waifu2x-converter-cpp.
|
for waifu2x-converter-cpp.
|
||||||
@ -28,9 +28,9 @@ class Waifu2xConverter:
|
|||||||
the upscale function.
|
the upscale function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, waifu2x_settings, model_dir):
|
def __init__(self, driver_settings, model_dir):
|
||||||
self.waifu2x_settings = waifu2x_settings
|
self.driver_settings = driver_settings
|
||||||
self.waifu2x_settings['model_dir'] = model_dir
|
self.driver_settings['model_dir'] = model_dir
|
||||||
self.print_lock = threading.Lock()
|
self.print_lock = threading.Lock()
|
||||||
|
|
||||||
def upscale(self, input_directory, output_directory, scale_ratio, jobs, image_format, upscaler_exceptions):
|
def upscale(self, input_directory, output_directory, scale_ratio, jobs, image_format, upscaler_exceptions):
|
||||||
@ -46,16 +46,16 @@ class Waifu2xConverter:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# overwrite config file settings
|
# overwrite config file settings
|
||||||
self.waifu2x_settings['input'] = input_directory
|
self.driver_settings['input'] = input_directory
|
||||||
self.waifu2x_settings['output'] = output_directory
|
self.driver_settings['output'] = output_directory
|
||||||
self.waifu2x_settings['scale-ratio'] = scale_ratio
|
self.driver_settings['scale-ratio'] = scale_ratio
|
||||||
self.waifu2x_settings['jobs'] = jobs
|
self.driver_settings['jobs'] = jobs
|
||||||
self.waifu2x_settings['output-format'] = image_format
|
self.driver_settings['output-format'] = image_format
|
||||||
|
|
||||||
# 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.waifu2x_settings['model-dir'] is None:
|
if self.driver_settings['model-dir'] is None:
|
||||||
self.waifu2x_settings['model-dir'] = pathlib.Path(self.waifu2x_settings['waifu2x_converter_path']) / 'models_rgb'
|
self.driver_settings['model-dir'] = pathlib.Path(self.driver_settings['waifu2x_converter_path']) / 'models_rgb'
|
||||||
|
|
||||||
# print thread start message
|
# print thread start message
|
||||||
self.print_lock.acquire()
|
self.print_lock.acquire()
|
||||||
@ -64,14 +64,14 @@ class Waifu2xConverter:
|
|||||||
|
|
||||||
# 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.waifu2x_settings['waifu2x_converter_path']) / 'waifu2x-converter-cpp.exe')]
|
execute = [str(pathlib.Path(self.driver_settings['path']) / 'waifu2x-converter-cpp.exe')]
|
||||||
|
|
||||||
for key in self.waifu2x_settings.keys():
|
for key in self.driver_settings.keys():
|
||||||
|
|
||||||
value = self.waifu2x_settings[key]
|
value = self.driver_settings[key]
|
||||||
|
|
||||||
# the key doesn't need to be passed in this case
|
# the key doesn't need to be passed in this case
|
||||||
if key == 'waifu2x_converter_path':
|
if key == 'path':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# null or None means that leave this option out (keep default)
|
# null or None means that leave this option out (keep default)
|
||||||
|
22
src/waifu2x_ncnn_vulkan.py
Normal file → Executable file
22
src/waifu2x_ncnn_vulkan.py
Normal file → Executable file
@ -4,7 +4,7 @@
|
|||||||
Name: Waifu2x NCNN Vulkan Driver
|
Name: Waifu2x NCNN Vulkan Driver
|
||||||
Author: SAT3LL
|
Author: SAT3LL
|
||||||
Date Created: June 26, 2019
|
Date Created: June 26, 2019
|
||||||
Last Modified: August 3, 2019
|
Last Modified: October 6, 2019
|
||||||
|
|
||||||
Dev: K4YT3X
|
Dev: K4YT3X
|
||||||
|
|
||||||
@ -30,14 +30,14 @@ class Waifu2xNcnnVulkan:
|
|||||||
the upscale function.
|
the upscale function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, waifu2x_settings):
|
def __init__(self, driver_settings):
|
||||||
self.waifu2x_settings = waifu2x_settings
|
self.driver_settings = driver_settings
|
||||||
|
|
||||||
# arguments passed through command line overwrites config file values
|
# 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
|
# waifu2x_ncnn_vulkan can't find its own model directory if its not in the current dir
|
||||||
# so change to it
|
# so change to it
|
||||||
os.chdir(os.path.join(self.waifu2x_settings['waifu2x_ncnn_vulkan_path'], '..'))
|
os.chdir(os.path.join(self.driver_settings['waifu2x_ncnn_vulkan_path'], '..'))
|
||||||
|
|
||||||
self.print_lock = threading.Lock()
|
self.print_lock = threading.Lock()
|
||||||
|
|
||||||
@ -52,9 +52,9 @@ class Waifu2xNcnnVulkan:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# overwrite config file settings
|
# overwrite config file settings
|
||||||
self.waifu2x_settings['i'] = input_directory
|
self.driver_settings['i'] = input_directory
|
||||||
self.waifu2x_settings['o'] = output_directory
|
self.driver_settings['o'] = output_directory
|
||||||
self.waifu2x_settings['s'] = scale_ratio
|
self.driver_settings['s'] = scale_ratio
|
||||||
|
|
||||||
# print thread start message
|
# print thread start message
|
||||||
self.print_lock.acquire()
|
self.print_lock.acquire()
|
||||||
@ -63,14 +63,14 @@ class Waifu2xNcnnVulkan:
|
|||||||
|
|
||||||
# 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.waifu2x_settings['waifu2x_ncnn_vulkan_path'])]
|
execute = [str(self.driver_settings['path'])]
|
||||||
|
|
||||||
for key in self.waifu2x_settings.keys():
|
for key in self.driver_settings.keys():
|
||||||
|
|
||||||
value = self.waifu2x_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 == 'waifu2x_ncnn_vulkan_path' or value is None or value is False:
|
if key == 'path' or value is None or value is False:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if len(key) == 1:
|
if len(key) == 1:
|
||||||
|
Loading…
Reference in New Issue
Block a user