Change the input to grayscale in the pytorch program

Change input from three-channel color to grayscale,use:self.turn = transforms.Grayscale(num_output_channels=1).
The same program can run through on one computer, and if it is changed to another computer (with the same environment), it will prompt an error:img should be PIL Image. Got <class ‘torch.Tensor’>。Who can help me answer

Are you sure the input is a PIL image either read from a file or from a numpy array?

I use this program:。
Now the interesting problem is that the program I modified can run on a computer, but when it is put on the server (strong computing power), it prompts an error.

Hi) Most likely it is the torchvision version is different on your PC versus server. The opportunity to use transforms on tensors was added only recently. So pytorch and torchvision update on the server should help.

Thanks for your reply, I will update the next version to try.

=> Start training
epoch: [1/250][50/202] time 0.283 (0.297)

Thank you, the question has been resolved.

1 Like