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

Method load_data

One_Day_One_GAN/day6/srgan/data_loader.py:11–40  ·  view source on GitHub ↗
(self, batch_size=1, is_testing=False)

Source from the content-addressed store, hash-verified

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

Callers 8

trainMethod · 0.45
trainMethod · 0.45
trainMethod · 0.45
trainMethod · 0.45
trainMethod · 0.45
sample_imagesMethod · 0.45
trainMethod · 0.45
trainMethod · 0.45

Calls 1

imreadMethod · 0.95

Tested by

no test coverage detected