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
3884faf0
Commit
3884faf0
authored
Dec 13, 2018
by
surgan12
Committed by
Francisco Massa
Dec 13, 2018
Browse files
Pad updated (#683)
* pad updated * checked pad * pad checked * pad checked
parent
8bd05e67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+14
-0
No files found.
torchvision/transforms/functional.py
View file @
3884faf0
...
...
@@ -288,6 +288,12 @@ def pad(img, padding, fill=0, padding_mode='constant'):
'Padding mode should be either constant, edge, reflect or symmetric'
if
padding_mode
==
'constant'
:
if
img
.
mode
==
'P'
:
palette
=
img
.
getpalette
()
image
=
ImageOps
.
expand
(
img
,
border
=
padding
,
fill
=
fill
)
image
.
putpalette
(
palette
)
return
image
return
ImageOps
.
expand
(
img
,
border
=
padding
,
fill
=
fill
)
else
:
if
isinstance
(
padding
,
int
):
...
...
@@ -301,6 +307,14 @@ def pad(img, padding, fill=0, padding_mode='constant'):
pad_right
=
padding
[
2
]
pad_bottom
=
padding
[
3
]
if
img
.
mode
==
'P'
:
palette
=
img
.
getpalette
()
img
=
np
.
asarray
(
img
)
img
=
np
.
pad
(
img
,
((
pad_top
,
pad_bottom
),
(
pad_left
,
pad_right
)),
padding_mode
)
img
=
Image
.
fromarray
(
img
)
img
.
putpalette
(
palette
)
return
img
img
=
np
.
asarray
(
img
)
# RGB image
if
len
(
img
.
shape
)
==
3
:
...
...
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