 pixel values into a [-1, 1] range, which is what the model expects.


	Copied
>>> from torchvision import transforms

>>> preprocess = transforms.Compose(
...     [
...         transforms.Resize((config.image_size, config.image_size)),
...         transforms.RandomHorizontalFlip(),
...         transforms.ToTensor(),
...         transforms.Normalize([0.5], [0.5]),
...     ]
... )
Use 🤗 Datasets’ set_transform method to apply the preprocess func