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
74e33657
Unverified
Commit
74e33657
authored
Feb 24, 2023
by
vfdev
Committed by
GitHub
Feb 24, 2023
Browse files
Minor updates in autoaugment, augment docstring v2 (#7317)
Co-authored-by:
Nicolas Hug
<
contact@nicolas-hug.com
>
parent
c4b41939
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
24 deletions
+32
-24
torchvision/transforms/v2/_augment.py
torchvision/transforms/v2/_augment.py
+6
-6
torchvision/transforms/v2/_auto_augment.py
torchvision/transforms/v2/_auto_augment.py
+26
-18
No files found.
torchvision/transforms/v2/_augment.py
View file @
74e33657
...
@@ -13,7 +13,7 @@ from .utils import is_simple_tensor, query_chw
...
@@ -13,7 +13,7 @@ from .utils import is_simple_tensor, query_chw
class
RandomErasing
(
_RandomApplyTransform
):
class
RandomErasing
(
_RandomApplyTransform
):
"""[BETA] Randomly select
s
a rectangle region in the input image or video and erase
s
its pixels.
"""[BETA] Randomly select a rectangle region in the input image or video and erase its pixels.
.. betastatus:: RandomErasing transform
.. betastatus:: RandomErasing transform
...
@@ -21,14 +21,14 @@ class RandomErasing(_RandomApplyTransform):
...
@@ -21,14 +21,14 @@ class RandomErasing(_RandomApplyTransform):
'Random Erasing Data Augmentation' by Zhong et al. See https://arxiv.org/abs/1708.04896
'Random Erasing Data Augmentation' by Zhong et al. See https://arxiv.org/abs/1708.04896
Args:
Args:
p: probability that the random erasing operation will be performed.
p
(float, optional)
: probability that the random erasing operation will be performed.
scale: range of proportion of erased area against input image.
scale
(tuple of float, optional)
: range of proportion of erased area against input image.
ratio: range of aspect ratio of erased area.
ratio
(tuple of float, optional)
: range of aspect ratio of erased area.
value: erasing value. Default is 0. If a single int, it is used to
value
(number or tuple of numbers)
: erasing value. Default is 0. If a single int, it is used to
erase all pixels. If a tuple of length 3, it is used to erase
erase all pixels. If a tuple of length 3, it is used to erase
R, G, B channels respectively.
R, G, B channels respectively.
If a str of 'random', erasing each pixel with random values.
If a str of 'random', erasing each pixel with random values.
inplace: boolean to make this transform inplace. Default set to False.
inplace
(bool, optional)
: boolean to make this transform inplace. Default set to False.
Returns:
Returns:
Erased input.
Erased input.
...
...
torchvision/transforms/v2/_auto_augment.py
View file @
74e33657
...
@@ -167,14 +167,16 @@ class AutoAugment(_AutoAugmentBase):
...
@@ -167,14 +167,16 @@ class AutoAugment(_AutoAugmentBase):
.. betastatus:: AutoAugment transform
.. betastatus:: AutoAugment transform
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
This transformation works on images and videos only.
If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
If img is PIL Image, it is expected to be in mode "L" or "RGB".
If img is PIL Image, it is expected to be in mode "L" or "RGB".
Args:
Args:
policy (AutoAugmentPolicy): Desired policy enum defined by
policy (AutoAugmentPolicy
, optional
): Desired policy enum defined by
:class:`torchvision.transforms.autoaugment.AutoAugmentPolicy`. Default is ``AutoAugmentPolicy.IMAGENET``.
:class:`torchvision.transforms.autoaugment.AutoAugmentPolicy`. Default is ``AutoAugmentPolicy.IMAGENET``.
interpolation (InterpolationMode): Desired interpolation enum defined by
interpolation (InterpolationMode
, optional
): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
...
@@ -342,15 +344,17 @@ class RandAugment(_AutoAugmentBase):
...
@@ -342,15 +344,17 @@ class RandAugment(_AutoAugmentBase):
.. betastatus:: RandAugment transform
.. betastatus:: RandAugment transform
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
This transformation works on images and videos only.
If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
If img is PIL Image, it is expected to be in mode "L" or "RGB".
If img is PIL Image, it is expected to be in mode "L" or "RGB".
Args:
Args:
num_ops (int): Number of augmentation transformations to apply sequentially.
num_ops (int
, optional
): Number of augmentation transformations to apply sequentially.
magnitude (int): Magnitude for all the transformations.
magnitude (int
, optional
): Magnitude for all the transformations.
num_magnitude_bins (int): The number of different magnitude values.
num_magnitude_bins (int
, optional
): The number of different magnitude values.
interpolation (InterpolationMode): Desired interpolation enum defined by
interpolation (InterpolationMode
, optional
): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
...
@@ -423,13 +427,15 @@ class TrivialAugmentWide(_AutoAugmentBase):
...
@@ -423,13 +427,15 @@ class TrivialAugmentWide(_AutoAugmentBase):
.. betastatus:: TrivialAugmentWide transform
.. betastatus:: TrivialAugmentWide transform
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
This transformation works on images and videos only.
If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
If img is PIL Image, it is expected to be in mode "L" or "RGB".
If img is PIL Image, it is expected to be in mode "L" or "RGB".
Args:
Args:
num_magnitude_bins (int): The number of different magnitude values.
num_magnitude_bins (int
, optional
): The number of different magnitude values.
interpolation (InterpolationMode): Desired interpolation enum defined by
interpolation (InterpolationMode
, optional
): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
...
@@ -492,18 +498,20 @@ class AugMix(_AutoAugmentBase):
...
@@ -492,18 +498,20 @@ class AugMix(_AutoAugmentBase):
.. betastatus:: AugMix transform
.. betastatus:: AugMix transform
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
This transformation works on images and videos only.
If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
If img is PIL Image, it is expected to be in mode "L" or "RGB".
If img is PIL Image, it is expected to be in mode "L" or "RGB".
Args:
Args:
severity (int): The severity of base augmentation operators. Default is ``3``.
severity (int
, optional
): The severity of base augmentation operators. Default is ``3``.
mixture_width (int): The number of augmentation chains. Default is ``3``.
mixture_width (int
, optional
): The number of augmentation chains. Default is ``3``.
chain_depth (int): The depth of augmentation chains. A negative value denotes stochastic depth sampled from the interval [1, 3].
chain_depth (int
, optional
): The depth of augmentation chains. A negative value denotes stochastic depth sampled from the interval [1, 3].
Default is ``-1``.
Default is ``-1``.
alpha (float): The hyperparameter for the probability distributions. Default is ``1.0``.
alpha (float
, optional
): The hyperparameter for the probability distributions. Default is ``1.0``.
all_ops (bool): Use all operations (including brightness, contrast, color and sharpness). Default is ``True``.
all_ops (bool
, optional
): Use all operations (including brightness, contrast, color and sharpness). Default is ``True``.
interpolation (InterpolationMode): Desired interpolation enum defined by
interpolation (InterpolationMode
, optional
): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
...
...
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