Skip to content

Commit

Permalink
Adding docs for RandAugment (#4349)
Browse files Browse the repository at this point in the history
* Adding docs for RandAugment.

* Fix docs.
  • Loading branch information
datumbox authored Sep 2, 2021
1 parent 5a81554 commit ad3c3f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ Generic Transforms
:members:


AutoAugment Transforms
----------------------
Automatic Augmentation Transforms
---------------------------------

`AutoAugment <https://arxiv.org/pdf/1805.09501.pdf>`_ is a common Data Augmentation technique that can improve the accuracy of Image Classification models.
Though the data augmentation policies are directly linked to their trained dataset, empirical studies show that
Expand All @@ -229,6 +229,10 @@ The new transform can be used standalone or mixed-and-matched with existing tran
.. autoclass:: AutoAugment
:members:

`RandAugment <https://arxiv.org/abs/1909.13719>`_ is a simple high-performing Data Augmentation technique which improves the accuracy of Image Classification models.

.. autoclass:: RandAugment
:members:

.. _functional_transforms:

Expand Down
8 changes: 8 additions & 0 deletions gallery/plot_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ def plot(imgs, with_orig=True, row_title=None, **imshow_kwargs):
row_title = [str(policy).split('.')[-1] for policy in policies]
plot(imgs, row_title=row_title)

####################################
# RandAugment
# ~~~~~~~~~~~
# The :class:`~torchvision.transforms.RandAugment` transform automatically augments the data.
augmenter = T.RandAugment()
imgs = [augmenter(orig_img) for _ in range(4)]
plot(imgs)

####################################
# Randomly-applied transforms
# ---------------------------
Expand Down
3 changes: 2 additions & 1 deletion torchvision/transforms/autoaugment.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def __repr__(self) -> str:
class RandAugment(torch.nn.Module):
r"""RandAugment data augmentation method based on
`"RandAugment: Practical automated data augmentation with a reduced search space"
<https://arxiv.org/abs/1909.13719>`.
<https://arxiv.org/abs/1909.13719>`_.
If the image is 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.
If img is PIL Image, it is expected to be in mode "L" or "RGB".
Expand Down Expand Up @@ -293,6 +293,7 @@ def _augmentation_space(self, num_bins: int, image_size: List[int]) -> Dict[str,
def forward(self, img: Tensor) -> Tensor:
"""
img (PIL Image or Tensor): Image to be transformed.
Returns:
PIL Image or Tensor: Transformed image.
"""
Expand Down

0 comments on commit ad3c3f7

Please sign in to comment.