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
2f3b7ca9
Unverified
Commit
2f3b7ca9
authored
Apr 21, 2021
by
Zhengyang Feng
Committed by
GitHub
Apr 21, 2021
Browse files
Various doc fixes for transforms (#3704)
parent
d9338f32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
35 deletions
+31
-35
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+11
-12
torchvision/transforms/transforms.py
torchvision/transforms/transforms.py
+20
-23
No files found.
torchvision/transforms/functional.py
View file @
2f3b7ca9
...
...
@@ -370,7 +370,7 @@ def resize(img: Tensor, size: List[int], interpolation: InterpolationMode = Inte
the resized image: if the longer edge of the image is greater
than ``max_size`` after being resized according to ``size``, then
the image is resized again so that the longer edge is equal to
``max_size``. As a result, ``
`
size` might be overruled, i.e the
``max_size``. As a result, ``size`
`
might be overruled, i.e the
smaller edge may be shorter than ``size``. This is only supported
if ``size`` is an int (or a sequence of length 1 in torchscript
mode).
...
...
@@ -424,22 +424,21 @@ def pad(img: Tensor, padding: List[int], fill: int = 0, padding_mode: str = "con
This value is only used when the padding_mode is constant.
Only number is supported for torch Tensor.
Only int or str or tuple value is supported for PIL Image.
padding_mode: Type of padding. Should be: constant, edge, reflect or symmetric. Default is constant.
padding_mode (str): Type of padding. Should be: constant, edge, reflect or symmetric.
Default is constant.
- constant: pads with a constant value, this value is specified with fill
- edge: pads with the last value
on
the edge of the image
,
i
f input a 5D torch Tensor, the last 3 dimensions will be padded instead of the last 2
- edge: pads with the last value
at
the edge of the image
.
I
f input a 5D torch Tensor, the last 3 dimensions will be padded instead of the last 2
- reflect: pads with reflection of image (without repeating the last value on the edge)
- reflect: pads with reflection of image without repeating the last value on the edge.
For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]
padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]
- symmetric: pads with reflection of image (repeating the last value on the edge)
padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]
- symmetric: pads with reflection of image repeating the last value on the edge.
For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]
Returns:
PIL Image or Tensor: Padded image.
...
...
torchvision/transforms/transforms.py
View file @
2f3b7ca9
...
...
@@ -253,7 +253,7 @@ class Resize(torch.nn.Module):
the resized image: if the longer edge of the image is greater
than ``max_size`` after being resized according to ``size``, then
the image is resized again so that the longer edge is equal to
``max_size``. As a result, ``
`
size` might be overruled, i.e the
``max_size``. As a result, ``size`
`
might be overruled, i.e the
smaller edge may be shorter than ``size``. This is only supported
if ``size`` is an int (or a sequence of length 1 in torchscript
mode).
...
...
@@ -361,18 +361,16 @@ class Pad(torch.nn.Module):
- constant: pads with a constant value, this value is specified with fill
- edge: pads with the last value at the edge of the image
,
i
f input a 5D torch Tensor, the last 3 dimensions will be padded instead of the last 2
- edge: pads with the last value at the edge of the image
.
I
f input a 5D torch Tensor, the last 3 dimensions will be padded instead of the last 2
- reflect: pads with reflection of image without repeating the last value on the edge
- reflect: pads with reflection of image without repeating the last value on the edge.
For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]
For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]
- symmetric: pads with reflection of image repeating the last value on the edge
For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]
- symmetric: pads with reflection of image repeating the last value on the edge.
For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]
"""
def
__init__
(
self
,
padding
,
fill
=
0
,
padding_mode
=
"constant"
):
...
...
@@ -540,22 +538,21 @@ class RandomCrop(torch.nn.Module):
This value is only used when the padding_mode is constant.
Only number is supported for torch Tensor.
Only int or str or tuple value is supported for PIL Image.
padding_mode (str): Type of padding. Should be: constant, edge, reflect or symmetric. Default is constant.
- constant: pads with a constant value, this value is specified with fill
- edge: pads with the last value on the edge of the image
- reflect: pads with reflection of image (without repeating the last value on the edge)
padding_mode (str): Type of padding. Should be: constant, edge, reflect or symmetric.
Default is constant.
padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]
- constant: pads with a constant value, this value is specified with fill
- symmetric: pads with reflection of image (repeating the last value on the edge)
- edge: pads with the last value at the edge of the image.
If input a 5D torch Tensor, the last 3 dimensions will be padded instead of the last 2
padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]
- reflect: pads with reflection of image without repeating the last value on the edge.
For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]
- symmetric: pads with reflection of image repeating the last value on the edge.
For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]
"""
@
staticmethod
...
...
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