Skip to content

Commit 764ac3b

Browse files
committed
Remove numpy dependency
1 parent e7342bb commit 764ac3b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

imagenet/transforms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import torch
22
import math
33
import random
4-
import numpy as np
54
from PIL import Image
65

76

@@ -17,7 +16,7 @@ def __call__(self, img):
1716

1817
class ToTensor(object):
1918
def __call__(self, pic):
20-
img = torch.ByteTensor(np.asarray(pic, dtype=np.uint8))
19+
img = torch.ByteTensor(torch.ByteStorage.from_buffer(pic.tobytes()))
2120
img = img.view(pic.size[0], pic.size[1], 3)
2221
# put it in CHW format
2322
# yikes, this transpose takes 80% of the loading time/CPU

0 commit comments

Comments
 (0)