MCPcopy Create free account
hub / github.com/OUCMachineLearning/OUCML / load_data

Method load_data

GAN/srgan_celebA/data_loader.py:12–41  ·  view source on GitHub ↗
(self, batch_size=1, is_testing=False)

Source from the content-addressed store, hash-verified

10 self.img_res = img_res
11
12 def load_data(self, batch_size=1, is_testing=False):
13 data_type = "train" if not is_testing else "test"
14
15 path = glob('./datasets/%s/*' % (self.dataset_name))
16
17 batch_images = np.random.choice(path, size=batch_size)
18
19 imgs_hr = []
20 imgs_lr = []
21 for img_path in batch_images:
22 img = self.imread(img_path)
23
24 h, w = self.img_res
25 low_h, low_w = int(h / 4), int(w / 4)
26
27 img_hr = scipy.misc.imresize(img, self.img_res)
28 img_lr = scipy.misc.imresize(img, (low_h, low_w))
29
30 # If training => do random flip
31 if not is_testing and np.random.random() < 0.5:
32 img_hr = np.fliplr(img_hr)
33 img_lr = np.fliplr(img_lr)
34
35 imgs_hr.append(img_hr)
36 imgs_lr.append(img_lr)
37
38 imgs_hr = np.array(imgs_hr) / 127.5 - 1.
39 imgs_lr = np.array(imgs_lr) / 127.5 - 1.
40
41 return imgs_hr, imgs_lr
42
43
44 def imread(self, path):

Callers 10

trainMethod · 0.45
trainMethod · 0.45
trainMethod · 0.45
trainMethod · 0.45
trainMethod · 0.45
trainMethod · 0.45
load_mnistFunction · 0.45
load_cifar10Function · 0.45
trainMethod · 0.45
sample_imagesMethod · 0.45

Calls 1

imreadMethod · 0.95

Tested by

no test coverage detected