MCPcopy Create free account
hub / github.com/CausalLearning/robust-unlearnable-examples / datasetTinyImageNet

Function datasetTinyImageNet

utils/data.py:82–109  ·  view source on GitHub ↗
(root='./path', train=True, transform=None)

Source from the content-addressed store, hash-verified

80 transform=transform, download=True)
81
82def datasetTinyImageNet(root='./path', train=True, transform=None):
83 if train: root = os.path.join(root, 'tiny-imagenet_train.pkl')
84 else: root = os.path.join(root, 'tiny-imagenet_val.pkl')
85 with open(root, 'rb') as f:
86 dat = pickle.load(f)
87 return Dataset(dat['data'], dat['targets'], transform)
88 # root = os.path.join(root, 'tiny-imagenet-200')
89 # if train: root = os.path.join(root, 'train')
90 # else: root = os.path.join(root, 'val', 'images')
91 # raw_dataset = torchvision.datasets.ImageFolder(root)
92 # xx, yy = [], []
93 # for i in range( len(raw_dataset) ):
94 # x, y = raw_dataset[i]
95 # x = np.array(x)
96 # xx.append( x.reshape(1, *x.shape) )
97 # yy.append( y )
98 # xx = np.concatenate(xx)
99 # yy = np.array(yy)
100
101 # dat = {'data':xx, 'targets':yy}
102 # if train: save_name = 'tiny-imagenet_train.pkl'
103 # else: save_name = 'tiny-imagenet_val.pkl'
104
105 # import pickle
106 # with open('./data/{}'.format(save_name), 'wb') as f:
107 # pickle.dump(dat, f)
108 # exit()
109 # return Dataset(xx, yy, transform)
110
111
112class Loader():

Callers

nothing calls this directly

Calls 1

DatasetClass · 0.70

Tested by

no test coverage detected