sharpening fixed

This commit is contained in:
2023-03-29 20:52:43 +02:00
parent 4b4dc46ebb
commit bdbfc9a8ce
5 changed files with 197 additions and 66 deletions

View File

@@ -12,11 +12,14 @@ import bin.handler
import os
import multiprocessing
allowedFiletypes = [ 'bmp', 'png', 'jpg' ];
if __name__ == '__main__':
ap = argparse.ArgumentParser( description='FSRImageVideoUpscaler - CLI, a CLI application to upscale videos and images using FSR. ' )
ap = argparse.ArgumentParser( description='FSRImageVideoUpscaler - CLI, a CLI application to upscale videos and images using FSR.' )
ap.add_argument( 'inputfile', help='File path for the video / image to be upscaled' )
ap.add_argument( 'outputfile', help='File path for the video / image that was upscaled' )
ap.add_argument( '-s', '--scalefactor', help='Scale factor for the video / image' )
ap.add_argument( '-F', '--filetype', help='Change the file type of the temporary image files. Supports bmp, png, jpg. Video quality: bmp > png > jpg. Only use bmp for short videos only, or on high end, high-capacity SSDs, as it uses lots of storage space! png is default, if not specified.' )
ap.add_argument( '-S', '--sharpening', help='Sharpening factor (between 0 and 1 wheras 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', '--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)' )
@@ -25,6 +28,8 @@ if __name__ == '__main__':
handler = bin.handler.Handler()
go = True;
go2 = True;
go3 = True;
multiprocessing.freeze_support();
if ( os.path.exists( args.outputfile ) ):
@@ -38,32 +43,41 @@ if __name__ == '__main__':
if ( args.noscaling ):
if ( args.sharpening != None ):
if ( float( args.sharpening ) > 0 ):
go = True;
go2 = True;
else:
go = False;
go2 = False;
else:
print( 'Missing argument for Sharpening. Please specify that argument and try again!' )
go = False;
go2 = False;
if ( args.sharpening != None ):
if ( float( args.sharpening ) > 1 ):
print( 'Invalid argument for Sharpening, please specify value between 0 and 1!' )
go = False;
go3 = False;
if ( args.filetype != None ):
if ( args.filetype in allowedFiletypes ):
filetype = args.filetype
else:
g3o = False
print( 'Invalid filetype for temp images specified. Please ensure to only use png, bmp or jpg!' );
else:
filetype = 'png'
if ( go ):
if ( go and go2 and go3 ):
if ( args.scalefactor ):
if ( args.scalefactor[ len(args.scalefactor) -1: ] == 'x' ):
if ( args.threads != None ):
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', args.scalefactor, args.outputfile, args.sharpening, args.noscaling, threads=int( args.threads ) );
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', args.scalefactor, args.outputfile, args.sharpening, args.noscaling, filetype, threads=int( args.threads ) );
else:
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', args.scalefactor, args.outputfile, args.sharpening, args.noscaling );
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', args.scalefactor, args.outputfile, args.sharpening, args.noscaling, filetype );
else:
raise NameError( 'Argument Scale does require to be of form 2x! (it has to end in x)' )
else:
if ( args.threads != None ):
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', '2x', args.outputfile, args.sharpening, args.noscaling, threads=int( args.threads ) );
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', '2x', args.outputfile, args.sharpening, args.noscaling, filetype, threads=int( args.threads ) );
else:
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', '2x', args.outputfile, args.sharpening, args.noscaling )
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', '2x', args.outputfile, args.sharpening, args.noscaling, filetype )
print( '\n\n---------------------------------------------------------------------------------\n\nDONE \n\nFSRImageVideoUpscalerFrontend V1.1.0\n\nCopyright 2023 FSRImageVideoUpscalerFrontend contributors\nThis application comes with absolutely no warranty to the extent permitted by applicable law\n\n' )