-
Notifications
You must be signed in to change notification settings - Fork 33
/
dataset.py
49 lines (45 loc) · 1.64 KB
/
dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import numpy as np
from scipy.misc import imsave, imresize
def load_dataset(name, root_folder):
data_folder = os.path.join(root_folder, 'data', name)
if name.lower() == 'mnist' or name.lower() == 'fashion':
x = np.load(os.path.join(data_folder, 'train.npy'))
side_length = 28
channels = 1
elif name.lower() == 'cifar10':
x = np.load(os.path.join(data_folder, 'train.npy'))
side_length = 32
channels = 3
elif name.lower() == 'celeba140':
x = np.load(os.path.join(data_folder, 'train.npy'))
side_length = 64
channels = 3
elif name.lower() == 'celeba':
x = np.load(os.path.join(data_folder, 'train.npy'))
side_length = 64
channels = 3
else:
raise Exception('No such dataset called {}.'.format(name))
return x, side_length, channels
def load_test_dataset(name, root_folder):
data_folder = os.path.join(root_folder, 'data', name)
if name.lower() == 'mnist' or name.lower() == 'fashion':
x = np.load(os.path.join(data_folder, 'test.npy'))
side_length = 28
channels = 1
elif name.lower() == 'cifar10':
x = np.load(os.path.join(data_folder, 'test.npy'))
side_length = 32
channels = 3
elif name.lower() == 'celeba140':
x = np.load(os.path.join(data_folder, 'test.npy'))
side_length = 64
channels = 3
elif name.lower() == 'celeba':
x = np.load(os.path.join(data_folder, 'test.npy'))
side_length = 64
channels = 3
else:
raise Exception('No such dataset called {}.'.format(name))
return x, side_length, channels