Commit 6d2423c7 authored by Bodo Kaiser's avatar Bodo Kaiser Committed by Soumith Chintala
Browse files

added copy=False to np.array constructor

parent 991bad2f
...@@ -43,9 +43,9 @@ class ToTensor(object): ...@@ -43,9 +43,9 @@ class ToTensor(object):
return img.float().div(255) return img.float().div(255)
# handle PIL Image # handle PIL Image
if pic.mode == 'I': if pic.mode == 'I':
img = torch.from_numpy(np.array(pic, np.int32)) img = torch.from_numpy(np.array(pic, np.int32, copy=False))
elif pic.mode == 'I;16': elif pic.mode == 'I;16':
img = torch.from_numpy(np.array(pic, np.int16)) img = torch.from_numpy(np.array(pic, np.int16, copy=False))
else: else:
img = torch.ByteTensor(torch.ByteStorage.from_buffer(pic.tobytes())) img = torch.ByteTensor(torch.ByteStorage.from_buffer(pic.tobytes()))
# PIL image mode: 1, L, P, I, F, RGB, YCbCr, RGBA, CMYK # PIL image mode: 1, L, P, I, F, RGB, YCbCr, RGBA, CMYK
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment