mirror of
https://github.com/k4yt3x/video2x.git
synced 2026-05-14 05:57:31 +08:00
2.0.3 added print thread lock to prevent printing format errors
This commit is contained in:
13
waifu2x.py
13
waifu2x.py
@@ -9,7 +9,7 @@ Last Modified: October 22, 2018
|
|||||||
Description: This class controls waifu2x
|
Description: This class controls waifu2x
|
||||||
engine
|
engine
|
||||||
|
|
||||||
Version 2.0.2
|
Version 2.0.3
|
||||||
"""
|
"""
|
||||||
from avalon_framework import Avalon
|
from avalon_framework import Avalon
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -29,6 +29,7 @@ class Waifu2x:
|
|||||||
self.waifu2x_path = waifu2x_path
|
self.waifu2x_path = waifu2x_path
|
||||||
self.method = method
|
self.method = method
|
||||||
self.model_type = model_type
|
self.model_type = model_type
|
||||||
|
self.print_lock = threading.Lock()
|
||||||
|
|
||||||
def upscale(self, folderin, folderout, width, height):
|
def upscale(self, folderin, folderout, width, height):
|
||||||
"""This is the core function for WAIFU2X class
|
"""This is the core function for WAIFU2X class
|
||||||
@@ -39,8 +40,18 @@ class Waifu2x:
|
|||||||
width {int} -- output video width
|
width {int} -- output video width
|
||||||
height {int} -- output video height
|
height {int} -- output video height
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Print thread start message
|
||||||
|
self.print_lock.acquire()
|
||||||
Avalon.debug_info('[upscaler] Thread {} started'.format(threading.current_thread().name))
|
Avalon.debug_info('[upscaler] Thread {} started'.format(threading.current_thread().name))
|
||||||
|
self.print_lock.release()
|
||||||
|
|
||||||
|
# Create string for execution
|
||||||
execute = '{} -p {} -I png -i {} -e png -o {} -w {} -h {} -n 3 -m noise_scale -y {}'.format(
|
execute = '{} -p {} -I png -i {} -e png -o {} -w {} -h {} -n 3 -m noise_scale -y {}'.format(
|
||||||
self.waifu2x_path, self.method, folderin, folderout, width, height, self.model_type)
|
self.waifu2x_path, self.method, folderin, folderout, width, height, self.model_type)
|
||||||
subprocess.call(execute)
|
subprocess.call(execute)
|
||||||
|
|
||||||
|
# Print thread exiting message
|
||||||
|
self.print_lock.acquire()
|
||||||
Avalon.debug_info('[upscaler] Thread {} exiting'.format(threading.current_thread().name))
|
Avalon.debug_info('[upscaler] Thread {} exiting'.format(threading.current_thread().name))
|
||||||
|
self.print_lock.release()
|
||||||
|
|||||||
Reference in New Issue
Block a user