Those transforms are only for PIL Images, so you have two options:

Using opencv to load the images and then convert to pil image using:

from PIL import Image
img = cv2.imread('img_path')
pil_img = Image.fromarray(img).convert('RGB')  #img as opencv


Load the image directly with PIL (better than 1)

from PIL import Image
pil_img = Image.open(img_path).convert('RGB') # convert('L') if it's a gray scale image

You can resize the pil image directly or also using transforms. Also you shouldn’t load all the images into a list, because Dataloader load on the fly, but you have to set your own Dataset or using something like https://pytorch.org/docs/stable/torchvision/datasets.html#imagefolder 336