That’s exactly what I did.
gt_transform = transforms.Compose([
            transforms.ToPILImage(),
            transforms.Resize((256, 256), interpolation=0),
            transforms.ToTensor()
            ])

label = torch.from_numpy(label.npy) # [143, 512, 512]
label_transform = gt_transform(label)

But I got the error
ValueError                                Traceback (most recent call last)
<ipython-input-31-da837537eac8> in <module>()
----> 1 label = gt_transform(label)

2 frames
/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional.py in to_pil_image(pic, mode)
    229         # check number of channels
    230         if pic.shape[-3] > 4:
--> 231             raise ValueError('pic should not have > 4 channels. Got {} channels.'.format(pic.shape[-3]))
    232 
    233     elif isinstance(pic, np.ndarray):

ValueError: pic should not have > 4 channels. Got 143 channels.