def get_batch(self, batch_size): x_imgs, y_imgs = self.data.get_batch(batch_size) select_rg = random.choice(['0', '90']) select_axis = random.choice(['0', '1', '2', '-1']) x_en_imgs = utils.enhance_imgs(x_imgs, rotate_rg=int(select_rg), flip_axis=int(select_axis), is_swirl=self.is_swirl) y_en_imgs = utils.enhance_imgs(y_imgs, rotate_rg=int(select_rg), flip_axis=int(select_axis)) return x_en_imgs,y_en_imgs
def enhance_predict(lr_imgs, network=None): outs_list = [] for _, flip_axis in enumerate([0, 1, 2, -1]): for _, rotate_rg in enumerate([0, 90]): en_imgs = utils.enhance_imgs(lr_imgs, rotate_rg, flip_axis) outs = network.predict(en_imgs) anti_outs = utils.anti_enhance_imgs(outs, rotate_rg, flip_axis) outs_list.append(anti_outs) return np.mean(outs_list, axis=0)
def ensem_predict(input_imgs, network): # ensembling outs_list = [] for _, flip_axis in enumerate([0, 1, 2, -1]): for _, rotate_rg in enumerate([0, 90]): en_imgs = utils.enhance_imgs(input_imgs, rotate_rg, flip_axis) outs = network.predict(en_imgs) composed_img = utils.compose_dwt_images(outs, FLAGS.wavelet) anti_outs = utils.anti_enhance_imgs(composed_img, rotate_rg, flip_axis) outs_list.append(anti_outs[0]) output = np.mean(outs_list, axis=0) return [output]