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
0a04aaa4
Commit
0a04aaa4
authored
Nov 16, 2016
by
Soumith Chintala
Browse files
fixing ToTensor bugs
parent
386a91b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
torchvision/transforms.py
torchvision/transforms.py
+3
-3
No files found.
torchvision/transforms.py
View file @
0a04aaa4
...
...
@@ -33,10 +33,10 @@ class ToTensor(object):
else
:
# handle PIL Image
img
=
torch
.
ByteTensor
(
torch
.
ByteStorage
.
from_buffer
(
pic
.
tobytes
()))
img
=
img
.
view
(
pic
.
size
[
0
],
pic
.
size
[
1
],
3
)
# put it from
W
HC to CHW format
img
=
img
.
view
(
pic
.
size
[
1
],
pic
.
size
[
0
],
3
)
# put it from H
W
C to CHW format
# yikes, this transpose takes 80% of the loading time/CPU
img
=
img
.
transpose
(
0
,
2
).
contiguous
()
img
=
img
.
transpose
(
0
,
1
).
transpose
(
0
,
2
).
contiguous
()
return
img
.
float
().
div
(
255
)
class
ToPILImage
(
object
):
...
...
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