Home

Awesome

Batch Transforms

Batch equivalent of PyTorch Transforms.

transform_batch = transforms.Compose([
    ToTensor(),
    Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225))])

for images in data_iterator:
    images = transform_batch(images)
    output = model(images)

Normalize

Applies the equivalent of torchvision.transforms.Normalize to a batch of images.

Note: This transform acts out of place by default, i.e., it does not mutate the input tensor.

__init__(mean, std, inplace=False, dtype=torch.float, device='cpu')

__call__(tensor)

 

RandomCrop

Applies the equivalent of torchvision.transforms.RandomCrop to a batch of images. Images are independently transformed.

__init__(size, padding=None, device='cpu')

__call__(tensor)

 

RandomHorizontalFlip

Applies the equivalent of torchvision.transforms.RandomHorizontalFlip to a batch of images. Images are independently transformed.

Note: This transform acts out of place by default, i.e., it does not mutate the input tensor.

__init__(p=0.5, inplace=False)

__call__(tensor)

 

ToTensor

Applies the equivalent of torchvision.transforms.ToTensor to a batch of images.

__init__()

__call__(tensor)