def test_save_image(self): arr = jt.array(np.random.randn(16, 3, 10, 10)) jt.save_image(arr, "/tmp/a.jpg")
parser.add_argument('--n_col', type=int, default=5, help='number of columns of sample matrix') parser.add_argument('path', type=str, help='path to checkpoint file') args = parser.parse_args() generator = StyledGenerator(512) ckpt = jt.load(args.path) generator.load_state_dict(ckpt) generator.eval() mean_style = get_mean_style(generator) step = int(math.log(args.size, 2)) - 2 img = sample(generator, step, mean_style, args.n_row * args.n_col) jt.save_image(img, 'style_mixing/sample.png', nrow=args.n_col, normalize=True, range=(-1, 1)) for j in range(20): img = style_mixing(generator, step, mean_style, args.n_col, args.n_row) jt.save_image(img, f'style_mixing/sample_mixing_{j}.png', nrow=args.n_col + 1, normalize=True, range=(-1, 1))
def test_save_image(self): arr = jt.array(np.random.randn(16, 3, 10, 10)) jt.save_image(arr, jt.flags.cache_path + "/tmp/a.jpg")
used_sample += real_image.shape[0] if (i + 1) % 100 == 0: images = [] gen_i, gen_j = (10, 5) with jt.no_grad(): for _ in range(gen_i): images.append( g_running(jt.randn(gen_j, code_size), step=step, alpha=alpha).data) jt.save_image( jt.concat(images, 0), f'FFHQ/sample/{str(i + 1).zfill(6)}.png', nrow=gen_i, normalize=True, range=(-1, 1), ) if (i + 1) % 10000 == 0: jt.save(g_running.state_dict(), f'FFHQ/checkpoint/{str(i + 1).zfill(6)}.model') state_msg = ( f'Size: {4 * 2 ** step}; G: {gen_loss_val:.3f}; D: {disc_loss_val:.3f};' f' Grad: {grad_loss_val:.3f}; Alpha: {alpha:.5f}') pbar.set_description(state_msg)