@ -17,12 +17,10 @@ class Script(scripts.Script):
return is_img2img
return is_img2img
def ui ( self , is_img2img ) :
def ui ( self , is_img2img ) :
info = gr . HTML (
info = gr . HTML ( " <p style= \" margin-bottom:0.75em \" >Will upscale the image by the selected scale factor; use width and height sliders to set tile size</p> " )
" <p style= \" margin-bottom:0.75em \" >Will upscale the image by the selected scale factor; use width and height sliders to set tile size</p> " )
overlap = gr . Slider ( minimum = 0 , maximum = 256 , step = 16 , label = ' Tile overlap ' , value = 64 )
overlap = gr . Slider ( minimum = 0 , maximum = 256 , step = 16 , label = ' Tile overlap ' , value = 64 )
scale_factor = gr . Slider ( minimum = 0 , maximum = 4 , step = 1 , label = ' Scale Factor ' , value = 2 )
scale_factor = gr . Slider ( minimum = 0 , maximum = 4 , step = 1 , label = ' Scale Factor ' , value = 2 )
upscaler_index = gr . Radio ( label = ' Upscaler ' , choices = [ x . name for x in shared . sd_upscalers ] ,
upscaler_index = gr . Radio ( label = ' Upscaler ' , choices = [ x . name for x in shared . sd_upscalers ] , value = shared . sd_upscalers [ 0 ] . name , type = " index " )
value = shared . sd_upscalers [ 0 ] . name , type = " index " )
return [ info , overlap , upscaler_index , scale_factor ]
return [ info , overlap , upscaler_index , scale_factor ]
@ -62,8 +60,7 @@ class Script(scripts.Script):
batch_count = math . ceil ( len ( work ) / batch_size )
batch_count = math . ceil ( len ( work ) / batch_size )
state . job_count = batch_count * upscale_count
state . job_count = batch_count * upscale_count
print (
print ( f " SD upscaling will process a total of { len ( work ) } images tiled as { len ( grid . tiles [ 0 ] [ 2 ] ) } x { len ( grid . tiles ) } per upscale in a total of { state . job_count } batches. " )
f " SD upscaling will process a total of { len ( work ) } images tiled as { len ( grid . tiles [ 0 ] [ 2 ] ) } x { len ( grid . tiles ) } per upscale in a total of { state . job_count } batches. " )
result_images = [ ]
result_images = [ ]
for n in range ( upscale_count ) :
for n in range ( upscale_count ) :
@ -87,17 +84,15 @@ class Script(scripts.Script):
image_index = 0
image_index = 0
for y , h , row in grid . tiles :
for y , h , row in grid . tiles :
for tiledata in row :
for tiledata in row :
tiledata [ 2 ] = work_results [ image_index ] if image_index < len ( work_results ) else Image . new ( " RGB " , (
tiledata [ 2 ] = work_results [ image_index ] if image_index < len ( work_results ) else Image . new ( " RGB " , ( p . width , p . height ) )
p . width , p . height ) )
image_index + = 1
image_index + = 1
combined_image = images . combine_grid ( grid )
combined_image = images . combine_grid ( grid )
result_images . append ( combined_image )
result_images . append ( combined_image )
if opts . samples_save :
if opts . samples_save :
images . save_image ( combined_image , p . outpath_samples , " " , start_seed , p . prompt , opts . samples_format ,
images . save_image ( combined_image , p . outpath_samples , " " , start_seed , p . prompt , opts . samples_format , info = initial_info , p = p )
info = initial_info , p = p )
processed = Processed ( p , result_images , seed , initial_info )
processed = Processed ( p , result_images , seed , initial_info )
return processed
return processed