From 01105d33e6952ded51df67d99d132e66e2482c41 Mon Sep 17 00:00:00 2001 From: janis Date: Tue, 16 May 2023 08:47:29 +0200 Subject: [PATCH] preparations for new threading mode for SS --- bin/__pycache__/handler.cpython-311.pyc | Bin 23791 -> 24051 bytes bin/__pycache__/probe.cpython-311.pyc | Bin 3781 -> 3777 bytes bin/handler.py | 15 +++++++++++---- imagevideoupscaler-cli.py | 14 +++++++++----- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/bin/__pycache__/handler.cpython-311.pyc b/bin/__pycache__/handler.cpython-311.pyc index cbbd6d81f96bd7b956ee5443df5a71a3644fdafc..74ada87e1d4123c94a4fc88e9f2f276e3b60b884 100644 GIT binary patch delta 1304 zcmZwGZ%i9y7y$71z3U&^>(MK8Ls)1#dJNjKN*R>_i(5OV6f+!F<^m#VdhG^OV0U0l zb07ROm+1tj&xd`5#JHGgf}WbGA7*0IElvY-$rhr~Pr76uRsxBMAB^vFUo3py z=bra{dhgx;g06iOb>Nef3SLhDi`MyBNW#JS1 zEYGISIr9N&M$4tAa@o;L;pn82OQ%=t)2Gy2M$t4ETR#9)2;26sNSiZaf}4{|ggnKK zaI1uf8E)N_b+LGh#;};;>636ty3Uq4?eWrojI*9UtUHeB4yAsaW9f+6tqYp0lX*WZ z#H!&!O)DqsuzP=#Wx_pu*!ZUAKBWz?>hZ$&wL#io+^hY}LW8j23(u4B#cCm7Gy7Dv%R;86lf0V$9wlQKL`{Me3emVX?X=Goci6YE+w<%BksWhQ*&7S3`?*lns|J$|9cq z)@+Q6L?P__(7q3dI?URtgj6B}jAC6m=jK2AAoaIwT(dJ?CU+`a=Pc%<#zf>LkyY~N z{$9!4{}D{}IFf=yXF_;TPZVZ58*Llq!j;Yi8im2G##P^L1Pd(-j_a$-RF=ukT)6ImfOD4 z#(|&1nd8XY$OYsb7ZvwwZ-s0v>` G7ylQLnL(2P delta 1154 zcmZwFSxgf_7y#gz-5zwi3vD2PgmSeQixg2#!APJYRS-oK73xvh7LDa_3Yut*;GHO5 z|ARhgB8g{w!EAU?6UC?x8jVFwG#Xzt@y&>_iN?gl`HLbLH|^Jd{^|bz?96_>O+VkH z@mCZ@BK(T>Z&q))Z^XZ#$;EtlhWJSoUmLVR(IM*R^io2gswE8~hHR@8)`tyYV>m8sy38A2mo%Mm zP^4x!Ed>-~?-u6wsi6?ogH&^#!OnxwVa;Ps5NuxvQI-qQnB)Jd?N*kE)B_JKkEX2# zE5%k5(Jop)>aFv`Ce^l0;90^PVR9i8PI;1{EyWC@DLG<7Z?%??`kB&fxR;m&iD`D4 zt(B#X=x7dn%5c&mNXaar#juQ94*N5G@I5n;FTUS0!_Hh-a~9%6@{rj`K4;>Q8ng0^ zt8o<7YXezP!7f`~$?4DK^t0-@;MKa}jic&=U}V+0F}dxf+!l#_v=Muf=y+1OU|BhN zT3%hbyi|NvLb;LnxlM$O5vfTL$7I^1XrE?o5NHK7I0p(>U}HW_SP@c#xDh;UhDYo) zFa=}WA?AXg&e>_rJlvJ&@pY*|KPw3J_4rwHyN}1iT20d-_?dHOO4b7uWRy(3$UI8 z!NX^`CWiN2Bg}$vJfizUIuAm7V4>SaW$?NkIcuptXPiuNhal_i<7AQy?S|WAv=m~6 zxkxfH4<0Y|m{kmIhzD%-w&KZMbSAJ)Oy?pqk&4)16zas?!I2u0bTX&62l23 zUwd2sPBQPsaX&Hu_gjkSKKRyBMhjuin#Sh+m_CRcLJo7LwVU2);te~B|Lj1HA%nqdr+2pIWI340}$vc3UA~-#ms0w`5Lp)W*(NETmX8h2ju_& delta 36 qcmX>odsLQtIWI340}w=AR@}&aikZ=Q@-=27mUzF^^35D9JGlV5p$cCB 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' )