def create_random_mask(self): if self.mask_type == 'random': if self.opt.mask_sub_type == 'fractal': mask = util.create_walking_mask( ) # create an initial random mask. elif self.opt.mask_sub_type == 'rect': mask = util.create_rand_mask() elif self.opt.mask_sub_type == 'island': mask = util.wrapper_gmask(self.opt) return mask
def create_random_mask(self): if self.opt.mask_type == 'random': if self.opt.mask_sub_type == 'fractal': assert 1==2, "It is broken somehow, use another mask_sub_type please" mask = util.create_walking_mask() # create an initial random mask. elif self.opt.mask_sub_type == 'rect': mask, rand_t, rand_l = util.create_rand_mask(self.opt) self.rand_t = rand_t self.rand_l = rand_l return mask elif self.opt.mask_sub_type == 'island': mask = util.wrapper_gmask(self.opt) return mask
import util.util as util import os from PIL import Image import glob mask_folder = 'masks' test_folder = './datasets/Paris/test' util.mkdir(mask_folder) opt = TrainOptions().parse() f = glob.glob(test_folder + '/*.png') print(f) for fl in f: mask = torch.zeros(opt.fineSize, opt.fineSize) if opt.mask_sub_type == 'fractal': mask = util.create_walking_mask() # create an initial random mask. elif opt.mask_sub_type == 'rect': mask, rand_t, rand_l = util.create_rand_mask(opt) elif opt.mask_sub_type == 'island': mask = util.wrapper_gmask(opt) print('Generating mask for test image: ' + os.path.basename(fl)) util.save_image( mask.squeeze().numpy() * 255, os.path.join(mask_folder, os.path.splitext(os.path.basename(fl))[0] + '_mask.png'))