Skip to content

Commit

Permalink
Merge pull request pytorch#21 from pytorch/float
Browse files Browse the repository at this point in the history
Fixes for inconsistency between / in Python 2 and 3
  • Loading branch information
soumith authored Jan 3, 2017
2 parents 5c39840 + 0786bae commit 3ed4831
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions torchvision/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __call__(self, pic):
return img.float().div(255)

class ToPILImage(object):
""" Converts a torch.*Tensor of range [0, 1] and shape C x H x W
""" Converts a torch.*Tensor of range [0, 1] and shape C x H x W
or numpy ndarray of dtype=uint8, range[0, 255] and shape H x W x C
to a PIL.Image of range [0, 255]
"""
Expand Down Expand Up @@ -111,8 +111,8 @@ def __init__(self, size):
def __call__(self, img):
w, h = img.size
th, tw = self.size
x1 = int(round((w - tw) / 2))
y1 = int(round((h - th) / 2))
x1 = int(round((w - tw) / 2.))
y1 = int(round((h - th) / 2.))
return img.crop((x1, y1, x1 + tw, y1 + th))


Expand Down Expand Up @@ -187,7 +187,7 @@ def __call__(self, img):
for attempt in range(10):
area = img.size[0] * img.size[1]
target_area = random.uniform(0.08, 1.0) * area
aspect_ratio = random.uniform(3 / 4, 4 / 3)
aspect_ratio = random.uniform(3. / 4, 4. / 3)

w = int(round(math.sqrt(target_area * aspect_ratio)))
h = int(round(math.sqrt(target_area / aspect_ratio)))
Expand Down

0 comments on commit 3ed4831

Please sign in to comment.