@@ -41,7 +41,7 @@ def __call__(self, pic):
41
41
return img .float ().div (255 )
42
42
43
43
class ToPILImage (object ):
44
- """ Converts a torch.*Tensor of range [0, 1] and shape C x H x W
44
+ """ Converts a torch.*Tensor of range [0, 1] and shape C x H x W
45
45
or numpy ndarray of dtype=uint8, range[0, 255] and shape H x W x C
46
46
to a PIL.Image of range [0, 255]
47
47
"""
@@ -111,8 +111,8 @@ def __init__(self, size):
111
111
def __call__ (self , img ):
112
112
w , h = img .size
113
113
th , tw = self .size
114
- x1 = int (round ((w - tw ) / 2 ))
115
- y1 = int (round ((h - th ) / 2 ))
114
+ x1 = int (round ((w - tw ) / 2. ))
115
+ y1 = int (round ((h - th ) / 2. ))
116
116
return img .crop ((x1 , y1 , x1 + tw , y1 + th ))
117
117
118
118
@@ -187,7 +187,7 @@ def __call__(self, img):
187
187
for attempt in range (10 ):
188
188
area = img .size [0 ] * img .size [1 ]
189
189
target_area = random .uniform (0.08 , 1.0 ) * area
190
- aspect_ratio = random .uniform (3 / 4 , 4 / 3 )
190
+ aspect_ratio = random .uniform (3. / 4 , 4. / 3 )
191
191
192
192
w = int (round (math .sqrt (target_area * aspect_ratio )))
193
193
h = int (round (math .sqrt (target_area / aspect_ratio )))
0 commit comments