Python torchvision.transforms.transforms.RandomCrop() Examples
The following are 1
code examples of torchvision.transforms.transforms.RandomCrop().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
torchvision.transforms.transforms
, or try the search function
.
Example #1
Source File: get_dataloader.py From Greedy_InfoMax with MIT License | 6 votes |
def get_transforms(eval=False, aug=None): trans = [] if aug["randcrop"] and not eval: trans.append(transforms.RandomCrop(aug["randcrop"])) if aug["randcrop"] and eval: trans.append(transforms.CenterCrop(aug["randcrop"])) if aug["flip"] and not eval: trans.append(transforms.RandomHorizontalFlip()) if aug["grayscale"]: trans.append(transforms.Grayscale()) trans.append(transforms.ToTensor()) trans.append(transforms.Normalize(mean=aug["bw_mean"], std=aug["bw_std"])) elif aug["mean"]: trans.append(transforms.ToTensor()) trans.append(transforms.Normalize(mean=aug["mean"], std=aug["std"])) else: trans.append(transforms.ToTensor()) trans = transforms.Compose(trans) return trans