sync - broken currently due to refactoring!!
This commit is contained in:
Binary file not shown.
@@ -1,15 +0,0 @@
|
|||||||
class ArgAssembly:
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get(self, quality):
|
|
||||||
if quality == "2x":
|
|
||||||
return "Performance"
|
|
||||||
elif quality == "1.7x":
|
|
||||||
return "Balanced"
|
|
||||||
elif quality == "1.5x":
|
|
||||||
return "Quality"
|
|
||||||
elif quality == "1.3x":
|
|
||||||
return "UltraQuality"
|
|
||||||
else:
|
|
||||||
raise Exception
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
class Checks:
|
|
||||||
def __init__(self):
|
|
||||||
self.custom_quality = 0.0
|
|
||||||
self.i_file_extension = ""
|
|
||||||
|
|
||||||
def perform(self, quality_selection, custom_quality, input_filepath, output_filepath):
|
|
||||||
# Call this function to perform entry checks.
|
|
||||||
# Returns True if all checks passed, False if one or more not passed.
|
|
||||||
if self.quality_checks(quality_selection, custom_quality) and self.file_checks(input_filepath, output_filepath):
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def quality_checks(self, quality_sel, custom_q):
|
|
||||||
if quality_sel != "Custom (will respect value below)":
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
self.custom_quality = float(custom_q)
|
|
||||||
except ValueError:
|
|
||||||
if str(custom_q)[len(custom_q) - 1:] == "x":
|
|
||||||
print("x found")
|
|
||||||
try:
|
|
||||||
self.custom_quality = float(str(custom_q)[:len(custom_q) - 1])
|
|
||||||
except ValueError:
|
|
||||||
print("invalid custom quality multiplier")
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
print("invalid letter in custom quality multiplier!")
|
|
||||||
return False
|
|
||||||
if 4 >= self.custom_quality >= 1:
|
|
||||||
print("quality selction ok")
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
print("invalid range for multiplier!")
|
|
||||||
|
|
||||||
def file_checks(self, i_fp, o_fp):
|
|
||||||
self.i_file_extension = str(i_fp)[len(i_fp) - 4:]
|
|
||||||
if self.i_file_extension == ".png" or self.i_file_extension == ".jpg":
|
|
||||||
print("file extensions ok (image)")
|
|
||||||
elif self.i_file_extension == "jpeg":
|
|
||||||
if str(i_fp)[len(i_fp) - 5:] == ".jpeg":
|
|
||||||
print("file extensions ok (image)")
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
elif self.i_file_extension == ".mp4" or self.i_file_extension == ".mkv":
|
|
||||||
print("file extensions ok (video)")
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
if str(i_fp)[len(i_fp) - 4:] == str(o_fp)[len(o_fp) - 4:]:
|
|
||||||
print("file extensions are the same in output and input")
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
print("files don't have same extension!")
|
|
||||||
return False
|
|
||||||
339
bin/engines/fsr.py
Normal file
339
bin/engines/fsr.py
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
import os
|
||||||
|
import multiprocessing
|
||||||
|
import time
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class FSRScaler:
|
||||||
|
def __init__(self):
|
||||||
|
self.os_type = sys.platform
|
||||||
|
self.command = ""
|
||||||
|
self.tmppath = ""
|
||||||
|
self.videometa = {}
|
||||||
|
|
||||||
|
def fsrScaler ( self, tmppath, filepath, threads, fsrpath, quality_setting, sharpening, scaling, filetype, mode ):
|
||||||
|
# Locate Images and assemble FSR-Command
|
||||||
|
self.file_list = []
|
||||||
|
self.filelist = os.listdir(tmppath)
|
||||||
|
self.filelist.pop(0)
|
||||||
|
self.filelist.sort()
|
||||||
|
self.number = 0
|
||||||
|
if sharpening != '' and sharpening != None:
|
||||||
|
for self.file in self.filelist:
|
||||||
|
self.number += 1
|
||||||
|
if ( self.os_type == 'win32' ):
|
||||||
|
self.file_list.append( f"{tmppath}{self.file} {tmppath}up\\up{str(self.number).zfill(8)}.{ filetype } " );
|
||||||
|
else:
|
||||||
|
self.file_list.append( f"{tmppath}{self.file} {tmppath}up/up{str(self.number).zfill(8)}.{ filetype } " );
|
||||||
|
try:
|
||||||
|
os.mkdir( f'{tmppath}up' )
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
for self.file in self.filelist:
|
||||||
|
self.number += 1
|
||||||
|
if ( self.os_type == 'win32' ):
|
||||||
|
self.file_list.append( f"{tmppath}{self.file} {tmppath}sc\\ig{str(self.number).zfill(8)}.{ filetype } " );
|
||||||
|
else:
|
||||||
|
self.file_list.append( f"{tmppath}{self.file} {tmppath}sc/ig{str(self.number).zfill(8)}.{ filetype } " );
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir( f'{tmppath}sc' )
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if ( self.os_type == 'win32' ):
|
||||||
|
self.maxlength = 8000
|
||||||
|
else:
|
||||||
|
self.maxlength = 31900
|
||||||
|
self.pos = 1
|
||||||
|
|
||||||
|
############################################
|
||||||
|
#
|
||||||
|
# Thread optimisation: Divide workload up into different threads & upscale using helper function
|
||||||
|
#
|
||||||
|
############################################
|
||||||
|
self.threads = threads
|
||||||
|
if ( threads > multiprocessing.cpu_count() ):
|
||||||
|
self.threads = multiprocessing.cpu_count();
|
||||||
|
|
||||||
|
if ( not scaling ):
|
||||||
|
engines = { 'NN': 'NearestNeighbor', 'fsr':'FidelityFX Super Resolution' }
|
||||||
|
print( f'\n\n==> Upscaling using { self.threads } threads <==\n\n' );
|
||||||
|
print( f'\n\n==> Upscaling Engine is { engines[ mode ] } <==\n\n' );
|
||||||
|
|
||||||
|
time.sleep( 2 );
|
||||||
|
|
||||||
|
self.command_list = [];
|
||||||
|
self.file_list_length = len( self.file_list );
|
||||||
|
for i in range( self.threads ):
|
||||||
|
self.files = '';
|
||||||
|
for _ in range( int( self.file_list_length // self.threads ) ):
|
||||||
|
self.files += self.file_list.pop( 0 );
|
||||||
|
|
||||||
|
if ( i == self.threads - 1 ):
|
||||||
|
for element in self.file_list:
|
||||||
|
self.files += element;
|
||||||
|
self.command_list.append( ( self.files, fsrpath, quality_setting, i, self.maxlength, self.os_type ) )
|
||||||
|
|
||||||
|
self.pool = multiprocessing.Pool( self.threads )
|
||||||
|
if ( mode == 'B' ):
|
||||||
|
self.pool.starmap( bilinearEngine, self.command_list );
|
||||||
|
elif ( mode == 'fsr' ):
|
||||||
|
self.pool.starmap( upscalerEngine, self.command_list );
|
||||||
|
self.pool.close();
|
||||||
|
self.pool.join();
|
||||||
|
|
||||||
|
if sharpening != '' and sharpening != None:
|
||||||
|
print( f'\n\n\n==> Sharpening using { self.threads } threads <==\n\n' );
|
||||||
|
time.sleep( 2 );
|
||||||
|
|
||||||
|
self.pathSharpening = tmppath
|
||||||
|
|
||||||
|
if ( not scaling ):
|
||||||
|
if ( self.os_type == 'win32' ):
|
||||||
|
self.pathSharpening += 'up\\'
|
||||||
|
elif ( self.os_type == 'linux' ):
|
||||||
|
self.pathSharpening += 'up/'
|
||||||
|
|
||||||
|
time.sleep( 2 );
|
||||||
|
try:
|
||||||
|
os.mkdir( f'{tmppath}sc' )
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
# Locate Images and assemble FSR-Command
|
||||||
|
self.file_list = []
|
||||||
|
self.filelist = os.listdir( self.pathSharpening )
|
||||||
|
self.filelist.pop(0)
|
||||||
|
self.filelist.sort()
|
||||||
|
self.number = 0
|
||||||
|
for self.file in self.filelist:
|
||||||
|
self.number += 1
|
||||||
|
if ( self.os_type == 'win32' ):
|
||||||
|
self.file_list.append( f"{self.pathSharpening}{self.file} {tmppath}sc\\ig{str(self.number).zfill(8)}.{ filetype } " );
|
||||||
|
else:
|
||||||
|
self.file_list.append( f"{self.pathSharpening}{self.file} {tmppath}sc/ig{str(self.number).zfill(8)}.{ filetype } " );
|
||||||
|
|
||||||
|
if ( self.os_type == 'win32' ):
|
||||||
|
self.maxlength = 8000
|
||||||
|
else:
|
||||||
|
self.maxlength = 31900
|
||||||
|
self.pos = 1
|
||||||
|
|
||||||
|
# assemble command list
|
||||||
|
self.command_list = [];
|
||||||
|
self.file_list_length = len( self.file_list );
|
||||||
|
for i in range( self.threads ):
|
||||||
|
self.files = '';
|
||||||
|
for _ in range( int( self.file_list_length // self.threads ) ):
|
||||||
|
self.files += self.file_list.pop( 0 );
|
||||||
|
|
||||||
|
if ( i == self.threads - 1 ):
|
||||||
|
for element in self.file_list:
|
||||||
|
self.files += element;
|
||||||
|
self.command_list.append( ( self.files, fsrpath, i, self.maxlength, self.os_type, sharpening, not sharpening ) )
|
||||||
|
|
||||||
|
self.pool = multiprocessing.Pool( self.threads )
|
||||||
|
self.pool.starmap( sharpeningEngine, self.command_list );
|
||||||
|
self.pool.close();
|
||||||
|
self.pool.join();
|
||||||
|
|
||||||
|
# Add return values
|
||||||
|
|
||||||
|
|
||||||
|
def upscalerEngine ( files, fsrpath, quality_setting, number, maxlength, os_type ):
|
||||||
|
files = files;
|
||||||
|
# Refactoring of commands that are longer than 32K characters
|
||||||
|
fileout = [];
|
||||||
|
pos = 0;
|
||||||
|
if len( files ) > maxlength:
|
||||||
|
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
file_processing = files[:maxlength - pos]
|
||||||
|
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
||||||
|
pos += 5
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
fileout.append(files[:maxlength - pos])
|
||||||
|
filesopt = files[maxlength - pos:]
|
||||||
|
posx = 0
|
||||||
|
posy = maxlength
|
||||||
|
|
||||||
|
# Command refactoring for commands that are longer than 64K characters
|
||||||
|
if len(filesopt) > maxlength:
|
||||||
|
while len(filesopt) > maxlength:
|
||||||
|
posx += maxlength - pos
|
||||||
|
posy += maxlength - pos
|
||||||
|
pos = 1
|
||||||
|
while files[posy - pos:posy - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
file_processing = files[posx:posy - pos]
|
||||||
|
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
||||||
|
pos += 5
|
||||||
|
while files[posy - pos:posy - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
|
||||||
|
file_processing = files[posx:posy - pos]
|
||||||
|
fileout.append(file_processing)
|
||||||
|
filesopt = files[posy - pos:]
|
||||||
|
fileout.append(filesopt)
|
||||||
|
else:
|
||||||
|
fileout.append(files[maxlength - pos:])
|
||||||
|
else:
|
||||||
|
fileout.append(files)
|
||||||
|
|
||||||
|
# Upscaling images
|
||||||
|
print( '\n\n\nUpscaling images... \n\n\n\n\n\n PROCESS: ', number, '\n\n\n' )
|
||||||
|
|
||||||
|
while len( fileout ) > 0:
|
||||||
|
files_handle = fileout.pop(0)
|
||||||
|
if os_type == 'linux':
|
||||||
|
command_us = f'wine {fsrpath} -Scale {quality_setting} {quality_setting} {files_handle}'
|
||||||
|
elif os_type == 'win32':
|
||||||
|
command_us = f'FidelityFX_CLI -Scale {quality_setting} {quality_setting} {files_handle}'
|
||||||
|
else:
|
||||||
|
print( 'OS CURRENTLY UNSUPPORTED!' )
|
||||||
|
return False
|
||||||
|
sub = subprocess.Popen( command_us, shell=True );
|
||||||
|
sub.wait();
|
||||||
|
time.sleep(3)
|
||||||
|
print( '\n\nCompleted executing Job\n\n\n PROCESS: ', number, '\n\n\n' );
|
||||||
|
|
||||||
|
|
||||||
|
def bilinearEngine ( files, fsrpath, quality_setting, number, maxlength, os_type, version ):
|
||||||
|
if ( version == 'HQC' ):
|
||||||
|
scaler = 'HighQualityCubic'
|
||||||
|
files = files;
|
||||||
|
# Refactoring of commands that are longer than 32K characters
|
||||||
|
fileout = [];
|
||||||
|
pos = 0;
|
||||||
|
if len( files ) > maxlength:
|
||||||
|
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
file_processing = files[:maxlength - pos]
|
||||||
|
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
||||||
|
pos += 5
|
||||||
|
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
fileout.append(files[:maxlength - pos])
|
||||||
|
filesopt = files[maxlength - pos:]
|
||||||
|
posx = 0
|
||||||
|
posy = maxlength
|
||||||
|
|
||||||
|
# Command refactoring for commands that are longer than 64K characters
|
||||||
|
if len(filesopt) > maxlength:
|
||||||
|
while len(filesopt) > maxlength:
|
||||||
|
posx += maxlength - pos
|
||||||
|
posy += maxlength - pos
|
||||||
|
pos = 1
|
||||||
|
while files[posy - pos:posy - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
file_processing = files[posx:posy - pos]
|
||||||
|
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
||||||
|
pos += 5
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
while files[posy - pos:posy - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
|
||||||
|
file_processing = files[posx:posy - pos]
|
||||||
|
fileout.append(file_processing)
|
||||||
|
filesopt = files[posy - pos:]
|
||||||
|
fileout.append(filesopt)
|
||||||
|
else:
|
||||||
|
fileout.append(files[maxlength - pos:])
|
||||||
|
else:
|
||||||
|
fileout.append(files)
|
||||||
|
|
||||||
|
# Upscaling images
|
||||||
|
print( '\n\n\nUpscaling images... \n\n\n\n\n\n PROCESS: ', number, '\n\n\n' )
|
||||||
|
|
||||||
|
while len( fileout ) > 0:
|
||||||
|
files_handle = fileout.pop(0)
|
||||||
|
if os_type == 'linux':
|
||||||
|
command_us = f'wine {fsrpath} -Mode NearestNeighbor -Scale {quality_setting} {quality_setting} {files_handle}'
|
||||||
|
elif os_type == 'win32':
|
||||||
|
command_us = f'FidelityFX_CLI -Mode NearestNeighbor -Scale {quality_setting} {quality_setting} {files_handle}'
|
||||||
|
else:
|
||||||
|
print( 'OS CURRENTLY UNSUPPORTED!' )
|
||||||
|
return False
|
||||||
|
sub = subprocess.Popen( command_us, shell=True );
|
||||||
|
sub.wait();
|
||||||
|
time.sleep(3)
|
||||||
|
print( '\n\nCompleted executing Job\n\n\n PROCESS: ', number, '\n\n\n' );
|
||||||
|
|
||||||
|
########################
|
||||||
|
#
|
||||||
|
# Sharpening
|
||||||
|
#
|
||||||
|
#######################
|
||||||
|
|
||||||
|
def sharpeningEngine ( files, fsrpath, number, maxlength, os_type, sharpening, didUpscale ):
|
||||||
|
files = files;
|
||||||
|
# Refactoring of commands that are longer than 32K characters
|
||||||
|
fileout = [];
|
||||||
|
pos = 0;
|
||||||
|
if len( files ) > maxlength:
|
||||||
|
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
file_processing = files[:maxlength - pos]
|
||||||
|
if ( didUpscale ):
|
||||||
|
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'up':
|
||||||
|
pos += 5
|
||||||
|
else:
|
||||||
|
if file_processing[len(file_processing) - 17:len(file_processing) - 15] == 'ru':
|
||||||
|
pos += 8
|
||||||
|
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
fileout.append(files[:maxlength - pos])
|
||||||
|
filesopt = files[maxlength - pos:]
|
||||||
|
posx = 0
|
||||||
|
posy = maxlength
|
||||||
|
|
||||||
|
# Command refactoring for commands that are longer than 64K characters
|
||||||
|
if len(filesopt) > maxlength:
|
||||||
|
while len(filesopt) > maxlength:
|
||||||
|
posx += maxlength - pos
|
||||||
|
posy += maxlength - pos
|
||||||
|
pos = 1
|
||||||
|
while files[posy - pos:posy - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
file_processing = files[posx:posy - pos]
|
||||||
|
if ( didUpscale ):
|
||||||
|
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'up':
|
||||||
|
pos += 5
|
||||||
|
else:
|
||||||
|
if file_processing[len(file_processing) - 17:len(file_processing) - 15] == 'ru':
|
||||||
|
pos += 8
|
||||||
|
while files[posy - pos:posy - pos + 1] != ' ':
|
||||||
|
pos += 1
|
||||||
|
|
||||||
|
file_processing = files[posx:posy - pos]
|
||||||
|
fileout.append(file_processing)
|
||||||
|
filesopt = files[posy - pos:]
|
||||||
|
fileout.append(filesopt)
|
||||||
|
else:
|
||||||
|
fileout.append(files[maxlength - pos:])
|
||||||
|
else:
|
||||||
|
fileout.append(files)
|
||||||
|
|
||||||
|
# Upscaling images
|
||||||
|
print( '\n\n\nSharpening images... \n\n\n\n\n\n PROCESS: ', number, '\n\n\n' )
|
||||||
|
|
||||||
|
while len( fileout ) > 0:
|
||||||
|
files_handle = fileout.pop(0)
|
||||||
|
print( '\n\n\n PROCESS: ', number, '\nRunning sharpening filter\n\n\n' );
|
||||||
|
if os_type == 'linux':
|
||||||
|
command_sharpening = f'wine {fsrpath} -Mode CAS -Sharpness {sharpening} {files_handle}'
|
||||||
|
elif os_type == 'win32':
|
||||||
|
command_sharpening = f'FidelityFX_CLI -Mode CAS -Sharpness {sharpening} {files_handle}'
|
||||||
|
else:
|
||||||
|
print( 'OS CURRENTLY UNSUPPORTED!' )
|
||||||
|
return False
|
||||||
|
sub2 = subprocess.Popen( command_sharpening, shell=True );
|
||||||
|
sub2.wait()
|
||||||
|
time.sleep(3)
|
||||||
|
print( '\n\nCompleted executing Job\n\n\n PROCESS: ', number, '\n\n\n' );
|
||||||
|
|
||||||
90
bin/engines/ss.py
Normal file
90
bin/engines/ss.py
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import multiprocessing
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class SpecialScaler:
|
||||||
|
def __init__(self):
|
||||||
|
self.os_type = sys.platform
|
||||||
|
self.command = ""
|
||||||
|
self.tmppath = ""
|
||||||
|
self.videometa = {}
|
||||||
|
|
||||||
|
def superScaler ( self, tmppath, threads, quality_setting, os_platform, model ):
|
||||||
|
print( '\n\n==> Preparing to upscale videos <==\n\n==> You will see a lot of numbers flying by showing the progress of the upscaling of each individual image.\n==> This process might take a long time, depending on the length of the video.\n\n')
|
||||||
|
time.sleep( 2 );
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir( f'{tmppath}sc' )
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
if ( os_platform == 'win32' ):
|
||||||
|
self.command = f'realesrgan-ncnn-vulkan -i {tmppath} -o {tmppath}sc -s {quality_setting} -j {threads}:{threads}:{threads} -n {model}'
|
||||||
|
elif ( os_platform == 'linux' ):
|
||||||
|
self.command = f'wine ./bin/lib/realesrgan-ncnn-vulkan.exe -i {tmppath} -o {tmppath}sc -s {quality_setting} -j {threads}:{threads}:{threads} -n {model}'
|
||||||
|
os.system( self.command );
|
||||||
|
|
||||||
|
|
||||||
|
def specialSuperScaler ( self, tmppath, threads, quality_setting, model ):
|
||||||
|
self.fileList = os.listdir( tmppath )
|
||||||
|
self.fileList.pop( 0 )
|
||||||
|
self.fileList.sort()
|
||||||
|
if ( threads > multiprocessing.cpu_count() * 2 ):
|
||||||
|
self.threads = multiprocessing.cpu_count() * 2;
|
||||||
|
else:
|
||||||
|
self.threads = threads
|
||||||
|
|
||||||
|
self.fileCount = len( self.fileList ) // self.threads
|
||||||
|
self.spareFiles = len( self.fileList ) % self.threads
|
||||||
|
|
||||||
|
self.cmdList = [];
|
||||||
|
|
||||||
|
for t in range( threads ):
|
||||||
|
try:
|
||||||
|
os.mkdir( f'{tmppath}{t}' )
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.base = t * self.fileCount;
|
||||||
|
if ( self.os_type == 'win32' ):
|
||||||
|
for j in range( self.fileCount ):
|
||||||
|
os.rename( f'{tmppath}{self.fileList[ self.base + j ] }', f'{tmppath}{ t }\\{self.fileList[ self.base + j ] }' )
|
||||||
|
elif ( self.os_type == 'linux' ):
|
||||||
|
for j in range( self.fileCount ):
|
||||||
|
os.rename( f'{tmppath}{self.fileList[ self.base + j ] }', f'{tmppath}{ t }/{self.fileList[ self.base + j ] }' )
|
||||||
|
|
||||||
|
self.cmdList.append( ( tmppath, t, quality_setting, model, self.os_type ) )
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir( f'{tmppath}{self.threads + 1}' )
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if ( self.os_type == 'win32' ):
|
||||||
|
for k in range( self.spareFiles ):
|
||||||
|
os.rename( f'{tmppath}{self.fileList[ self.threads * self.fileCount + k ] }', f'{tmppath}{ t }\\{self.fileList[ self.threads * self.fileCount + k ] }' )
|
||||||
|
elif ( self.os_type == 'linux' ):
|
||||||
|
for k in range( self.spareFiles ):
|
||||||
|
os.rename( f'{tmppath}{self.fileList[ self.threads * self.fileCount + k ] }', f'{tmppath}{ self.threads + 1 }/{self.fileList[ self.threads * self.fileCount + k ] }' )
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir( f'{tmppath}sc' )
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.pool_ss = multiprocessing.Pool( self.threads )
|
||||||
|
self.pool_ss.starmap( specialScalerEngine, self.cmdList );
|
||||||
|
self.pool_ss.close();
|
||||||
|
self.pool_ss.join();
|
||||||
|
|
||||||
|
specialScalerEngine( tmppath, t, quality_setting, model, self.os_type )
|
||||||
|
|
||||||
|
|
||||||
|
def specialScalerEngine ( tmppath, tNumber, quality_setting, model, os_type ):
|
||||||
|
if ( os_type == 'win32' ):
|
||||||
|
command = f'realesrgan-ncnn-vulkan -i {tmppath}{tNumber} -o {tmppath}sc -s {quality_setting} -n {model}'
|
||||||
|
elif ( os_type == 'linux' ):
|
||||||
|
command = f'wine ./bin/lib/realesrgan-ncnn-vulkan.exe -i {tmppath}{tNumber} -o {tmppath}sc -s {quality_setting} -n {model}'
|
||||||
|
sub = subprocess.Popen( command, shell=True );
|
||||||
|
sub.wait();
|
||||||
421
bin/handler.py
421
bin/handler.py
@@ -15,8 +15,11 @@ ffmpeg = bin.probe
|
|||||||
import configparser
|
import configparser
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import bin.engines.ss
|
||||||
import multiprocessing
|
import bin.engines.fsr
|
||||||
|
|
||||||
|
fsr = bin.engines.fsr.FSRScaler()
|
||||||
|
ss = bin.engines.ss.SpecialScaler()
|
||||||
|
|
||||||
|
|
||||||
# Loading the config file to get user preferred temp path
|
# Loading the config file to get user preferred temp path
|
||||||
@@ -131,14 +134,15 @@ class Handler:
|
|||||||
|
|
||||||
time.sleep( 2 );
|
time.sleep( 2 );
|
||||||
|
|
||||||
|
self.lastUsedPath = ''
|
||||||
|
|
||||||
if ( scalerEngine == 'fsr' or scalerEngine == 'NN' ):
|
if ( scalerEngine == 'fsr' or scalerEngine == 'NN' ):
|
||||||
self.fsrScaler( self.tmppath, filepath, threads, fsrpath, quality_setting + 'x', sharpening, scaling, filetype, scalerEngine )
|
self.lastUsedPath = fsr.fsrScaler( self.tmppath, filepath, threads, fsrpath, quality_setting + 'x', sharpening, scaling, filetype, scalerEngine )
|
||||||
elif ( scalerEngine == 'SS' ):
|
elif ( scalerEngine == 'SS' ):
|
||||||
if ( not useSpecialModeSS ):
|
if ( not useSpecialModeSS ):
|
||||||
self.superScaler( self.tmppath, threads, quality_setting, self.os_type, model )
|
self.lastUsedPath = ss.superScaler( self.tmppath, threads, quality_setting, self.os_type, model )
|
||||||
else:
|
else:
|
||||||
self.specialSuperScaler( self.tmppath, threads, quality_setting, model )
|
self.lastUsedPath = ss.specialSuperScaler( self.tmppath, threads, quality_setting, model )
|
||||||
else:
|
else:
|
||||||
raise Exception( 'ERROR upscaling. scalerEngine invalid' );
|
raise Exception( 'ERROR upscaling. scalerEngine invalid' );
|
||||||
|
|
||||||
@@ -168,7 +172,7 @@ class Handler:
|
|||||||
os.system( self.command )
|
os.system( self.command )
|
||||||
|
|
||||||
# reassemble Video
|
# reassemble Video
|
||||||
print( '\n\n==>Reassembling Video... with framerate @', self.framerate, '\n\n' )
|
print( '\n\n==> Reassembling Video... with framerate @', self.framerate, '\n\n' )
|
||||||
if self.os_type == 'linux':
|
if self.os_type == 'linux':
|
||||||
self.command = f'ffmpeg -framerate {self.framerate} -i {self.tmppath}sc/ig%08d.{filetype} {output_path} -i {self.tmppath}audio.aac'
|
self.command = f'ffmpeg -framerate {self.framerate} -i {self.tmppath}sc/ig%08d.{filetype} {output_path} -i {self.tmppath}audio.aac'
|
||||||
elif self.os_type == 'win32':
|
elif self.os_type == 'win32':
|
||||||
@@ -177,408 +181,3 @@ class Handler:
|
|||||||
print( 'OS CURRENTLY UNSUPPORTED!' );
|
print( 'OS CURRENTLY UNSUPPORTED!' );
|
||||||
return False
|
return False
|
||||||
os.system( self.command )
|
os.system( self.command )
|
||||||
|
|
||||||
|
|
||||||
def superScaler ( self, tmppath, threads, quality_setting, os_platform, model ):
|
|
||||||
print( '\n\n==> Preparing to upscale videos <==\n\n==> You will see a lot of numbers flying by showing the progress of the upscaling of each individual image.\n==> This process might take a long time, depending on the length of the video.\n\n')
|
|
||||||
time.sleep( 2 );
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.mkdir( f'{tmppath}sc' )
|
|
||||||
except FileExistsError:
|
|
||||||
pass
|
|
||||||
if ( os_platform == 'win32' ):
|
|
||||||
self.command = f'realesrgan-ncnn-vulkan -i {tmppath} -o {tmppath}sc -s {quality_setting} -j {threads}:{threads}:{threads} -n {model}'
|
|
||||||
elif ( os_platform == 'linux' ):
|
|
||||||
self.command = f'wine ./bin/lib/realesrgan-ncnn-vulkan.exe -i {tmppath} -o {tmppath}sc -s {quality_setting} -j {threads}:{threads}:{threads} -n {model}'
|
|
||||||
os.system( self.command );
|
|
||||||
|
|
||||||
|
|
||||||
def specialSuperScaler ( self, tmppath, threads, quality_setting, model ):
|
|
||||||
self.fileList = os.listdir( tmppath )
|
|
||||||
self.fileList.pop( 0 )
|
|
||||||
self.fileList.sort()
|
|
||||||
if ( threads > multiprocessing.cpu_count() * 2 ):
|
|
||||||
self.threads = multiprocessing.cpu_count() * 2;
|
|
||||||
else:
|
|
||||||
self.threads = threads
|
|
||||||
|
|
||||||
self.fileCount = len( self.fileList ) // self.threads
|
|
||||||
self.spareFiles = len( self.fileList ) % self.threads
|
|
||||||
|
|
||||||
self.cmdList = [];
|
|
||||||
|
|
||||||
for t in range( threads ):
|
|
||||||
try:
|
|
||||||
os.mkdir( f'{tmppath}{t}' )
|
|
||||||
except FileExistsError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self.base = t * self.fileCount;
|
|
||||||
if ( self.os_type == 'win32' ):
|
|
||||||
for j in range( self.fileCount ):
|
|
||||||
os.rename( f'{tmppath}{self.fileList[ self.base + j ] }', f'{tmppath}{ t }\\{self.fileList[ self.base + j ] }' )
|
|
||||||
elif ( self.os_type == 'linux' ):
|
|
||||||
for j in range( self.fileCount ):
|
|
||||||
os.rename( f'{tmppath}{self.fileList[ self.base + j ] }', f'{tmppath}{ t }/{self.fileList[ self.base + j ] }' )
|
|
||||||
|
|
||||||
self.cmdList.append( ( tmppath, t, quality_setting, model, self.os_type ) )
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.mkdir( f'{tmppath}{self.threads + 1}' )
|
|
||||||
except FileExistsError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if ( self.os_type == 'win32' ):
|
|
||||||
for k in range( self.spareFiles ):
|
|
||||||
os.rename( f'{tmppath}{self.fileList[ self.threads * self.fileCount + k ] }', f'{tmppath}{ t }\\{self.fileList[ self.threads * self.fileCount + k ] }' )
|
|
||||||
elif ( self.os_type == 'linux' ):
|
|
||||||
for k in range( self.spareFiles ):
|
|
||||||
os.rename( f'{tmppath}{self.fileList[ self.threads * self.fileCount + k ] }', f'{tmppath}{ self.threads + 1 }/{self.fileList[ self.threads * self.fileCount + k ] }' )
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.mkdir( f'{tmppath}sc' )
|
|
||||||
except FileExistsError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self.pool_ss = multiprocessing.Pool( self.threads )
|
|
||||||
self.pool_ss.starmap( specialScalerEngine, self.cmdList );
|
|
||||||
self.pool_ss.close();
|
|
||||||
self.pool_ss.join();
|
|
||||||
|
|
||||||
specialScalerEngine( tmppath, t, quality_setting, model, self.os_type )
|
|
||||||
|
|
||||||
def fsrScaler ( self, tmppath, filepath, threads, fsrpath, quality_setting, sharpening, scaling, filetype, mode ):
|
|
||||||
# Locate Images and assemble FSR-Command
|
|
||||||
self.file_list = []
|
|
||||||
self.filelist = os.listdir(tmppath)
|
|
||||||
self.filelist.pop(0)
|
|
||||||
self.filelist.sort()
|
|
||||||
self.number = 0
|
|
||||||
if sharpening != '' and sharpening != None:
|
|
||||||
for self.file in self.filelist:
|
|
||||||
self.number += 1
|
|
||||||
if ( self.os_type == 'win32' ):
|
|
||||||
self.file_list.append( f"{tmppath}{self.file} {tmppath}up\\up{str(self.number).zfill(8)}.{ filetype } " );
|
|
||||||
else:
|
|
||||||
self.file_list.append( f"{tmppath}{self.file} {tmppath}up/up{str(self.number).zfill(8)}.{ filetype } " );
|
|
||||||
try:
|
|
||||||
os.mkdir( f'{tmppath}up' )
|
|
||||||
except FileExistsError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
for self.file in self.filelist:
|
|
||||||
self.number += 1
|
|
||||||
if ( self.os_type == 'win32' ):
|
|
||||||
self.file_list.append( f"{tmppath}{self.file} {tmppath}sc\\ig{str(self.number).zfill(8)}.{ filetype } " );
|
|
||||||
else:
|
|
||||||
self.file_list.append( f"{tmppath}{self.file} {tmppath}sc/ig{str(self.number).zfill(8)}.{ filetype } " );
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.mkdir( f'{tmppath}sc' )
|
|
||||||
except FileExistsError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if ( self.os_type == 'win32' ):
|
|
||||||
self.maxlength = 8000
|
|
||||||
else:
|
|
||||||
self.maxlength = 31900
|
|
||||||
self.pos = 1
|
|
||||||
|
|
||||||
############################################
|
|
||||||
#
|
|
||||||
# Thread optimisation: Divide workload up into different threads & upscale using helper function
|
|
||||||
#
|
|
||||||
############################################
|
|
||||||
self.threads = threads
|
|
||||||
if ( threads > multiprocessing.cpu_count() ):
|
|
||||||
self.threads = multiprocessing.cpu_count();
|
|
||||||
|
|
||||||
if ( not scaling ):
|
|
||||||
engines = { 'NN': 'NearestNeighbor', 'fsr':'FidelityFX Super Resolution' }
|
|
||||||
print( f'\n\n==> Upscaling using { self.threads } threads <==\n\n' );
|
|
||||||
print( f'\n\n==> Upscaling Engine is { engines[ mode ] } <==\n\n' );
|
|
||||||
|
|
||||||
time.sleep( 2 );
|
|
||||||
|
|
||||||
self.command_list = [];
|
|
||||||
self.file_list_length = len( self.file_list );
|
|
||||||
for i in range( self.threads ):
|
|
||||||
self.files = '';
|
|
||||||
for _ in range( int( self.file_list_length // self.threads ) ):
|
|
||||||
self.files += self.file_list.pop( 0 );
|
|
||||||
|
|
||||||
if ( i == self.threads - 1 ):
|
|
||||||
for element in self.file_list:
|
|
||||||
self.files += element;
|
|
||||||
self.command_list.append( ( self.files, fsrpath, quality_setting, i, self.maxlength, self.os_type ) )
|
|
||||||
|
|
||||||
self.pool = multiprocessing.Pool( self.threads )
|
|
||||||
if ( mode == 'B' ):
|
|
||||||
self.pool.starmap( bilinearEngine, self.command_list );
|
|
||||||
elif ( mode == 'fsr' ):
|
|
||||||
self.pool.starmap( upscalerEngine, self.command_list );
|
|
||||||
self.pool.close();
|
|
||||||
self.pool.join();
|
|
||||||
|
|
||||||
if sharpening != '' and sharpening != None:
|
|
||||||
print( f'\n\n\n==> Sharpening using { self.threads } threads <==\n\n' );
|
|
||||||
time.sleep( 2 );
|
|
||||||
|
|
||||||
self.pathSharpening = tmppath
|
|
||||||
|
|
||||||
if ( not scaling ):
|
|
||||||
if ( self.os_type == 'win32' ):
|
|
||||||
self.pathSharpening += 'up\\'
|
|
||||||
elif ( self.os_type == 'linux' ):
|
|
||||||
self.pathSharpening += 'up/'
|
|
||||||
|
|
||||||
time.sleep( 2 );
|
|
||||||
try:
|
|
||||||
os.mkdir( f'{tmppath}sc' )
|
|
||||||
except FileExistsError:
|
|
||||||
pass
|
|
||||||
# Locate Images and assemble FSR-Command
|
|
||||||
self.file_list = []
|
|
||||||
self.filelist = os.listdir( self.pathSharpening )
|
|
||||||
self.filelist.pop(0)
|
|
||||||
self.filelist.sort()
|
|
||||||
self.number = 0
|
|
||||||
for self.file in self.filelist:
|
|
||||||
self.number += 1
|
|
||||||
if ( self.os_type == 'win32' ):
|
|
||||||
self.file_list.append( f"{self.pathSharpening}{self.file} {tmppath}sc\\ig{str(self.number).zfill(8)}.{ filetype } " );
|
|
||||||
else:
|
|
||||||
self.file_list.append( f"{self.pathSharpening}{self.file} {tmppath}sc/ig{str(self.number).zfill(8)}.{ filetype } " );
|
|
||||||
|
|
||||||
if ( self.os_type == 'win32' ):
|
|
||||||
self.maxlength = 8000
|
|
||||||
else:
|
|
||||||
self.maxlength = 31900
|
|
||||||
self.pos = 1
|
|
||||||
|
|
||||||
# assemble command list
|
|
||||||
self.command_list = [];
|
|
||||||
self.file_list_length = len( self.file_list );
|
|
||||||
for i in range( self.threads ):
|
|
||||||
self.files = '';
|
|
||||||
for _ in range( int( self.file_list_length // self.threads ) ):
|
|
||||||
self.files += self.file_list.pop( 0 );
|
|
||||||
|
|
||||||
if ( i == self.threads - 1 ):
|
|
||||||
for element in self.file_list:
|
|
||||||
self.files += element;
|
|
||||||
self.command_list.append( ( self.files, fsrpath, i, self.maxlength, self.os_type, sharpening, not sharpening ) )
|
|
||||||
|
|
||||||
self.pool = multiprocessing.Pool( self.threads )
|
|
||||||
self.pool.starmap( sharpeningEngine, self.command_list );
|
|
||||||
self.pool.close();
|
|
||||||
self.pool.join();
|
|
||||||
|
|
||||||
|
|
||||||
def specialScalerEngine ( tmppath, tNumber, quality_setting, model, os_type ):
|
|
||||||
if ( os_type == 'win32' ):
|
|
||||||
command = f'realesrgan-ncnn-vulkan -i {tmppath}{tNumber} -o {tmppath}sc -s {quality_setting} -n {model}'
|
|
||||||
elif ( os_type == 'linux' ):
|
|
||||||
command = f'wine ./bin/lib/realesrgan-ncnn-vulkan.exe -i {tmppath}{tNumber} -o {tmppath}sc -s {quality_setting} -n {model}'
|
|
||||||
sub = subprocess.Popen( command, shell=True );
|
|
||||||
sub.wait();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def upscalerEngine ( files, fsrpath, quality_setting, number, maxlength, os_type ):
|
|
||||||
files = files;
|
|
||||||
# Refactoring of commands that are longer than 32K characters
|
|
||||||
fileout = [];
|
|
||||||
pos = 0;
|
|
||||||
if len( files ) > maxlength:
|
|
||||||
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
file_processing = files[:maxlength - pos]
|
|
||||||
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
|
||||||
pos += 5
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
fileout.append(files[:maxlength - pos])
|
|
||||||
filesopt = files[maxlength - pos:]
|
|
||||||
posx = 0
|
|
||||||
posy = maxlength
|
|
||||||
|
|
||||||
# Command refactoring for commands that are longer than 64K characters
|
|
||||||
if len(filesopt) > maxlength:
|
|
||||||
while len(filesopt) > maxlength:
|
|
||||||
posx += maxlength - pos
|
|
||||||
posy += maxlength - pos
|
|
||||||
pos = 1
|
|
||||||
while files[posy - pos:posy - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
file_processing = files[posx:posy - pos]
|
|
||||||
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
|
||||||
pos += 5
|
|
||||||
while files[posy - pos:posy - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
|
|
||||||
file_processing = files[posx:posy - pos]
|
|
||||||
fileout.append(file_processing)
|
|
||||||
filesopt = files[posy - pos:]
|
|
||||||
fileout.append(filesopt)
|
|
||||||
else:
|
|
||||||
fileout.append(files[maxlength - pos:])
|
|
||||||
else:
|
|
||||||
fileout.append(files)
|
|
||||||
|
|
||||||
# Upscaling images
|
|
||||||
print( '\n\n\nUpscaling images... \n\n\n\n\n\n PROCESS: ', number, '\n\n\n' )
|
|
||||||
|
|
||||||
while len( fileout ) > 0:
|
|
||||||
files_handle = fileout.pop(0)
|
|
||||||
if os_type == 'linux':
|
|
||||||
command_us = f'wine {fsrpath} -Scale {quality_setting} {quality_setting} {files_handle}'
|
|
||||||
elif os_type == 'win32':
|
|
||||||
command_us = f'FidelityFX_CLI -Scale {quality_setting} {quality_setting} {files_handle}'
|
|
||||||
else:
|
|
||||||
print( 'OS CURRENTLY UNSUPPORTED!' )
|
|
||||||
return False
|
|
||||||
sub = subprocess.Popen( command_us, shell=True );
|
|
||||||
sub.wait();
|
|
||||||
time.sleep(3)
|
|
||||||
print( '\n\nCompleted executing Job\n\n\n PROCESS: ', number, '\n\n\n' );
|
|
||||||
|
|
||||||
|
|
||||||
def bilinearEngine ( files, fsrpath, quality_setting, number, maxlength, os_type, version ):
|
|
||||||
if ( version == 'HQC' ):
|
|
||||||
scaler = 'HighQualityCubic'
|
|
||||||
files = files;
|
|
||||||
# Refactoring of commands that are longer than 32K characters
|
|
||||||
fileout = [];
|
|
||||||
pos = 0;
|
|
||||||
if len( files ) > maxlength:
|
|
||||||
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
file_processing = files[:maxlength - pos]
|
|
||||||
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
|
||||||
pos += 5
|
|
||||||
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
fileout.append(files[:maxlength - pos])
|
|
||||||
filesopt = files[maxlength - pos:]
|
|
||||||
posx = 0
|
|
||||||
posy = maxlength
|
|
||||||
|
|
||||||
# Command refactoring for commands that are longer than 64K characters
|
|
||||||
if len(filesopt) > maxlength:
|
|
||||||
while len(filesopt) > maxlength:
|
|
||||||
posx += maxlength - pos
|
|
||||||
posy += maxlength - pos
|
|
||||||
pos = 1
|
|
||||||
while files[posy - pos:posy - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
file_processing = files[posx:posy - pos]
|
|
||||||
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
|
||||||
pos += 5
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
while files[posy - pos:posy - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
|
|
||||||
file_processing = files[posx:posy - pos]
|
|
||||||
fileout.append(file_processing)
|
|
||||||
filesopt = files[posy - pos:]
|
|
||||||
fileout.append(filesopt)
|
|
||||||
else:
|
|
||||||
fileout.append(files[maxlength - pos:])
|
|
||||||
else:
|
|
||||||
fileout.append(files)
|
|
||||||
|
|
||||||
# Upscaling images
|
|
||||||
print( '\n\n\nUpscaling images... \n\n\n\n\n\n PROCESS: ', number, '\n\n\n' )
|
|
||||||
|
|
||||||
while len( fileout ) > 0:
|
|
||||||
files_handle = fileout.pop(0)
|
|
||||||
if os_type == 'linux':
|
|
||||||
command_us = f'wine {fsrpath} -Mode NearestNeighbor -Scale {quality_setting} {quality_setting} {files_handle}'
|
|
||||||
elif os_type == 'win32':
|
|
||||||
command_us = f'FidelityFX_CLI -Mode NearestNeighbor -Scale {quality_setting} {quality_setting} {files_handle}'
|
|
||||||
else:
|
|
||||||
print( 'OS CURRENTLY UNSUPPORTED!' )
|
|
||||||
return False
|
|
||||||
sub = subprocess.Popen( command_us, shell=True );
|
|
||||||
sub.wait();
|
|
||||||
time.sleep(3)
|
|
||||||
print( '\n\nCompleted executing Job\n\n\n PROCESS: ', number, '\n\n\n' );
|
|
||||||
|
|
||||||
########################
|
|
||||||
#
|
|
||||||
# Sharpening
|
|
||||||
#
|
|
||||||
#######################
|
|
||||||
|
|
||||||
def sharpeningEngine ( files, fsrpath, number, maxlength, os_type, sharpening, didUpscale ):
|
|
||||||
files = files;
|
|
||||||
# Refactoring of commands that are longer than 32K characters
|
|
||||||
fileout = [];
|
|
||||||
pos = 0;
|
|
||||||
if len( files ) > maxlength:
|
|
||||||
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
file_processing = files[:maxlength - pos]
|
|
||||||
if ( didUpscale ):
|
|
||||||
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'up':
|
|
||||||
pos += 5
|
|
||||||
else:
|
|
||||||
if file_processing[len(file_processing) - 17:len(file_processing) - 15] == 'ru':
|
|
||||||
pos += 8
|
|
||||||
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
fileout.append(files[:maxlength - pos])
|
|
||||||
filesopt = files[maxlength - pos:]
|
|
||||||
posx = 0
|
|
||||||
posy = maxlength
|
|
||||||
|
|
||||||
# Command refactoring for commands that are longer than 64K characters
|
|
||||||
if len(filesopt) > maxlength:
|
|
||||||
while len(filesopt) > maxlength:
|
|
||||||
posx += maxlength - pos
|
|
||||||
posy += maxlength - pos
|
|
||||||
pos = 1
|
|
||||||
while files[posy - pos:posy - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
file_processing = files[posx:posy - pos]
|
|
||||||
if ( didUpscale ):
|
|
||||||
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'up':
|
|
||||||
pos += 5
|
|
||||||
else:
|
|
||||||
if file_processing[len(file_processing) - 17:len(file_processing) - 15] == 'ru':
|
|
||||||
pos += 8
|
|
||||||
while files[posy - pos:posy - pos + 1] != ' ':
|
|
||||||
pos += 1
|
|
||||||
|
|
||||||
file_processing = files[posx:posy - pos]
|
|
||||||
fileout.append(file_processing)
|
|
||||||
filesopt = files[posy - pos:]
|
|
||||||
fileout.append(filesopt)
|
|
||||||
else:
|
|
||||||
fileout.append(files[maxlength - pos:])
|
|
||||||
else:
|
|
||||||
fileout.append(files)
|
|
||||||
|
|
||||||
# Upscaling images
|
|
||||||
print( '\n\n\nSharpening images... \n\n\n\n\n\n PROCESS: ', number, '\n\n\n' )
|
|
||||||
|
|
||||||
while len( fileout ) > 0:
|
|
||||||
files_handle = fileout.pop(0)
|
|
||||||
print( '\n\n\n PROCESS: ', number, '\nRunning sharpening filter\n\n\n' );
|
|
||||||
if os_type == 'linux':
|
|
||||||
command_sharpening = f'wine {fsrpath} -Mode CAS -Sharpness {sharpening} {files_handle}'
|
|
||||||
elif os_type == 'win32':
|
|
||||||
command_sharpening = f'FidelityFX_CLI -Mode CAS -Sharpness {sharpening} {files_handle}'
|
|
||||||
else:
|
|
||||||
print( 'OS CURRENTLY UNSUPPORTED!' )
|
|
||||||
return False
|
|
||||||
sub2 = subprocess.Popen( command_sharpening, shell=True );
|
|
||||||
sub2.wait()
|
|
||||||
time.sleep(3)
|
|
||||||
print( '\n\nCompleted executing Job\n\n\n PROCESS: ', number, '\n\n\n' );
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,4 @@ const router = createRouter({
|
|||||||
routes
|
routes
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log( process.env.IS_ELECTRON );
|
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
Reference in New Issue
Block a user