Then create a preprocessing function to apply the transforms and return the pixel_values - the inputs to the model - of the image:

def transforms(examples):
     examples["pixel_values"] = [_transforms(img.convert("RGB")) for img in examples["image"]]
     del examples["image"]
     return examples

To apply the preprocessing function over the entire dataset, use 🤗 Datasets [~datasets.Dataset.with_transform] method. The transforms are applied on the fly when you load an element of the dataset: