We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1fe1709 commit 3fbe21eCopy full SHA for 3fbe21e
1 file changed
torchvision/transforms/functional.py
@@ -206,10 +206,7 @@ def pil_to_tensor(pic: Any) -> Tensor:
206
return torch.as_tensor(nppic)
207
208
# handle PIL Image
209
- img = np.array(pic, copy=True)
210
- if pic.mode == "I;16":
211
- img = img.astype(np.uint16)
212
- img = torch.as_tensor(img)
+ img = torch.as_tensor(np.array(pic, copy=True))
213
img = img.view(pic.size[1], pic.size[0], F_pil.get_image_num_channels(pic))
214
# put it from HWC to CHW format
215
img = img.permute((2, 0, 1))
0 commit comments