diff --git a/bin/__pycache__/handler.cpython-311.pyc b/bin/__pycache__/handler.cpython-311.pyc index cbbd6d8..74ada87 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 2fca37d..bdb75f5 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 8cac029..0c793e3 100644 --- a/bin/handler.py +++ b/bin/handler.py @@ -35,7 +35,7 @@ class Handler: # TODO: CHECK if this upscaler is any good: https://github.com/Maximellerbach/Image-Processing-using-AI (looks quite promising) - def handler(self, fsrpath, filepath, quality_setting, output_path, sharpening, scaling, filetype, scalerEngine, model, threads=4 ): + def handler(self, fsrpath, filepath, quality_setting, output_path, sharpening, scaling, filetype, scalerEngine, model, useSpecialModeSS, threads=4 ): # Function to be called when using this class as this function automatically determines if file is video or image print( '\n\nFSRImageVideoUpscalerFrontend - V1.1.0\n\nCopyright 2023 FSRImageVideoUpscalerFrontend contributors\n\n\n\n' ); @@ -64,7 +64,7 @@ class Handler: # Determining filetype if str(filepath)[len(filepath) - 4:] == ".mp4" or str(filepath)[len(filepath) - 4:] == ".mkv" or str(filepath)[len(filepath) - 4:] == ".MP4": print( '\n\n==> Upscaling video' ) - self.video_scaling( fsrpath, filepath, quality_setting, output_path, threads, sharpening, scaling, filetype, scalerEngine, model ) + self.video_scaling( fsrpath, filepath, quality_setting, output_path, threads, sharpening, scaling, filetype, scalerEngine, model, useSpecialModeSS ) elif str(filepath)[len(filepath) - 4:] == ".JPG" or str(filepath)[len(filepath) - 4:] == ".png" or str(filepath)[len(filepath) - 4:] == ".jpg" or str(filepath)[len(filepath) - 5:] == ".jpeg": print( '\n==>upscaling image' ) self.photo_scaling(fsrpath, filepath, quality_setting, output_path) @@ -85,7 +85,7 @@ class Handler: os.system(self.command) print( '\n\n==>Photo upscaled' ); - def video_scaling( self, fsrpath, filepath, quality_setting, output_path, threads, sharpening, scaling, filetype, scalerEngine, model ): + def video_scaling( self, fsrpath, filepath, quality_setting, output_path, threads, sharpening, scaling, filetype, scalerEngine, model, useSpecialModeSS ): # DO NOT CALL THIS! Use Handler().handler() instead! # Splitting video into frames @@ -135,7 +135,10 @@ class Handler: if ( scalerEngine == 'fsr' ): self.fsrScaler( self.tmppath, filepath, threads, fsrpath, quality_setting + 'x', sharpening, scaling, filetype ) elif ( scalerEngine == 'SS' ): - self.superScaler( self.tmppath, threads, quality_setting, self.os_type, model ) + if ( not useSpecialModeSS ): + self.superScaler( self.tmppath, threads, quality_setting, self.os_type, model ) + else: + self.specialSuperScaler( ) else: raise Exception( 'ERROR upscaling. scalerEngine invalid' ); @@ -191,6 +194,10 @@ class Handler: os.system( self.command ); + def specialSuperScaler (): + pass + + def fsrScaler ( self, tmppath, filepath, threads, fsrpath, quality_setting, sharpening, scaling, filetype ): # Locate Images and assemble FSR-Command self.file_list = [] diff --git a/imagevideoupscaler-cli.py b/imagevideoupscaler-cli.py index 6bea216..5cf5177 100644 --- a/imagevideoupscaler-cli.py +++ b/imagevideoupscaler-cli.py @@ -22,6 +22,7 @@ if __name__ == '__main__': ap.add_argument( '-F', '--filetype', help='Change the file type of the temporary image files. Supports png, jpg. Video quality: png > jpg. Png is default, if not specified.' ) ap.add_argument( '-S', '--sharpening', help='Sharpening factor (between 0 and 1 whereas 0 means no sharpening, 1 the most sharpening. Recommendation: Do not exceed 0.25, as it often looks bad)' ) ap.add_argument( '-N', '--noscaling', help='Do not upscale video, instead only sharpen. Sharpening argument required!', action='store_true' ) + ap.add_argument( '-t', '--threading', help='Use special threading mode with SS scaler (spawns 16 threads upscaling at one time)', action='store_true' ) ap.add_argument( '-T', '--threads', help='Thread count to use. Cannot exceed CPU thread count. Scaling non-linear (using 2 threads is not exactly 2x the speed of 1 thread). Scales well with FSR, barely with Real-ESRGAN, as it uses mostly the GPU to upscale' ) ap.add_argument( '-E', '--engine', help='Upscaling engine. Can be fsr or SS (for Real-ESRGAN). FSR tends to be lower quality, but faster, Real-ESRGAN is meant for anime. Defaults to fsr' ) ap.add_argument( '-M', '--model', help='Only available if using Real-ESRGAN. Change the ML-Model used to upsample video, can be: realesr-animevideov3 | realesrgan-x4plus-anime , defaults to realesr-animevideov3' ) @@ -32,6 +33,7 @@ if __name__ == '__main__': go = True; go2 = True; go3 = True; + specialMode = False; engine = 'fsr'; model = 'realesr-animevideov3'; availableModels = [ 'realesr-animevideov3', 'realesrgan-x4plus-anime' ]; @@ -79,25 +81,27 @@ if __name__ == '__main__': if ( args.filetype in allowedFiletypes ): filetype = args.filetype else: - g3o = False + go3 = False print( 'Invalid filetype for temp images specified. Please ensure to only use png or jpg!' ); else: filetype = 'png' + specialMode = args.threading; + if ( go and go2 and go3 ): if ( args.scalefactor ): if ( int( args.scalefactor ) ): if ( args.threads != None ): - handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, args.scalefactor, args.outputfile, args.sharpening, args.noscaling, filetype, engine, model, threads=int( args.threads ) ); + handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, args.scalefactor, args.outputfile, args.sharpening, args.noscaling, filetype, engine, model, specialMode, threads=int( args.threads ) ); else: - handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, args.scalefactor, args.outputfile, args.sharpening, args.noscaling, filetype, engine, model ); + handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, args.scalefactor, args.outputfile, args.sharpening, args.noscaling, filetype, engine, model, specialMode ); else: raise NameError( 'Argument Scale does require to be an integer!' ) else: if ( args.threads != None ): - handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, '2', args.outputfile, args.sharpening, args.noscaling, filetype, engine, model, threads=int( args.threads ) ); + handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, '2', args.outputfile, args.sharpening, args.noscaling, filetype, engine, model, specialMode, threads=int( args.threads ) ); else: - handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, '2', args.outputfile, args.sharpening, args.noscaling, filetype, engine, model ) + handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, '2', args.outputfile, args.sharpening, args.noscaling, filetype, engine, model, specialMode ) print( '\n\n---------------------------------------------------------------------------------\n\nDONE \n\n\n\nImageVideoUpscalerFrontend V1.1.0\n\nCopyright 2023 FSRImageVideoUpscalerFrontend contributors\nThis application comes with absolutely no warranty to the extent permitted by applicable law\n\n\n\nYour video was saved to ' + args.outputfile + '\n\n\n' )