Skip to content

Commit 6d2423c

Browse files
bodokaisersoumith
authored andcommitted
added copy=False to np.array constructor
1 parent 991bad2 commit 6d2423c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

torchvision/transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def __call__(self, pic):
4343
return img.float().div(255)
4444
# handle PIL Image
4545
if pic.mode == 'I':
46-
img = torch.from_numpy(np.array(pic, np.int32))
46+
img = torch.from_numpy(np.array(pic, np.int32, copy=False))
4747
elif pic.mode == 'I;16':
48-
img = torch.from_numpy(np.array(pic, np.int16))
48+
img = torch.from_numpy(np.array(pic, np.int16, copy=False))
4949
else:
5050
img = torch.ByteTensor(torch.ByteStorage.from_buffer(pic.tobytes()))
5151
# PIL image mode: 1, L, P, I, F, RGB, YCbCr, RGBA, CMYK

0 commit comments

Comments
 (0)