Still not fixed in pyTorch 1.6.0 and torchvision 0.7.0, trying to load a PIL image as a Tensor succeeds but prints this warning. My guess is that Torchvision transform pil_to_tensor tries to create a Tensor that inherits the underlying numpy storage from the PIL Image, which is marked as read-only, and since a Tensor can’t be read-only, it has to print the warning.
pic = Image.open(fn).convert(mode=‘L’)
tensor = tvt.functional.pil_to_tensor(img).type(torch.ByteTensor)
=> the warning, ending with:
(Triggered internally at /pytorch/torch/csrc/utils/tensor_numpy.cpp:141.)
img = torch.as_tensor(np.asarray(pic))