转自:https://blog.csdn.net/grllery/article/details/102470263
transform = transforms.Compose([
transforms.Grayscale(num_output_channels=1),
transforms.ToTensor()
])
img = transform(img)
print(img.size()) # img(1, 681, 1023)
img = np.transpose(img, (1,2,0)) # img(681, 1023, 1)
plt.imshow(img.squeeze()) # img(681, 1023)
plt.show()