Converting augmentation of Keras into Pytorch

I am reproducing a code (which is in tensorflow/keras) in which the following augmentations are applied.

ImageDataGenerator(
    zoom_range=0.1,
    fill_mode='reflect',
    width_shift_range=0.4,
    height_shift_range=0.4)

How can I use the same augmentation methods in Pytorch.

I would suggest to take a look at torchvision.transforms or at Albumentations

there are not available in both

may be @ptrblck can guide better on this

You can make custom transforms: Writing Custom Datasets, DataLoaders and Transforms — PyTorch Tutorials 2.4.0+cu121 documentation

For width and height shift range: How shift an image vertically or horizontally?

For zoom: Pytorch randomresizedcrop vs zoom_range in datagenerator

Reflect: torch.nn.functional.pad — PyTorch 2.4 documentation (I guess)

2 Likes