I tried the way you told me but I am not getting the correct results.
Note: I want my image tensor to be of shape [3, T, 128,128] where T is no of images and 3 is channels and 128, 128 are width and height
My code:
transform = transforms.Compose(
[transforms.ToTensor(),

 transforms.Resize(128)

])

from torch.utils.data import Dataset, DataLoader
from torch import from_numpy, tensor
import numpy as np
class UBFCDataset(Dataset):
def __init__(self):

    xy = np.loadtxt('/content/drive/My Drive/Subject3hr.csv')

    self.x_data = torch.from_numpy(xy[:])

    self.len = xy.shape[0]

def __len__(self):

    return self.len

def __getitem__(self, index):

    train_data_tensor = torchvision.datasets.ImageFolder("/content/drive/My Drive/Meta-rPPG-master/da", transform=transforms)

    return train_data_tensor, self.x_data

dataset = UBFCDataset()
train_loader = DataLoader(dataset=dataset,batch_size=32,shuffle=True)
for data in train_loader:
    inputs, labels = data

    inputs, labels = tensor(inputs), tensor(labels)

Error:
TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found <class ‘torchvision.datasets.folder.ImageFolder’>