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
8560d58b
Commit
8560d58b
authored
Dec 15, 2016
by
Soumith Chintala
Browse files
add support for single channel images
parent
dffb2d13
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
torchvision/utils.py
torchvision/utils.py
+5
-0
No files found.
torchvision/utils.py
View file @
8560d58b
...
...
@@ -15,8 +15,13 @@ def make_grid(tensor, nrow=8, padding=2):
tensor
=
tensorlist
[
0
].
new
(
size
)
for
i
in
range
(
numImages
):
tensor
[
i
].
copy_
(
tensorlist
[
i
])
if
tensor
.
dim
()
==
2
:
# single image H x W
tensor
=
torch
.
view
(
1
,
tensor
.
size
(
0
),
tensor
.
size
(
1
))
tensor
=
torch
.
cat
((
tensor
,
tensor
,
tensor
),
0
)
if
tensor
.
dim
()
==
3
:
# single image
return
tensor
if
tensor
.
dim
()
==
4
and
tensor
.
size
(
1
)
==
1
:
# single-channel images
tensor
=
torch
.
cat
((
tensor
,
tensor
,
tensor
),
1
)
# make the mini-batch of images into a grid
nmaps
=
tensor
.
size
(
0
)
xmaps
=
min
(
nrow
,
nmaps
)
...
...
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