.convert is a method of PIL.Image, so you have to use it after you’ve loaded the image and before transforming it to a tensor.
Are you using a Dataset or a class like ImageFolder?
If you are using the latter, the transformation should already be performed in this line 127.
If you are using your own Dataset, you should add it into the __getitem__ method after the image was loaded:
class MyDataset(Dataset):
    def __init__(self, image_paths, transforms=transforms):
        self.image_paths = image_paths
        self.transforms = transforms

    def __getitem__(self, index):
        image = Image.open(self.image_paths[index])
        image = image.convert('RGB')
        if self.transforms:
            image = self.transforms(image)
        return image

I skipped the target part. Let me know, if this works for you!