@@ -1120,16 +1120,15 @@ def _resize_and_chop_tiles(self,
11201120 tiles_y = int (max (1 , round (i_height / (options .downsample_by * m_height ))))
11211121 logging .debug ("Chunking to {} x {} tiles" .format (tiles_x , tiles_y ))
11221122
1123- # Resample image to this size
1123+ # Fit image within target size
11241124 resamp_x = int (m_width + (tiles_x - 1 ) * (m_width - options .tile_overlap ))
11251125 resamp_y = int (m_height + (tiles_y - 1 ) * (m_height - options .tile_overlap ))
11261126
1127- logging .debug ("Resizing to {} x {} for tiling" .format (resamp_x , resamp_y ))
1128-
11291127 # Chop & resize image piece
11301128 if image .mode != 'RGB' :
11311129 image = image .convert ('RGB' )
11321130 image .thumbnail ((resamp_x , resamp_y ), Image .LANCZOS )
1131+ logging .debug ("Resizing to {} x {} for tiling" .format (image .width , image .height ))
11331132
11341133 # Rescale the input from uint8
11351134 input_zero = float (self .input_details ['quantization' ][1 ])
@@ -1144,8 +1143,8 @@ def _resize_and_chop_tiles(self,
11441143
11451144 # Do chunking
11461145 tiles = []
1147- for x_off in range (0 , resamp_x - options .tile_overlap , m_width - options . tile_overlap ):
1148- for y_off in range (0 , resamp_y - options .tile_overlap , m_height - options . tile_overlap ):
1146+ for x_off in range (0 , image . width - options .tile_overlap , int ( ceil (( image . width - m_width ) / tiles_x )) ):
1147+ for y_off in range (0 , image . height - options .tile_overlap , int ( ceil (( image . height - m_height ) / tiles_y )) ):
11491148 # Adjust contrast on a per-chunk basis; we will likely be quantizing the image during scaling
11501149 image_chunk = ImageOps .autocontrast (image .crop ((x_off ,
11511150 y_off ,
0 commit comments