mirror of
https://github.com/k4yt3x/video2x.git
synced 2025-01-30 23:58:11 +00:00
change waifu2x-ncnn-vulkan to underscores
agglomerate waifu2x choices to a list
This commit is contained in:
parent
4e3565b3ac
commit
0b99ac33a6
@ -150,7 +150,8 @@ class Upscaler:
|
|||||||
self.upscaler_exceptions = []
|
self.upscaler_exceptions = []
|
||||||
|
|
||||||
# initialize waifu2x driver
|
# initialize waifu2x driver
|
||||||
if self.waifu2x_driver != 'waifu2x_caffe' and self.waifu2x_driver != 'waifu2x_converter' and self.waifu2x_driver != 'waifu2x-ncnn-vulkan':
|
drivers = ['waifu2x_caffe', 'waifu2x_converter', 'waifu2x_ncnn_vulkan']
|
||||||
|
if self.waifu2x_driver not in drivers:
|
||||||
raise Exception(f'Unrecognized waifu2x driver: {self.waifu2x_driver}')
|
raise Exception(f'Unrecognized waifu2x driver: {self.waifu2x_driver}')
|
||||||
|
|
||||||
# it's easier to do multi-threading with waifu2x_converter
|
# it's easier to do multi-threading with waifu2x_converter
|
||||||
@ -247,7 +248,7 @@ class Upscaler:
|
|||||||
|
|
||||||
if len(self.upscaler_exceptions) != 0:
|
if len(self.upscaler_exceptions) != 0:
|
||||||
raise(self.upscaler_exceptions[0])
|
raise(self.upscaler_exceptions[0])
|
||||||
elif self.waifu2x_driver == 'waifu2x-ncnn-vulkan':
|
elif self.waifu2x_driver == 'waifu2x_ncnn_vulkan':
|
||||||
# create a container for all upscaler threads
|
# create a container for all upscaler threads
|
||||||
upscaler_threads = []
|
upscaler_threads = []
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@
|
|||||||
"output": null,
|
"output": null,
|
||||||
"input": null
|
"input": null
|
||||||
},
|
},
|
||||||
"waifu2x-ncnn-vulkan": {
|
"waifu2x_ncnn_vulkan": {
|
||||||
"waifu2x-ncnn-vulkan_path": "C:\\Users\\kobalt\\AppData\\Local\\video2x\\waifu2x-ncnn-vulkan\\waifu2x.exe",
|
"waifu2x_ncnn_vulkan_path": "C:\\Users\\kobalt\\AppData\\Local\\video2x\\waifu2x-ncnn-vulkan\\waifu2x.exe",
|
||||||
"block-size": 400,
|
"block-size": 400,
|
||||||
"scale-ratio": null,
|
"scale-ratio": null,
|
||||||
"noise-level": 2,
|
"noise-level": 2,
|
||||||
|
@ -82,7 +82,7 @@ def process_arguments():
|
|||||||
# upscaler options
|
# upscaler options
|
||||||
upscaler_options = parser.add_argument_group('Upscaler Options')
|
upscaler_options = parser.add_argument_group('Upscaler Options')
|
||||||
upscaler_options.add_argument('-m', '--method', help='upscaling method', action='store', default='gpu', choices=['cpu', 'gpu', 'cudnn'])
|
upscaler_options.add_argument('-m', '--method', help='upscaling method', action='store', default='gpu', choices=['cpu', 'gpu', 'cudnn'])
|
||||||
upscaler_options.add_argument('-d', '--driver', help='waifu2x driver', action='store', default='waifu2x_caffe', choices=['waifu2x_caffe', 'waifu2x_converter', 'waifu2x-ncnn-vulkan'])
|
upscaler_options.add_argument('-d', '--driver', help='waifu2x driver', action='store', default='waifu2x_caffe', choices=['waifu2x_caffe', 'waifu2x_converter', 'waifu2x_ncnn_vulkan'])
|
||||||
upscaler_options.add_argument('-y', '--model_dir', help='directory containing model JSON files', action='store')
|
upscaler_options.add_argument('-y', '--model_dir', help='directory containing model JSON files', action='store')
|
||||||
upscaler_options.add_argument('-t', '--threads', help='number of threads to use for upscaling', action='store', type=int, default=1)
|
upscaler_options.add_argument('-t', '--threads', help='number of threads to use for upscaling', action='store', type=int, default=1)
|
||||||
upscaler_options.add_argument('-c', '--config', help='video2x config file location', action='store', default=os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 'video2x.json'))
|
upscaler_options.add_argument('-c', '--config', help='video2x config file location', action='store', default=os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 'video2x.json'))
|
||||||
@ -203,9 +203,9 @@ def absolutify_paths(config):
|
|||||||
if not re.match('^[a-z]:', config['waifu2x_converter']['waifu2x_converter_path'], re.IGNORECASE):
|
if not re.match('^[a-z]:', config['waifu2x_converter']['waifu2x_converter_path'], re.IGNORECASE):
|
||||||
config['waifu2x_converter']['waifu2x_converter_path'] = os.path.join(current_directory, config['waifu2x_converter']['waifu2x_converter_path'])
|
config['waifu2x_converter']['waifu2x_converter_path'] = os.path.join(current_directory, config['waifu2x_converter']['waifu2x_converter_path'])
|
||||||
|
|
||||||
# check waifu2x-ncnn-vulkan path
|
# check waifu2x_ncnn_vulkan path
|
||||||
if not re.match('^[a-z]:', config['waifu2x-ncnn-vulkan']['waifu2x-ncnn-vulkan_path'], re.IGNORECASE):
|
if not re.match('^[a-z]:', config['waifu2x_ncnn_vulkan']['waifu2x_ncnn_vulkan_path'], re.IGNORECASE):
|
||||||
config['waifu2x-ncnn-vulkan']['waifu2x-ncnn-vulkan_path'] = os.path.join(current_directory, config['waifu2x-ncnn-vulkan']['waifu2x-ncnn-vulkan_path'])
|
config['waifu2x_ncnn_vulkan']['waifu2x_ncnn_vulkan_path'] = os.path.join(current_directory, config['waifu2x_ncnn_vulkan']['waifu2x_ncnn_vulkan_path'])
|
||||||
|
|
||||||
# check ffmpeg path
|
# check ffmpeg path
|
||||||
if not re.match('^[a-z]:', config['ffmpeg']['ffmpeg_path'], re.IGNORECASE):
|
if not re.match('^[a-z]:', config['ffmpeg']['ffmpeg_path'], re.IGNORECASE):
|
||||||
@ -248,11 +248,11 @@ if not args.input:
|
|||||||
if not args.output:
|
if not args.output:
|
||||||
Avalon.error('You must specify output video file/directory path')
|
Avalon.error('You must specify output video file/directory path')
|
||||||
exit(1)
|
exit(1)
|
||||||
if (args.driver == 'waifu2x_converter' or args.driver == 'waifu2x-ncnn-vulkan') and args.width and args.height:
|
if (args.driver == 'waifu2x_converter' or args.driver == 'waifu2x_ncnn_vulkan') and args.width and args.height:
|
||||||
Avalon.error('Waifu2x Converter CPP / waifu2x-ncnn-vulkan accepts only scaling ratio')
|
Avalon.error('Waifu2x Converter CPP / waifu2x_ncnn_vulkan accepts only scaling ratio')
|
||||||
exit(1)
|
exit(1)
|
||||||
if args.driver == 'waifu2x-ncnn-vulkan' and (args.ratio > 2 or not args.ratio.is_integer()):
|
if args.driver == 'waifu2x_ncnn_vulkan' and (args.ratio > 2 or not args.ratio.is_integer()):
|
||||||
Avalon.error('scale ratio must be 2 or 1 for waifu2x-ncnn-vulkan')
|
Avalon.error('scale ratio must be 2 or 1 for waifu2x_ncnn_vulkan')
|
||||||
exit(1)
|
exit(1)
|
||||||
if (args.width or args.height) and args.ratio:
|
if (args.width or args.height) and args.ratio:
|
||||||
Avalon.error('You can only specify either scaling ratio or output width and height')
|
Avalon.error('You can only specify either scaling ratio or output width and height')
|
||||||
@ -281,12 +281,12 @@ elif args.driver == 'waifu2x_converter':
|
|||||||
Avalon.error('Specified waifu2x-converter-cpp directory doesn\'t exist')
|
Avalon.error('Specified waifu2x-converter-cpp directory doesn\'t exist')
|
||||||
Avalon.error('Please check the configuration file settings')
|
Avalon.error('Please check the configuration file settings')
|
||||||
raise FileNotFoundError(waifu2x_settings['waifu2x_converter_path'])
|
raise FileNotFoundError(waifu2x_settings['waifu2x_converter_path'])
|
||||||
elif args.driver == 'waifu2x-ncnn-vulkan':
|
elif args.driver == 'waifu2x_ncnn_vulkan':
|
||||||
waifu2x_settings = config['waifu2x-ncnn-vulkan']
|
waifu2x_settings = config['waifu2x_ncnn_vulkan']
|
||||||
if not os.path.isfile(waifu2x_settings['waifu2x-ncnn-vulkan_path']):
|
if not os.path.isfile(waifu2x_settings['waifu2x_ncnn_vulkan_path']):
|
||||||
Avalon.error('Specified waifu2x-ncnn-vulkan directory doesn\'t exist')
|
Avalon.error('Specified waifu2x_ncnn_vulkan directory doesn\'t exist')
|
||||||
Avalon.error('Please check the configuration file settings')
|
Avalon.error('Please check the configuration file settings')
|
||||||
raise FileNotFoundError(waifu2x_settings['waifu2x-ncnn-vulkan_path'])
|
raise FileNotFoundError(waifu2x_settings['waifu2x_ncnn_vulkan_path'])
|
||||||
|
|
||||||
# read FFmpeg configuration
|
# read FFmpeg configuration
|
||||||
ffmpeg_settings = config['ffmpeg']
|
ffmpeg_settings = config['ffmpeg']
|
||||||
|
@ -23,7 +23,7 @@ Installation Details:
|
|||||||
- ffmpeg: %LOCALAPPDATA%\\video2x\\ffmpeg
|
- ffmpeg: %LOCALAPPDATA%\\video2x\\ffmpeg
|
||||||
- waifu2x-caffe: %LOCALAPPDATA%\\video2x\\waifu2x-caffe
|
- waifu2x-caffe: %LOCALAPPDATA%\\video2x\\waifu2x-caffe
|
||||||
- waifu2x-cpp-converter: %LOCALAPPDATA%\\video2x\\waifu2x-converter-cpp
|
- waifu2x-cpp-converter: %LOCALAPPDATA%\\video2x\\waifu2x-converter-cpp
|
||||||
- waifu2x-ncnn-vulkan: %LOCALAPPDATA%\\video2x\\waifu2x-ncnn-vulkan
|
- waifu2x_ncnn_vulkan: %LOCALAPPDATA%\\video2x\\waifu2x-ncnn-vulkan
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
@ -50,7 +50,7 @@ def process_arguments():
|
|||||||
|
|
||||||
# video options
|
# video options
|
||||||
general_options = parser.add_argument_group('General Options')
|
general_options = parser.add_argument_group('General Options')
|
||||||
general_options.add_argument('-d', '--driver', help='driver to download and configure', action='store', choices=['all', 'waifu2x_caffe', 'waifu2x_converter', 'waifu2x-ncnn-vulkan'], default='all')
|
general_options.add_argument('-d', '--driver', help='driver to download and configure', action='store', choices=['all', 'waifu2x_caffe', 'waifu2x_converter', 'waifu2x_ncnn_vulkan'], default='all')
|
||||||
|
|
||||||
# parse arguments
|
# parse arguments
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
@ -84,7 +84,7 @@ class Video2xSetup:
|
|||||||
self._install_waifu2x_caffe()
|
self._install_waifu2x_caffe()
|
||||||
elif self.driver == 'waifu2x_converter':
|
elif self.driver == 'waifu2x_converter':
|
||||||
self._install_waifu2x_converter_cpp()
|
self._install_waifu2x_converter_cpp()
|
||||||
elif self.driver == 'waifu2x-ncnn-vulkan':
|
elif self.driver == 'waifu2x_ncnn_vulkan':
|
||||||
self._install_waifu2x_ncnn_vulkan()
|
self._install_waifu2x_ncnn_vulkan()
|
||||||
|
|
||||||
print('\nGenerating Video2X configuration file')
|
print('\nGenerating Video2X configuration file')
|
||||||
@ -197,14 +197,14 @@ class Video2xSetup:
|
|||||||
template_dict['waifu2x_caffe']['waifu2x_caffe_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-caffe', 'waifu2x-caffe-cui.exe')
|
template_dict['waifu2x_caffe']['waifu2x_caffe_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-caffe', 'waifu2x-caffe-cui.exe')
|
||||||
template_dict['waifu2x_converter']['waifu2x_converter_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-converter-cpp')
|
template_dict['waifu2x_converter']['waifu2x_converter_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-converter-cpp')
|
||||||
# TODO: after version 20190611 executable changes to waifu2x-ncnn-vulkan so rename this when it breaks
|
# TODO: after version 20190611 executable changes to waifu2x-ncnn-vulkan so rename this when it breaks
|
||||||
template_dict['waifu2x-ncnn-vulkan']['waifu2x-ncnn-vulkan_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-ncnn-vulkan', 'waifu2x.exe')
|
template_dict['waifu2x_ncnn_vulkan']['waifu2x_ncnn_vulkan_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-ncnn-vulkan', 'waifu2x.exe')
|
||||||
elif self.driver == 'waifu2x_caffe':
|
elif self.driver == 'waifu2x_caffe':
|
||||||
template_dict['waifu2x_caffe']['waifu2x_caffe_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-caffe', 'waifu2x-caffe-cui.exe')
|
template_dict['waifu2x_caffe']['waifu2x_caffe_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-caffe', 'waifu2x-caffe-cui.exe')
|
||||||
elif self.driver == 'waifu2x_converter':
|
elif self.driver == 'waifu2x_converter':
|
||||||
template_dict['waifu2x_converter']['waifu2x_converter_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-converter-cpp')
|
template_dict['waifu2x_converter']['waifu2x_converter_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-converter-cpp')
|
||||||
elif self.driver == 'waifu2x-ncnn-vulkan':
|
elif self.driver == 'waifu2x_ncnn_vulkan':
|
||||||
# TODO: after version 20190611 executable changes to waifu2x-ncnn-vulkan so rename this when it breaks
|
# TODO: after version 20190611 executable changes to waifu2x-ncnn-vulkan so rename this when it breaks
|
||||||
template_dict['waifu2x-ncnn-vulkan']['waifu2x-ncnn-vulkan_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-ncnn-vulkan', 'waifu2x.exe')
|
template_dict['waifu2x_ncnn_vulkan']['waifu2x_ncnn_vulkan_path'] = os.path.join(local_app_data, 'video2x', 'waifu2x-ncnn-vulkan', 'waifu2x.exe')
|
||||||
|
|
||||||
template_dict['ffmpeg']['ffmpeg_path'] = os.path.join(local_app_data, 'video2x', 'ffmpeg-latest-win64-static', 'bin')
|
template_dict['ffmpeg']['ffmpeg_path'] = os.path.join(local_app_data, 'video2x', 'ffmpeg-latest-win64-static', 'bin')
|
||||||
template_dict['video2x']['video2x_cache_directory'] = None
|
template_dict['video2x']['video2x_cache_directory'] = None
|
||||||
|
@ -7,7 +7,7 @@ Name: Waifu2x NCNN Vulkan Driver
|
|||||||
Author: K4YT3X, SAT3LL
|
Author: K4YT3X, SAT3LL
|
||||||
|
|
||||||
Description: This class is a high-level wrapper
|
Description: This class is a high-level wrapper
|
||||||
for waifu2x-ncnn-vulkan.
|
for waifu2x_ncnn_vulkan.
|
||||||
"""
|
"""
|
||||||
from avalon_framework import Avalon
|
from avalon_framework import Avalon
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -28,9 +28,9 @@ class Waifu2xNcnnVulkan:
|
|||||||
|
|
||||||
# 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.waifu2x_settings['waifu2x_ncnn_vulkan_path'], '..'))
|
||||||
|
|
||||||
self.print_lock = threading.Lock()
|
self.print_lock = threading.Lock()
|
||||||
|
|
||||||
@ -53,14 +53,14 @@ class Waifu2xNcnnVulkan:
|
|||||||
Avalon.debug_info(f'[upscaler] Thread {threading.current_thread().name} started')
|
Avalon.debug_info(f'[upscaler] Thread {threading.current_thread().name} started')
|
||||||
self.print_lock.release()
|
self.print_lock.release()
|
||||||
|
|
||||||
# waifu2x-ncnn-vulkan accepts arguments in a positional manner
|
# waifu2x_ncnn_vulkan accepts arguments in a positional manner
|
||||||
# See: https://github.com/nihui/waifu2x-ncnn-vulkan#usage
|
# See: https://github.com/nihui/waifu2x_ncnn_vulkan#usage
|
||||||
# waifu2x-ncnn-vulkan.exe [input image] [output png] [noise=-1/0/1/2/3] [scale=1/2] [blocksize=400]
|
# waifu2x_ncnn_vulkan.exe [input image] [output png] [noise=-1/0/1/2/3] [scale=1/2] [blocksize=400]
|
||||||
# noise = noise level, large value means strong denoise effect, -1=no effect
|
# noise = noise level, large value means strong denoise effect, -1=no effect
|
||||||
# scale = scale level, 1=no scale, 2=upscale 2x
|
# scale = scale level, 1=no scale, 2=upscale 2x
|
||||||
# blocksize = tile size, use smaller value to reduce GPU memory usage, default is 400
|
# blocksize = tile size, use smaller value to reduce GPU memory usage, default is 400
|
||||||
|
|
||||||
# waifu2x-ncnn-vulkan does not accept an arbitrary scale ratio, max is 2
|
# waifu2x_ncnn_vulkan does not accept an arbitrary scale ratio, max is 2
|
||||||
if scale_ratio == 1:
|
if scale_ratio == 1:
|
||||||
for raw_frame in os.listdir(input_directory):
|
for raw_frame in os.listdir(input_directory):
|
||||||
command = [
|
command = [
|
||||||
@ -70,7 +70,7 @@ class Waifu2xNcnnVulkan:
|
|||||||
'1',
|
'1',
|
||||||
str(self.waifu2x_settings['block-size'])
|
str(self.waifu2x_settings['block-size'])
|
||||||
]
|
]
|
||||||
execute = [self.waifu2x_settings['waifu2x-ncnn-vulkan_path']]
|
execute = [self.waifu2x_settings['waifu2x_ncnn_vulkan_path']]
|
||||||
execute.extend(command)
|
execute.extend(command)
|
||||||
|
|
||||||
Avalon.debug_info(f'Executing: {execute}')
|
Avalon.debug_info(f'Executing: {execute}')
|
||||||
@ -84,7 +84,7 @@ class Waifu2xNcnnVulkan:
|
|||||||
'2',
|
'2',
|
||||||
str(self.waifu2x_settings['block-size'])
|
str(self.waifu2x_settings['block-size'])
|
||||||
]
|
]
|
||||||
execute = [self.waifu2x_settings['waifu2x-ncnn-vulkan_path']]
|
execute = [self.waifu2x_settings['waifu2x_ncnn_vulkan_path']]
|
||||||
execute.extend(command)
|
execute.extend(command)
|
||||||
|
|
||||||
Avalon.debug_info(f'Executing: {execute}')
|
Avalon.debug_info(f'Executing: {execute}')
|
||||||
|
Loading…
Reference in New Issue
Block a user