@@ -350,16 +350,21 @@ def _scale(self, x, scale):
350350 top = (height - scale_h ) // 2
351351 left = (width - scale_w ) // 2
352352
353- if self .estimator .channels_first :
354- if self .nb_dims == 3 :
355- x_out = zoom (x [:, top : top + scale_h , left : left + scale_w ], zoom = zooms , order = 1 )
356- elif self .nb_dims == 4 :
357- x_out = zoom (x [:, :, top : top + scale_h , left : left + scale_w ], zoom = zooms , order = 1 )
353+ if scale_h <= height and scale_w <= width and top >= 0 and left >= 0 :
354+
355+ if self .estimator .channels_first :
356+ if self .nb_dims == 3 :
357+ x_out = zoom (x [:, top : top + scale_h , left : left + scale_w ], zoom = zooms , order = 1 )
358+ elif self .nb_dims == 4 :
359+ x_out = zoom (x [:, :, top : top + scale_h , left : left + scale_w ], zoom = zooms , order = 1 )
360+ else :
361+ if self .nb_dims == 3 :
362+ x_out = zoom (x [top : top + scale_h , left : left + scale_w , :], zoom = zooms , order = 1 )
363+ elif self .nb_dims == 4 :
364+ x_out = zoom (x [:, top : top + scale_h , left : left + scale_w , :], zoom = zooms , order = 1 )
365+
358366 else :
359- if self .nb_dims == 3 :
360- x_out = zoom (x [top : top + scale_h , left : left + scale_w , :], zoom = zooms , order = 1 )
361- elif self .nb_dims == 4 :
362- x_out = zoom (x [:, top : top + scale_h , left : left + scale_w , :], zoom = zooms , order = 1 )
367+ x_out = x
363368
364369 cut_top = (x_out .shape [self .i_h ] - height ) // 2
365370 cut_left = (x_out .shape [self .i_w ] - width ) // 2
0 commit comments