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
9aff5677
Unverified
Commit
9aff5677
authored
May 24, 2018
by
Francisco Massa
Committed by
GitHub
May 24, 2018
Browse files
Revert "add padding-mode choice to `RandomCrop` (#512)" (#515)
This reverts commit
11da4f17
.
parent
11da4f17
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
7 deletions
+4
-7
torchvision/transforms/transforms.py
torchvision/transforms/transforms.py
+4
-7
No files found.
torchvision/transforms/transforms.py
View file @
9aff5677
...
@@ -375,19 +375,16 @@ class RandomCrop(object):
...
@@ -375,19 +375,16 @@ class RandomCrop(object):
of the image. Default is 0, i.e no padding. If a sequence of length
of the image. Default is 0, i.e no padding. If a sequence of length
4 is provided, it is used to pad left, top, right, bottom borders
4 is provided, it is used to pad left, top, right, bottom borders
respectively.
respectively.
padding_mode (str): Type of padding. Should be: constant, edge, reflect
or symmetric. Default is constant.
pad_if_needed (boolean): It will pad the image if smaller than the
pad_if_needed (boolean): It will pad the image if smaller than the
desired size to avoid raising an exception.
desired size to avoid raising an exception.
"""
"""
def
__init__
(
self
,
size
,
padding
=
0
,
padding_mode
=
'constant'
,
pad_if_needed
=
False
):
def
__init__
(
self
,
size
,
padding
=
0
,
pad_if_needed
=
False
):
if
isinstance
(
size
,
numbers
.
Number
):
if
isinstance
(
size
,
numbers
.
Number
):
self
.
size
=
(
int
(
size
),
int
(
size
))
self
.
size
=
(
int
(
size
),
int
(
size
))
else
:
else
:
self
.
size
=
size
self
.
size
=
size
self
.
padding
=
padding
self
.
padding
=
padding
self
.
padding_mode
=
padding_mode
self
.
pad_if_needed
=
pad_if_needed
self
.
pad_if_needed
=
pad_if_needed
@
staticmethod
@
staticmethod
...
@@ -419,14 +416,14 @@ class RandomCrop(object):
...
@@ -419,14 +416,14 @@ class RandomCrop(object):
PIL Image: Cropped image.
PIL Image: Cropped image.
"""
"""
if
self
.
padding
>
0
:
if
self
.
padding
>
0
:
img
=
F
.
pad
(
img
,
self
.
padding
,
padding_mode
=
self
.
padding_mode
)
img
=
F
.
pad
(
img
,
self
.
padding
)
# pad the width if needed
# pad the width if needed
if
self
.
pad_if_needed
and
img
.
size
[
0
]
<
self
.
size
[
1
]:
if
self
.
pad_if_needed
and
img
.
size
[
0
]
<
self
.
size
[
1
]:
img
=
F
.
pad
(
img
,
(
int
((
1
+
self
.
size
[
1
]
-
img
.
size
[
0
])
/
2
),
0
)
,
padding_mode
=
self
.
padding_mode
)
img
=
F
.
pad
(
img
,
(
int
((
1
+
self
.
size
[
1
]
-
img
.
size
[
0
])
/
2
),
0
))
# pad the height if needed
# pad the height if needed
if
self
.
pad_if_needed
and
img
.
size
[
1
]
<
self
.
size
[
0
]:
if
self
.
pad_if_needed
and
img
.
size
[
1
]
<
self
.
size
[
0
]:
img
=
F
.
pad
(
img
,
(
0
,
int
((
1
+
self
.
size
[
0
]
-
img
.
size
[
1
])
/
2
))
,
padding_mode
=
self
.
padding_mode
)
img
=
F
.
pad
(
img
,
(
0
,
int
((
1
+
self
.
size
[
0
]
-
img
.
size
[
1
])
/
2
)))
i
,
j
,
h
,
w
=
self
.
get_params
(
img
,
self
.
size
)
i
,
j
,
h
,
w
=
self
.
get_params
(
img
,
self
.
size
)
...
...
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