diff --git a/bin/__pycache__/handler.cpython-311.pyc b/bin/__pycache__/handler.cpython-311.pyc index 74ada87..2de20d8 100644 Binary files a/bin/__pycache__/handler.cpython-311.pyc and b/bin/__pycache__/handler.cpython-311.pyc differ diff --git a/bin/__pycache__/probe.cpython-311.pyc b/bin/__pycache__/probe.cpython-311.pyc index bdb75f5..2fca37d 100644 Binary files a/bin/__pycache__/probe.cpython-311.pyc and b/bin/__pycache__/probe.cpython-311.pyc differ diff --git a/bin/handler.py b/bin/handler.py index 0c793e3..d1c5392 100644 --- a/bin/handler.py +++ b/bin/handler.py @@ -17,7 +17,6 @@ import time import shutil import subprocess import multiprocessing -import itertools # Loading the config file to get user preferred temp path @@ -138,7 +137,7 @@ class Handler: if ( not useSpecialModeSS ): self.superScaler( self.tmppath, threads, quality_setting, self.os_type, model ) else: - self.specialSuperScaler( ) + self.specialSuperScaler( self.tmppath, threads, quality_setting, model ) else: raise Exception( 'ERROR upscaling. scalerEngine invalid' ); @@ -194,9 +193,62 @@ class Handler: os.system( self.command ); - def specialSuperScaler (): - pass + 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; + print( self.base ); + 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 ) ) + + print( self.threads * self.fileCount ); + + 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 ): # Locate Images and assemble FSR-Command @@ -306,6 +358,15 @@ class Handler: 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; diff --git a/imagevideoupscaler-cli.py b/imagevideoupscaler-cli.py index 5cf5177..e579b2d 100644 --- a/imagevideoupscaler-cli.py +++ b/imagevideoupscaler-cli.py @@ -59,7 +59,7 @@ if __name__ == '__main__': if ( args.model in availableModels ): model = args.model; else: - print( 'Invalid argument for model. Can be: realesr-animevideov3 | realesrgan-x4plus | realesrgan-x4plus-anime | realesrnet-x4plus' ) + print( 'Invalid argument for model. Can be: realesr-animevideov3 | realesrgan-x4plus-anime' ) go2 = False; if ( args.noscaling ): @@ -74,7 +74,7 @@ if __name__ == '__main__': if ( args.sharpening != None ): if ( float( args.sharpening ) > 1 ): - print( 'Invalid argument for Sharpening, please specify value between 0 and 1!' ) + print( 'Invalid argument for Sharpening, please specify a value between 0 and 1!' ) go3 = False; if ( args.filetype != None ):