Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize and pil link fix #519

Merged
merged 2 commits into from
May 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions torchvision/transforms/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def to_pil_image(pic, mode=None):
pic (Tensor or numpy.ndarray): Image to be converted to PIL Image.
mode (`PIL.Image mode`_): color space and pixel depth of input data (optional).

.. _PIL.Image mode: http://pillow.readthedocs.io/en/3.4.x/handbook/concepts.html#modes
.. _PIL.Image mode: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#concept-modes

Returns:
PIL Image: Image converted to PIL Image.
Expand Down Expand Up @@ -163,10 +163,10 @@ def normalize(tensor, mean, std):
"""
if not _is_tensor_image(tensor):
raise TypeError('tensor is not a torch image.')
# TODO: make efficient
for t, m, s in zip(tensor, mean, std):
t.sub_(m).div_(s)
return tensor

mean = torch.Tensor(mean).view((tensor.shape[0], 1, 1))
std = torch.Tensor(std).view((tensor.shape[0], 1, 1))
return tensor.sub_(mean).div_(std)


def resize(img, size, interpolation=Image.BILINEAR):
Expand Down