..         transforms.Normalize([0.5], [0.5]),
...     ]
... )
Use 🤗 Datasets’ set_transform method to apply the preprocess function on the fly during training:


	Copied
>>> def transform(examples):
...     images = [preprocess(image.convert("RGB")) for image in examples["image"]]
...     return {"images": images}


>>> dataset.set_transform(transform)
Feel free to visualize the images again to confirm that they’ve been resized. Now you’re rea