Please define a customed dataset following the official tutoral.
Inside the CustomedDataset class
def __getitem__(self, idx):

define:
 compose = transforms.Compose([transforms.ToPILImage(), 
                                         transforms.Resize((128,128),interpolation=Image.NEAREST),
                                         transforms.ToTensor(),
                                         transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

then use:
img_tensor = compose(img_tensor)