preparations for new threading mode for SS
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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)
|
# 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
|
# 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' );
|
print( '\n\nFSRImageVideoUpscalerFrontend - V1.1.0\n\nCopyright 2023 FSRImageVideoUpscalerFrontend contributors\n\n\n\n' );
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class Handler:
|
|||||||
# Determining filetype
|
# Determining filetype
|
||||||
if str(filepath)[len(filepath) - 4:] == ".mp4" or str(filepath)[len(filepath) - 4:] == ".mkv" or str(filepath)[len(filepath) - 4:] == ".MP4":
|
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' )
|
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":
|
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' )
|
print( '\n==>upscaling image' )
|
||||||
self.photo_scaling(fsrpath, filepath, quality_setting, output_path)
|
self.photo_scaling(fsrpath, filepath, quality_setting, output_path)
|
||||||
@@ -85,7 +85,7 @@ class Handler:
|
|||||||
os.system(self.command)
|
os.system(self.command)
|
||||||
print( '\n\n==>Photo upscaled' );
|
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!
|
# DO NOT CALL THIS! Use Handler().handler() instead!
|
||||||
|
|
||||||
# Splitting video into frames
|
# Splitting video into frames
|
||||||
@@ -135,7 +135,10 @@ class Handler:
|
|||||||
if ( scalerEngine == 'fsr' ):
|
if ( scalerEngine == 'fsr' ):
|
||||||
self.fsrScaler( self.tmppath, filepath, threads, fsrpath, quality_setting + 'x', sharpening, scaling, filetype )
|
self.fsrScaler( self.tmppath, filepath, threads, fsrpath, quality_setting + 'x', sharpening, scaling, filetype )
|
||||||
elif ( scalerEngine == 'SS' ):
|
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:
|
else:
|
||||||
raise Exception( 'ERROR upscaling. scalerEngine invalid' );
|
raise Exception( 'ERROR upscaling. scalerEngine invalid' );
|
||||||
|
|
||||||
@@ -191,6 +194,10 @@ class Handler:
|
|||||||
os.system( self.command );
|
os.system( self.command );
|
||||||
|
|
||||||
|
|
||||||
|
def specialSuperScaler ():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def fsrScaler ( self, tmppath, filepath, threads, fsrpath, quality_setting, sharpening, scaling, filetype ):
|
def fsrScaler ( self, tmppath, filepath, threads, fsrpath, quality_setting, sharpening, scaling, filetype ):
|
||||||
# Locate Images and assemble FSR-Command
|
# Locate Images and assemble FSR-Command
|
||||||
self.file_list = []
|
self.file_list = []
|
||||||
|
|||||||
@@ -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( '-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( '-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( '-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( '-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( '-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' )
|
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;
|
go = True;
|
||||||
go2 = True;
|
go2 = True;
|
||||||
go3 = True;
|
go3 = True;
|
||||||
|
specialMode = False;
|
||||||
engine = 'fsr';
|
engine = 'fsr';
|
||||||
model = 'realesr-animevideov3';
|
model = 'realesr-animevideov3';
|
||||||
availableModels = [ 'realesr-animevideov3', 'realesrgan-x4plus-anime' ];
|
availableModels = [ 'realesr-animevideov3', 'realesrgan-x4plus-anime' ];
|
||||||
@@ -79,25 +81,27 @@ if __name__ == '__main__':
|
|||||||
if ( args.filetype in allowedFiletypes ):
|
if ( args.filetype in allowedFiletypes ):
|
||||||
filetype = args.filetype
|
filetype = args.filetype
|
||||||
else:
|
else:
|
||||||
g3o = False
|
go3 = False
|
||||||
print( 'Invalid filetype for temp images specified. Please ensure to only use png or jpg!' );
|
print( 'Invalid filetype for temp images specified. Please ensure to only use png or jpg!' );
|
||||||
else:
|
else:
|
||||||
filetype = 'png'
|
filetype = 'png'
|
||||||
|
|
||||||
|
specialMode = args.threading;
|
||||||
|
|
||||||
|
|
||||||
if ( go and go2 and go3 ):
|
if ( go and go2 and go3 ):
|
||||||
if ( args.scalefactor ):
|
if ( args.scalefactor ):
|
||||||
if ( int( args.scalefactor ) ):
|
if ( int( args.scalefactor ) ):
|
||||||
if ( args.threads != None ):
|
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:
|
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:
|
else:
|
||||||
raise NameError( 'Argument Scale does require to be an integer!' )
|
raise NameError( 'Argument Scale does require to be an integer!' )
|
||||||
else:
|
else:
|
||||||
if ( args.threads != None ):
|
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:
|
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' )
|
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' )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user