@@ -67,7 +67,7 @@ def to_tensor(pic):
67
67
return img
68
68
69
69
70
- def to_pilimage (pic ):
70
+ def to_pil_image (pic ):
71
71
if not (_is_numpy_image (pic ) or _is_tensor_image (pic )):
72
72
raise TypeError ('pic should be Tensor or ndarray. Got {}.' .format (type (pic )))
73
73
@@ -219,7 +219,7 @@ def __call__(self, pic):
219
219
PIL.Image: Image converted to PIL.Image.
220
220
221
221
"""
222
- return to_pilimage (pic )
222
+ return to_pil_image (pic )
223
223
224
224
225
225
class Normalize (object ):
@@ -294,9 +294,10 @@ def __init__(self, size):
294
294
else :
295
295
self .size = size
296
296
297
- def get_params (self , img ):
297
+ @staticmethod
298
+ def get_params (img , output_size ):
298
299
w , h = img .size
299
- th , tw = self . size
300
+ th , tw = output_size
300
301
x1 = int (round ((w - tw ) / 2. ))
301
302
y1 = int (round ((h - th ) / 2. ))
302
303
return x1 , y1 , tw , th
@@ -309,7 +310,7 @@ def __call__(self, img):
309
310
Returns:
310
311
PIL.Image: Cropped image.
311
312
"""
312
- x1 , y1 , tw , th = self .get_params (img )
313
+ x1 , y1 , tw , th = self .get_params (img , self . size )
313
314
return crop (img , x1 , y1 , tw , th )
314
315
315
316
@@ -382,9 +383,10 @@ def __init__(self, size, padding=0):
382
383
self .size = size
383
384
self .padding = padding
384
385
385
- def get_params (self , img ):
386
+ @staticmethod
387
+ def get_params (img , output_size ):
386
388
w , h = img .size
387
- th , tw = self . size
389
+ th , tw = output_size
388
390
if w == tw and h == th :
389
391
return img
390
392
@@ -403,7 +405,7 @@ def __call__(self, img):
403
405
if self .padding > 0 :
404
406
img = pad (img , self .padding )
405
407
406
- x1 , y1 , tw , th = self .get_params (img )
408
+ x1 , y1 , tw , th = self .get_params (img , self . size )
407
409
408
410
return crop (img , x1 , y1 , tw , th )
409
411
@@ -441,7 +443,8 @@ def __init__(self, size, interpolation=Image.BILINEAR):
441
443
self .size = size
442
444
self .interpolation = interpolation
443
445
444
- def get_params (self , img ):
446
+ @staticmethod
447
+ def get_params (img ):
445
448
for attempt in range (10 ):
446
449
area = img .size [0 ] * img .size [1 ]
447
450
target_area = random .uniform (0.08 , 1.0 ) * area
0 commit comments