2018-02-24 18:34:00 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Name: FFMPEG Class
|
|
|
|
Author: K4YT3X
|
|
|
|
Date Created: Feb 24, 2018
|
2018-10-22 19:21:59 +00:00
|
|
|
Last Modified: October 22, 2018
|
2018-02-24 18:34:00 +00:00
|
|
|
|
|
|
|
Description: This class controls waifu2x
|
|
|
|
engine
|
|
|
|
|
2018-10-22 19:01:40 +00:00
|
|
|
Version 2.0.2
|
2018-02-24 18:34:00 +00:00
|
|
|
"""
|
2018-10-22 19:01:40 +00:00
|
|
|
from avalon_framework import Avalon
|
2018-05-19 04:54:16 +00:00
|
|
|
import subprocess
|
2018-10-22 19:01:40 +00:00
|
|
|
import threading
|
2018-02-24 18:34:00 +00:00
|
|
|
|
|
|
|
|
2018-10-22 19:01:40 +00:00
|
|
|
class Waifu2x:
|
2018-02-25 03:52:04 +00:00
|
|
|
"""This class communicates with waifu2x cui engine
|
|
|
|
|
|
|
|
An object will be created for this class, containing information
|
|
|
|
about the binary address and the processing method. When being called
|
|
|
|
by the main program, other detailed information will be passed to
|
|
|
|
the upscale function.
|
|
|
|
"""
|
2018-02-24 18:34:00 +00:00
|
|
|
|
2018-05-19 04:54:16 +00:00
|
|
|
def __init__(self, waifu2x_path, method, model_type):
|
2018-02-24 21:13:27 +00:00
|
|
|
self.waifu2x_path = waifu2x_path
|
2018-02-24 21:55:26 +00:00
|
|
|
self.method = method
|
2018-05-19 04:54:16 +00:00
|
|
|
self.model_type = model_type
|
2018-02-24 18:34:00 +00:00
|
|
|
|
2018-09-29 15:02:36 +00:00
|
|
|
def upscale(self, folderin, folderout, width, height):
|
|
|
|
"""This is the core function for WAIFU2X class
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
folderin {string} -- source folder path
|
|
|
|
folderout {string} -- output folder path
|
|
|
|
width {int} -- output video width
|
|
|
|
height {int} -- output video height
|
|
|
|
"""
|
2018-10-22 19:01:40 +00:00
|
|
|
Avalon.debug_info('[upscaler] Thread {} started'.format(threading.current_thread().name))
|
|
|
|
execute = '{} -p {} -I png -i {} -e png -o {} -w {} -h {} -n 3 -m noise_scale -y {}'.format(
|
2018-09-29 15:02:36 +00:00
|
|
|
self.waifu2x_path, self.method, folderin, folderout, width, height, self.model_type)
|
|
|
|
subprocess.call(execute)
|
2018-10-22 19:01:40 +00:00
|
|
|
Avalon.debug_info('[upscaler] Thread {} exiting'.format(threading.current_thread().name))
|