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
cabca398
Commit
cabca398
authored
Sep 10, 2019
by
Dmitrii Petukhov
Committed by
Francisco Massa
Sep 10, 2019
Browse files
Fix make_grid: support any number of channels in tensor (#1300)
parent
7f7e7663
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
torchvision/utils.py
torchvision/utils.py
+2
-1
No files found.
torchvision/utils.py
View file @
cabca398
...
@@ -74,7 +74,8 @@ def make_grid(tensor, nrow=8, padding=2,
...
@@ -74,7 +74,8 @@ def make_grid(tensor, nrow=8, padding=2,
xmaps
=
min
(
nrow
,
nmaps
)
xmaps
=
min
(
nrow
,
nmaps
)
ymaps
=
int
(
math
.
ceil
(
float
(
nmaps
)
/
xmaps
))
ymaps
=
int
(
math
.
ceil
(
float
(
nmaps
)
/
xmaps
))
height
,
width
=
int
(
tensor
.
size
(
2
)
+
padding
),
int
(
tensor
.
size
(
3
)
+
padding
)
height
,
width
=
int
(
tensor
.
size
(
2
)
+
padding
),
int
(
tensor
.
size
(
3
)
+
padding
)
grid
=
tensor
.
new_full
((
3
,
height
*
ymaps
+
padding
,
width
*
xmaps
+
padding
),
pad_value
)
num_channels
=
tensor
.
size
(
1
)
grid
=
tensor
.
new_full
((
num_channels
,
height
*
ymaps
+
padding
,
width
*
xmaps
+
padding
),
pad_value
)
k
=
0
k
=
0
for
y
in
irange
(
ymaps
):
for
y
in
irange
(
ymaps
):
for
x
in
irange
(
xmaps
):
for
x
in
irange
(
xmaps
):
...
...
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