diff --git a/bin/__pycache__/handler.cpython-311.pyc b/bin/__pycache__/handler.cpython-311.pyc index 352b8fc..97e96ea 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/engines/fsr.py b/bin/engines/fsr.py index 551a921..b55c1b7 100644 --- a/bin/engines/fsr.py +++ b/bin/engines/fsr.py @@ -58,9 +58,9 @@ class FSRScaler: self.threads = multiprocessing.cpu_count(); if ( not scaling ): - engines = { 'NN': 'NearestNeighbor', 'fsr':'FidelityFX Super Resolution' } + engines = { 'c': 'Cubic', 'hqc': 'High Quality Cubic', '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' ); + print( f'\n\n==> Upscaling Engine is { engines[ mode.lower() ] } <==\n\n' ); time.sleep( 2 ); @@ -74,13 +74,10 @@ class FSRScaler: 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.command_list.append( ( self.files, fsrpath, quality_setting, i, self.maxlength, self.os_type, mode ) ) 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.starmap( upscalerEngine, self.command_list ); self.pool.close(); self.pool.join(); @@ -140,8 +137,12 @@ class FSRScaler: # Add return values - -def upscalerEngine ( files, fsrpath, quality_setting, number, maxlength, os_type ): +def upscalerEngine ( files, fsrpath, quality_setting, number, maxlength, os_type, version ): + scaler = 'FSR' + if ( version.upper() == 'HQC' ): + scaler = 'HighQualityCubic' + elif ( version.upper() == 'C' ): + scaler = 'Cubic' files = files; # Refactoring of commands that are longer than 32K characters fileout = []; @@ -190,9 +191,9 @@ def upscalerEngine ( files, fsrpath, quality_setting, number, maxlength, os_type 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}' + command_us = f'wine {fsrpath} -Mode { scaler } -Scale {quality_setting} {quality_setting} {files_handle}' elif os_type == 'win32': - command_us = f'FidelityFX_CLI -Scale {quality_setting} {quality_setting} {files_handle}' + command_us = f'FidelityFX_CLI -Mode { scaler } -Scale {quality_setting} {quality_setting} {files_handle}' else: print( 'OS CURRENTLY UNSUPPORTED!' ) return False @@ -202,68 +203,6 @@ def upscalerEngine ( files, fsrpath, quality_setting, number, maxlength, os_type 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 diff --git a/bin/handler.py b/bin/handler.py index 315e7d6..10eacbc 100644 --- a/bin/handler.py +++ b/bin/handler.py @@ -136,9 +136,9 @@ class Handler: self.lastUsedPath = '' - if ( scalerEngine == 'fsr' or scalerEngine == 'NN' ): + if ( scalerEngine.lower() == 'fsr' or scalerEngine.lower() == 'c' or scalerEngine.lower() == 'hqc' ): self.lastUsedPath = fsr.fsrScaler( self.tmppath, filepath, threads, fsrpath, quality_setting + 'x', sharpening, scaling, filetype, scalerEngine ) - elif ( scalerEngine == 'SS' ): + elif ( scalerEngine.upper() == 'SS' ): if ( not useSpecialModeSS ): self.lastUsedPath = ss.superScaler( self.tmppath, threads, quality_setting, self.os_type, model ) else: diff --git a/imagevideoupscaler-cli.py b/imagevideoupscaler-cli.py index d285aeb..ddff270 100644 --- a/imagevideoupscaler-cli.py +++ b/imagevideoupscaler-cli.py @@ -49,7 +49,7 @@ if __name__ == '__main__': go = False if ( args.engine != None ): - if ( args.engine == 'fsr' or args.engine == 'SS' or args.engine == 'NN' ): + if ( args.engine == 'fsr' or args.engine == 'SS' or args.engine.lower() == 'c' or args.engine.lower() == 'hqc' ): engine = args.engine; else: print( 'Invalid argument for engine' ) diff --git a/website/plugins.md b/website/plugins.md new file mode 100644 index 0000000..2183845 --- /dev/null +++ b/website/plugins.md @@ -0,0 +1,11 @@ +# Writing plugins for ImageVideoUpscaler + +Your plugin has to fulfill the following requirements: +- Name of class it exposes has to be [name of engine]Scaler. The name of the file should be just the name of the engine in all lower case. +- It has to support a folder or an individual file as an input and the function, has to take the following arguments: + +Argument | Variable type +---------|--------------- +x | y + +- The function has to return the path to the folder where the final resulting images are located. \ No newline at end of file