Exemple #1
0
    model = Generator(128, [1024, 512, 256, 128, 64, 32], 3)

    ckpt = torch.load(args.cp_path, map_location=lambda storage, loc: storage)
    model.load_state_dict(ckpt['model_state'])

    if args.cuda:
        model = model.cuda()

    print('Cuda Mode is: {}'.format(args.cuda))

    history = ckpt['history']

    if not args.no_plots:
        plot_learningcurves(history, 'gen_loss')
        plot_learningcurves(history, 'disc_loss')
        plot_learningcurves(history, 'gen_loss_minibatch')
        plot_learningcurves(history, 'disc_loss_minibatch')

    test_model(model=model,
               n_tests=args.n_tests,
               cuda_mode=args.cuda,
               SNGAN=True)
    save_samples(prefix='cats',
                 generator=model,
                 cp_name=args.cp_path.split('/')[-1].split('.')[0],
                 cuda_mode=args.cuda,
                 enhance=False,
                 im_size=256,
                 fig_size=(4, 8),
                 SNGAN=True)
Exemple #2
0
    if args.cuda:
        model = model.cuda()

    print('Cuda Mode is: {}'.format(args.cuda))

    history = ckpt['history']

    print('Min FID:', np.min(history['FID-c']))
    print('Epoch with min FID:', np.argmin(history['FID-c']))

    if not args.no_plots:
        plot_learningcurves(history, 'gen_loss')
        plot_learningcurves(history, 'disc_loss')
        plot_learningcurves(history, 'gen_loss_minibatch')
        plot_learningcurves(history, 'disc_loss_minibatch')
        plot_learningcurves(history, 'FID-c')

    test_model(model=model, n_tests=args.n_tests, cuda_mode=args.cuda)
    save_samples(prefix='CIFAR10_DCGAN',
                 generator=model,
                 cp_name=args.cp_path.split('/')[-1].split('.')[0],
                 cuda_mode=args.cuda)

    if args.inception:
        print(
            inception_score(model,
                            N=args.n_inception,
                            cuda=args.cuda,
                            resize=True,
                            splits=10))