(self, batch_size=1, is_testing=False)
| 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): |
no test coverage detected