From 1fa50afd01b61acfdefe3530807bed20101eafbf Mon Sep 17 00:00:00 2001 From: janis Date: Wed, 24 May 2023 11:06:19 +0200 Subject: [PATCH] sync - broken currently due to refactoring!! --- bin/__pycache__/handler.cpython-311.pyc | Bin 33211 -> 11004 bytes bin/arg_assembly.py | 15 - bin/checks.py | 56 ---- bin/engines/fsr.py | 339 +++++++++++++++++++ bin/engines/ss.py | 90 +++++ bin/handler.py | 425 +----------------------- frontend/src/router/index.js | 2 - 7 files changed, 441 insertions(+), 486 deletions(-) delete mode 100644 bin/arg_assembly.py delete mode 100644 bin/checks.py create mode 100644 bin/engines/fsr.py create mode 100644 bin/engines/ss.py diff --git a/bin/__pycache__/handler.cpython-311.pyc b/bin/__pycache__/handler.cpython-311.pyc index f6eb0be3623338c0d958604371746ac2af49571f..352b8fcc8a9b945b0abd6630d835e5e0974185f3 100644 GIT binary patch delta 1437 zcmZ`&T}&fI9G}_lZWrkG0}K72Y`e4+ibqfGPEU{zMMN)p90wuLf>$fE2b5A^x8@A? z0>ql&n`9omoH63X1Y>--q&{HO91m*Fn0VXT1k&V`7vqC3V9ql!Mx8A*fs>oe{$~DP zzyE*czw^bL)ZatKb)GK=WH^7EK_`V(qn$bhR~yfZG=hkVSA=Paju|uuZN&Kf6@WD( z7Oht7Y&V+2{1F!uwpj(uz=cf|kn}MNjy6}b;Yz7;?U7>8Ta}fo-#YYGL=A!fyZX5(oC!!)9a#2|(si&zrDW$GybLU*P|M{%$*^L)kkv}=L6 zGL?`#3!JBUa6B59JaP@;l&c9W;Gp?BJdeLK|HQ3SXo<=IR!3~u8FXZRwk$AbkShfu zLg{F!GE_TFX_CT{y|BNRA4_(YJjn4qIBOHjs1%ceDIId-4{Xl5!z76r66!e!9Z6Lv z!DKf8INl@RX1fL7x78fUnK-MNOJmJT*z0kp-DEz(X-b~M^L8hmv72CB=BoW026EMw~^37*=0p8{u6S6QWX4x z=OZ>u^vYP~ch4TkR2@vieX_>YsHrZz@4 zuc-aQYG_iOPGm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2GF!*N(vb*e*T!3x3(bRP#)=R-v+CqIEZO_(O2;wM4y0*YkA! zvdbg7YWUhci+g!jhv4cET^*p_qnRJteqejeG3%Id=v6D;wW^iMXRB5ki!;`tAvQcR zG$egkgPXmK4Sw&u1+>5TYXRWoPT_QS5@X;y82p)eI0FmLx02M$9T-XU&NoSlPLiTe zN>PnLX8d6YVyQ^X)rjVoh@i+6$~{B`IMW1p`U8@q^Ir{{uPyAj$v$ diff --git a/bin/arg_assembly.py b/bin/arg_assembly.py deleted file mode 100644 index ddbb568..0000000 --- a/bin/arg_assembly.py +++ /dev/null @@ -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 diff --git a/bin/checks.py b/bin/checks.py deleted file mode 100644 index 7556a6a..0000000 --- a/bin/checks.py +++ /dev/null @@ -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 diff --git a/bin/engines/fsr.py b/bin/engines/fsr.py new file mode 100644 index 0000000..551a921 --- /dev/null +++ b/bin/engines/fsr.py @@ -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' ); + diff --git a/bin/engines/ss.py b/bin/engines/ss.py new file mode 100644 index 0000000..ad767d1 --- /dev/null +++ b/bin/engines/ss.py @@ -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(); \ No newline at end of file diff --git a/bin/handler.py b/bin/handler.py index a452984..315e7d6 100644 --- a/bin/handler.py +++ b/bin/handler.py @@ -15,8 +15,11 @@ ffmpeg = bin.probe import configparser import time import shutil -import subprocess -import multiprocessing +import bin.engines.ss +import bin.engines.fsr + +fsr = bin.engines.fsr.FSRScaler() +ss = bin.engines.ss.SpecialScaler() # Loading the config file to get user preferred temp path @@ -131,14 +134,15 @@ class Handler: time.sleep( 2 ); + self.lastUsedPath = '' 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' ): if ( not useSpecialModeSS ): - self.superScaler( self.tmppath, threads, quality_setting, self.os_type, model ) - else: - self.specialSuperScaler( self.tmppath, threads, quality_setting, model ) + self.lastUsedPath = ss.superScaler( self.tmppath, threads, quality_setting, self.os_type, model ) + else: + self.lastUsedPath = ss.specialSuperScaler( self.tmppath, threads, quality_setting, model ) else: raise Exception( 'ERROR upscaling. scalerEngine invalid' ); @@ -168,7 +172,7 @@ class Handler: os.system( self.command ) # 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': 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': @@ -176,409 +180,4 @@ class Handler: else: print( 'OS CURRENTLY UNSUPPORTED!' ); return False - 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' ); - + os.system( self.command ) \ No newline at end of file diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index e50c1ab..918817f 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -22,6 +22,4 @@ const router = createRouter({ routes }) -console.log( process.env.IS_ELECTRON ); - export default router