pytorch / vision

Datasets, Transforms and Models specific to Computer Vision
https://pytorch.org/vision
BSD 3-Clause "New" or "Revised" License
16.11k stars 6.94k forks source link

Feature Request: RandAugment support for Data Augmentation #4981

Closed take2rohit closed 2 years ago

take2rohit commented 2 years ago

🚀 Feature

Need RandAugment module inside torchvision.transforms for augmenting images before training. This would ease the implementation of RandAugment.

Motivation

RandAugment is currently being used excessively in fields of representation learning and unsupervised domain adaptation. There are many papers this year itself that uses RandAugment however its direct pytorch implementation isn't out there. Implementing this method fast would be really helpful and avoid a lot of hassle for researchers. Hence I feel it would be a very meaningful addition to the library. I am also working with the science behind augmentation techniques when applied to domain adaptation. So I would be happy to contribute this feature to PyTorch.

Pitch

A user should be able to compose transforms using RandAugment just by adding one line. For eg.

from torchvision import transforms

transforms.Compose([
        transforms.Resize((resize_size, resize_size)),
        transform.RandAugment(**kwargs),
        transforms.ToTensor(),
    ])

Extension

Other popular augmentation methods like MixUp, CutMix and AutoAugment can also be accommodated in torchvision.transforms

Alternatives

https://github.com/ildoonet/pytorch-randaugment

cc @fmassa @vfdev-5 @pmeier

mruberry commented 2 years ago

@pmeier maybe we should move this to the torchvision repo?

vfdev-5 commented 2 years ago

@take2rohit there is already RandAugment implemented in torchvision. Please check the docs.

datumbox commented 2 years ago

And concerning Cutmix and Mixup, implementations already exist in References and we will move them soon on TorchVision once the new Transforms API is adopted.