Skip to content

Commit 74e3365

Browse files
vfdev-5NicolasHug
andauthored
Minor updates in autoaugment, augment docstring v2 (#7317)
Co-authored-by: Nicolas Hug <[email protected]>
1 parent c4b4193 commit 74e3365

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

torchvision/transforms/v2/_augment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313

1414

1515
class RandomErasing(_RandomApplyTransform):
16-
"""[BETA] Randomly selects a rectangle region in the input image or video and erases its pixels.
16+
"""[BETA] Randomly select a rectangle region in the input image or video and erase its pixels.
1717
1818
.. betastatus:: RandomErasing transform
1919
2020
This transform does not support PIL Image.
2121
'Random Erasing Data Augmentation' by Zhong et al. See https://arxiv.org/abs/1708.04896
2222
2323
Args:
24-
p: probability that the random erasing operation will be performed.
25-
scale: range of proportion of erased area against input image.
26-
ratio: range of aspect ratio of erased area.
27-
value: erasing value. Default is 0. If a single int, it is used to
24+
p (float, optional): probability that the random erasing operation will be performed.
25+
scale (tuple of float, optional): range of proportion of erased area against input image.
26+
ratio (tuple of float, optional): range of aspect ratio of erased area.
27+
value (number or tuple of numbers): erasing value. Default is 0. If a single int, it is used to
2828
erase all pixels. If a tuple of length 3, it is used to erase
2929
R, G, B channels respectively.
3030
If a str of 'random', erasing each pixel with random values.
31-
inplace: boolean to make this transform inplace. Default set to False.
31+
inplace (bool, optional): boolean to make this transform inplace. Default set to False.
3232
3333
Returns:
3434
Erased input.

torchvision/transforms/v2/_auto_augment.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,16 @@ class AutoAugment(_AutoAugmentBase):
167167
168168
.. betastatus:: AutoAugment transform
169169
170-
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
170+
This transformation works on images and videos only.
171+
172+
If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
171173
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
172174
If img is PIL Image, it is expected to be in mode "L" or "RGB".
173175
174176
Args:
175-
policy (AutoAugmentPolicy): Desired policy enum defined by
177+
policy (AutoAugmentPolicy, optional): Desired policy enum defined by
176178
:class:`torchvision.transforms.autoaugment.AutoAugmentPolicy`. Default is ``AutoAugmentPolicy.IMAGENET``.
177-
interpolation (InterpolationMode): Desired interpolation enum defined by
179+
interpolation (InterpolationMode, optional): Desired interpolation enum defined by
178180
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
179181
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
180182
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
@@ -342,15 +344,17 @@ class RandAugment(_AutoAugmentBase):
342344
343345
.. betastatus:: RandAugment transform
344346
345-
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
347+
This transformation works on images and videos only.
348+
349+
If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
346350
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
347351
If img is PIL Image, it is expected to be in mode "L" or "RGB".
348352
349353
Args:
350-
num_ops (int): Number of augmentation transformations to apply sequentially.
351-
magnitude (int): Magnitude for all the transformations.
352-
num_magnitude_bins (int): The number of different magnitude values.
353-
interpolation (InterpolationMode): Desired interpolation enum defined by
354+
num_ops (int, optional): Number of augmentation transformations to apply sequentially.
355+
magnitude (int, optional): Magnitude for all the transformations.
356+
num_magnitude_bins (int, optional): The number of different magnitude values.
357+
interpolation (InterpolationMode, optional): Desired interpolation enum defined by
354358
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
355359
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
356360
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
@@ -423,13 +427,15 @@ class TrivialAugmentWide(_AutoAugmentBase):
423427
424428
.. betastatus:: TrivialAugmentWide transform
425429
426-
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
430+
This transformation works on images and videos only.
431+
432+
If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
427433
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
428434
If img is PIL Image, it is expected to be in mode "L" or "RGB".
429435
430436
Args:
431-
num_magnitude_bins (int): The number of different magnitude values.
432-
interpolation (InterpolationMode): Desired interpolation enum defined by
437+
num_magnitude_bins (int, optional): The number of different magnitude values.
438+
interpolation (InterpolationMode, optional): Desired interpolation enum defined by
433439
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
434440
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
435441
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
@@ -492,18 +498,20 @@ class AugMix(_AutoAugmentBase):
492498
493499
.. betastatus:: AugMix transform
494500
495-
If the image is torch Tensor, it should be of type torch.uint8, and it is expected
501+
This transformation works on images and videos only.
502+
503+
If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
496504
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
497505
If img is PIL Image, it is expected to be in mode "L" or "RGB".
498506
499507
Args:
500-
severity (int): The severity of base augmentation operators. Default is ``3``.
501-
mixture_width (int): The number of augmentation chains. Default is ``3``.
502-
chain_depth (int): The depth of augmentation chains. A negative value denotes stochastic depth sampled from the interval [1, 3].
508+
severity (int, optional): The severity of base augmentation operators. Default is ``3``.
509+
mixture_width (int, optional): The number of augmentation chains. Default is ``3``.
510+
chain_depth (int, optional): The depth of augmentation chains. A negative value denotes stochastic depth sampled from the interval [1, 3].
503511
Default is ``-1``.
504-
alpha (float): The hyperparameter for the probability distributions. Default is ``1.0``.
505-
all_ops (bool): Use all operations (including brightness, contrast, color and sharpness). Default is ``True``.
506-
interpolation (InterpolationMode): Desired interpolation enum defined by
512+
alpha (float, optional): The hyperparameter for the probability distributions. Default is ``1.0``.
513+
all_ops (bool, optional): Use all operations (including brightness, contrast, color and sharpness). Default is ``True``.
514+
interpolation (InterpolationMode, optional): Desired interpolation enum defined by
507515
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
508516
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
509517
fill (sequence or number, optional): Pixel fill value for the area outside the transformed

0 commit comments

Comments
 (0)