Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
b1ef1fe7
Commit
b1ef1fe7
authored
May 26, 2018
by
Holger Kohr
Committed by
Soumith Chintala
May 26, 2018
Browse files
Normalize and pil link fix (#519)
* Fix PIL link * Make normalize more efficient
parent
f27eccea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+5
-5
No files found.
torchvision/transforms/functional.py
View file @
b1ef1fe7
...
@@ -94,7 +94,7 @@ def to_pil_image(pic, mode=None):
...
@@ -94,7 +94,7 @@ def to_pil_image(pic, mode=None):
pic (Tensor or numpy.ndarray): Image to be converted to PIL Image.
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).
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: http
s
://pillow.readthedocs.io/en/
latest
/handbook/concepts.html#
concept-
modes
Returns:
Returns:
PIL Image: Image converted to PIL Image.
PIL Image: Image converted to PIL Image.
...
@@ -163,10 +163,10 @@ def normalize(tensor, mean, std):
...
@@ -163,10 +163,10 @@ def normalize(tensor, mean, std):
"""
"""
if
not
_is_tensor_image
(
tensor
):
if
not
_is_tensor_image
(
tensor
):
raise
TypeError
(
'tensor is not a torch image.'
)
raise
TypeError
(
'tensor is not a torch image.'
)
# TODO: make efficient
for
t
,
m
,
s
in
zip
(
tensor
,
mean
,
std
):
mean
=
torch
.
Tensor
(
mean
).
view
((
tensor
.
shape
[
0
],
1
,
1
))
t
.
sub_
(
m
).
div_
(
s
)
std
=
torch
.
Tensor
(
std
).
view
((
tensor
.
shape
[
0
],
1
,
1
)
)
return
tensor
return
tensor
.
sub_
(
mean
).
div_
(
std
)
def
resize
(
img
,
size
,
interpolation
=
Image
.
BILINEAR
):
def
resize
(
img
,
size
,
interpolation
=
Image
.
BILINEAR
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment