In the traditional ImageFolder class you would do something like -
data = dataloader(
        Imagefolder( path_To_images, transforms.Compose(['YOUR TRANSFORMATIONS'])))

Essentially it loads the data using the PIL library performs some processing on the loaded image using the PIL library which you specify and then you add a ToTensor() in the compose where it takes the processed image makes it ready to be taken as input for your network, returns the tensor and the class… Dataloader prepares the batches.
So in your pipeline wherever you are loading your images using PIL, just convert them to tensors(or any other data type mentioned in the error) and it should work.