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
429dbebe
Commit
429dbebe
authored
Mar 11, 2017
by
Edgar Simo-Serra
Committed by
Soumith Chintala
Mar 10, 2017
Browse files
Fixed save_image to correctly output values in the full byte range. (#41)
parent
c76de96a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
torchvision/utils.py
torchvision/utils.py
+1
-1
No files found.
torchvision/utils.py
View file @
429dbebe
...
@@ -50,6 +50,6 @@ def save_image(tensor, filename, nrow=8, padding=2):
...
@@ -50,6 +50,6 @@ def save_image(tensor, filename, nrow=8, padding=2):
from
PIL
import
Image
from
PIL
import
Image
tensor
=
tensor
.
cpu
()
tensor
=
tensor
.
cpu
()
grid
=
make_grid
(
tensor
,
nrow
=
nrow
,
padding
=
padding
)
grid
=
make_grid
(
tensor
,
nrow
=
nrow
,
padding
=
padding
)
ndarr
=
grid
.
mul
(
0.5
).
add
(
0.5
).
mul
(
255
).
byte
().
transpose
(
0
,
2
).
transpose
(
0
,
1
).
numpy
()
ndarr
=
grid
.
mul
(
255
).
byte
().
transpose
(
0
,
2
).
transpose
(
0
,
1
).
numpy
()
im
=
Image
.
fromarray
(
ndarr
)
im
=
Image
.
fromarray
(
ndarr
)
im
.
save
(
filename
)
im
.
save
(
filename
)
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