You could also do a transform to Grayscale
dataset = torchvision.datasets.ImageFolder(
        root = data_path,
        #    By default the imageFolder loads images with 3 channels and we expect the image to be grayscale.
        #    So let's transform the image to grayscale
        transform =  transforms.Compose([transforms.Grayscale(), transforms.ToTensor()])
    )