Esempio n. 1
0
    def test_sequence_keyframes_linear_random_batch(self):
        n_keyframes = 10
        n_vector = 100
        n_label = 1000
        num_frames = 100
        batch_size = 7  # pick something that doesn't divide num_frames
        batch_div = int(num_frames // batch_size)
        batch_rem = 1 if int(num_frames % batch_size) > 0 else 0
        batch_count = batch_div + batch_rem
        keyframes = np.asarray([
            create_random_keyframe(n_vector, n_label)
            for i in range(n_keyframes)
        ])
        z, label, trunc = latent_space.sequence_keyframes(
            keyframes,
            num_frames,
            batch_size=batch_size,
            interp_method='linear')

        assert (num_frames == z.shape[0]),\
                'z sequence: target frame count: %s; actual shape: %s' % (num_frames, z.shape)
        assert (num_frames == label.shape[0]),\
                'label sequence: target frame count: %s; actual shape: %s' % (num_frames, label.shape)
        assert (batch_count == trunc.shape[0]),\
                'trunc sequence: target frame count: %s; actual shape: %s' % (batch_count, trunc.shape)
Esempio n. 2
0
def main():
    args = handle_args()
    # get animation keyframes from ganbreeder
    print('Downloading keyframe info from ganbreeder...')
    keyframes = ganbreeder.get_info_batch(args.username, args.password, args.keys)

    # interpolate path through input space
    print('Interpolating path through input space...')
    try:
        z_seq, label_seq, truncation_seq = latent_space.sequence_keyframes(
                keyframes,
                args.nframes,
                batch_size=args.nbatch,
                interp_method=args.interp,
                loop=args.loop)
    except ValueError as e:
        print(e)
        print('ERROR: Interpolation failed. Make sure you are using at least 3 keys (4 if --no-loop is enabled)')
        print('If you would like to use fewer keys, try using the --interp linear argument')
        return 1

    # sample the GAN
    print('Loading bigGAN...')
    gan = biggan.BigGAN()

    path = '' if args.output_dir == None else str(args.output_dir)
    prefix = '' if args.prefix == None else str(args.prefix)
    saver = image_utils.ImageSaver(output_dir=path, prefix=prefix)
    print('Image files will be saved to: '+path + prefix)
    print('Sampling from bigGAN...')
    gan.sample(z_seq, label_seq, truncation=truncation_seq, batch_size=args.nbatch, save_callback=saver.save)
    print('Done.')
    return 0
Esempio n. 3
0
    def test_sequence_keyframes_linear_random_basic(self):
        n_keyframes = 10
        n_vector = 100
        n_label = 1000
        num_frames = 100
        keyframes = np.asarray([
            create_random_keyframe(n_vector, n_label)
            for i in range(n_keyframes)
        ])
        z, label, trunc = latent_space.sequence_keyframes(
            keyframes, num_frames, batch_size=1, interp_method='linear')

        assert (num_frames == z.shape[0]),\
                'z sequence: target frame count: %s; actual shape: %s' % (num_frames, z.shape)
        assert (num_frames == label.shape[0]),\
                'label sequence: target frame count: %s; actual shape: %s' % (num_frames, label.shape)
        assert (num_frames == trunc.shape[0]),\
                'trunc sequence: target frame count: %s; actual shape: %s' % (num_frames, trunc.shape)
Esempio n. 4
0
 def test_sequence_keyframes_cubic_random_batch_oob(self):
     n_keyframes = 10
     n_vector = 100
     n_label = 1000
     num_frames = 100
     batch_size = 150  # pick something that doesn't divide num_frames
     batch_div = int(num_frames // batch_size)
     batch_rem = 1 if int(num_frames % batch_size) > 0 else 0
     batch_count = batch_div + batch_rem
     keyframes = np.asarray([
         create_random_keyframe(n_vector, n_label)
         for i in range(n_keyframes)
     ])
     z, label, trunc = latent_space.sequence_keyframes(
         keyframes,
         num_frames,
         batch_size=batch_size,
         interp_method='cubic')