There is a calss called ToPILImage to transform tensor to PILImage in torchvision, however, there’s a problem which will cause overflow and underflow.
The line causing bug is as follows:
pic = pic.mul(255).byte()

This .byte() will transform the tensor from float to uint8 with potential underflow and overflow problem.
For instance, -1.34(float) is supposed to be 0(uint8) after the transform, however, due to the underflow, it will become 255(uint8) instead.
I fixed this problem by this:
pic = (np.clip(pic.numpy(),0.,1.)*255.).astype(np.uint8)

This is a problem easy to be ignored, I hope you can take a look at it.