Skip to content

Commit 3fbe21e

Browse files
committed
remove redundant astype in pil_to_tensor
1 parent 1fe1709 commit 3fbe21e

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

torchvision/transforms/functional.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@ def pil_to_tensor(pic: Any) -> Tensor:
206206
return torch.as_tensor(nppic)
207207

208208
# 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)
209+
img = torch.as_tensor(np.array(pic, copy=True))
213210
img = img.view(pic.size[1], pic.size[0], F_pil.get_image_num_channels(pic))
214211
# put it from HWC to CHW format
215212
img = img.permute((2, 0, 1))

0 commit comments

Comments
 (0)