Usually the image is already loaded as PIL image, you do not need to use transforms.ToPILImage(). Also it is not straight forward to convert a tensor to image because the tensors are usually normalized using per-channel mean and std.