def get_args(): parser = argparse.ArgumentParser() parser.add_argument('--gpu', help='comma separated list of GPU(s) to use.') parser.add_argument('--load', help='load model') parser.add_argument('--sample', action='store_true', help='view generated examples') parser.add_argument('--data', help='a jpeg directory') parser.add_argument('--load-size', help='size to load the original images', type=int) parser.add_argument('--crop-size', help='crop the original images', type=int) args = parser.parse_args() use_global_argument(args) if args.gpu: os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu return args
img = func([[z]])[0][0][:, :, ::-1] img = (img + 1) * 128 imgs.append(img) viz = next(build_patch_list(imgs, nr_row=1, nr_col=4, viz=True)) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--gpu', help='comma separated list of GPU(s) to use.') parser.add_argument('--load', help='load model') parser.add_argument('--sample', action='store_true', help='run sampling') parser.add_argument('--vec', action='store_true', help='run vec arithmetic demo') parser.add_argument( '--data', help='`image_align_celeba` directory of the celebA dataset') args = parser.parse_args() use_global_argument(args) if args.gpu: os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu if args.sample: sample(args.load) elif args.vec: vec(args.load) else: assert args.data config = get_config() if args.load: config.session_init = SaverRestore(args.load) GANTrainer(config, g_vs_d=1).train()