add documentation for plugins & refactor more
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -58,9 +58,9 @@ class FSRScaler:
|
|||||||
self.threads = multiprocessing.cpu_count();
|
self.threads = multiprocessing.cpu_count();
|
||||||
|
|
||||||
if ( not scaling ):
|
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 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 );
|
time.sleep( 2 );
|
||||||
|
|
||||||
@@ -74,12 +74,9 @@ class FSRScaler:
|
|||||||
if ( i == self.threads - 1 ):
|
if ( i == self.threads - 1 ):
|
||||||
for element in self.file_list:
|
for element in self.file_list:
|
||||||
self.files += element;
|
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 )
|
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.close();
|
||||||
self.pool.join();
|
self.pool.join();
|
||||||
@@ -140,71 +137,12 @@ class FSRScaler:
|
|||||||
|
|
||||||
# Add return values
|
# Add return values
|
||||||
|
|
||||||
|
def upscalerEngine ( files, fsrpath, quality_setting, number, maxlength, os_type, version ):
|
||||||
def upscalerEngine ( files, fsrpath, quality_setting, number, maxlength, os_type ):
|
scaler = 'FSR'
|
||||||
files = files;
|
if ( version.upper() == 'HQC' ):
|
||||||
# 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
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
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
|
|
||||||
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} -Scale {quality_setting} {quality_setting} {files_handle}'
|
|
||||||
elif os_type == 'win32':
|
|
||||||
command_us = f'FidelityFX_CLI -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' );
|
|
||||||
|
|
||||||
|
|
||||||
def bilinearEngine ( files, fsrpath, quality_setting, number, maxlength, os_type, version ):
|
|
||||||
if ( version == 'HQC' ):
|
|
||||||
scaler = 'HighQualityCubic'
|
scaler = 'HighQualityCubic'
|
||||||
|
elif ( version.upper() == 'C' ):
|
||||||
|
scaler = 'Cubic'
|
||||||
files = files;
|
files = files;
|
||||||
# Refactoring of commands that are longer than 32K characters
|
# Refactoring of commands that are longer than 32K characters
|
||||||
fileout = [];
|
fileout = [];
|
||||||
@@ -215,6 +153,8 @@ def bilinearEngine ( files, fsrpath, quality_setting, number, maxlength, os_type
|
|||||||
file_processing = files[:maxlength - pos]
|
file_processing = files[:maxlength - pos]
|
||||||
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
||||||
pos += 5
|
pos += 5
|
||||||
|
else:
|
||||||
|
pass
|
||||||
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
while files[maxlength - pos:maxlength - pos + 1] != ' ':
|
||||||
pos += 1
|
pos += 1
|
||||||
fileout.append(files[:maxlength - pos])
|
fileout.append(files[:maxlength - pos])
|
||||||
@@ -233,8 +173,6 @@ def bilinearEngine ( files, fsrpath, quality_setting, number, maxlength, os_type
|
|||||||
file_processing = files[posx:posy - pos]
|
file_processing = files[posx:posy - pos]
|
||||||
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ig':
|
||||||
pos += 5
|
pos += 5
|
||||||
else:
|
|
||||||
pass
|
|
||||||
while files[posy - pos:posy - pos + 1] != ' ':
|
while files[posy - pos:posy - pos + 1] != ' ':
|
||||||
pos += 1
|
pos += 1
|
||||||
|
|
||||||
@@ -253,9 +191,9 @@ def bilinearEngine ( files, fsrpath, quality_setting, number, maxlength, os_type
|
|||||||
while len( fileout ) > 0:
|
while len( fileout ) > 0:
|
||||||
files_handle = fileout.pop(0)
|
files_handle = fileout.pop(0)
|
||||||
if os_type == 'linux':
|
if os_type == 'linux':
|
||||||
command_us = f'wine {fsrpath} -Mode NearestNeighbor -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':
|
elif os_type == 'win32':
|
||||||
command_us = f'FidelityFX_CLI -Mode NearestNeighbor -Scale {quality_setting} {quality_setting} {files_handle}'
|
command_us = f'FidelityFX_CLI -Mode { scaler } -Scale {quality_setting} {quality_setting} {files_handle}'
|
||||||
else:
|
else:
|
||||||
print( 'OS CURRENTLY UNSUPPORTED!' )
|
print( 'OS CURRENTLY UNSUPPORTED!' )
|
||||||
return False
|
return False
|
||||||
@@ -264,6 +202,7 @@ def bilinearEngine ( files, fsrpath, quality_setting, number, maxlength, os_type
|
|||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
print( '\n\nCompleted executing Job\n\n\n PROCESS: ', number, '\n\n\n' );
|
print( '\n\nCompleted executing Job\n\n\n PROCESS: ', number, '\n\n\n' );
|
||||||
|
|
||||||
|
|
||||||
########################
|
########################
|
||||||
#
|
#
|
||||||
# Sharpening
|
# Sharpening
|
||||||
|
|||||||
@@ -136,9 +136,9 @@ class Handler:
|
|||||||
|
|
||||||
self.lastUsedPath = ''
|
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 )
|
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 ):
|
if ( not useSpecialModeSS ):
|
||||||
self.lastUsedPath = ss.superScaler( self.tmppath, threads, quality_setting, self.os_type, model )
|
self.lastUsedPath = ss.superScaler( self.tmppath, threads, quality_setting, self.os_type, model )
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ if __name__ == '__main__':
|
|||||||
go = False
|
go = False
|
||||||
|
|
||||||
if ( args.engine != None ):
|
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;
|
engine = args.engine;
|
||||||
else:
|
else:
|
||||||
print( 'Invalid argument for engine' )
|
print( 'Invalid argument for engine' )
|
||||||
|
|||||||
11
website/plugins.md
Normal file
11
website/plugins.md
Normal file
@@ -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.
|
||||||
Reference in New Issue
Block a user