-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
47 lines (40 loc) · 1.47 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import tensorflow as tf
import tensorflow.contrib.slim as slim
import numpy as np
import h5py
import matplotlib.pyplot as plt
import os
import argparse
import random
from util import *
from ops import *
from models import *
from train import *
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('model_path', type=str)
parser.add_argument('input_frame_path', type=str)
parser.add_argument('input_action_path', type=str)
parser.add_argument('output_path', type=str)
parser.add_argument('--dna', action='store_true')
sess = tf.InteractiveSession()
queue_runners = tf.train.start_queue_runners(sess)
trainer = Trainer(sess, True, 'bce', 'adam', parser.dna)
init_op = tf.global_variables_initializer()
sess.run(init_op)
saver = tf.train.Saver()
saver.restore(sess, tf.train.latest_checkpoint(parser.model_path))
seq = np.load(parser.input_frame_path)
act = np.load(parser.input_action_path)
seq_batch = seq[32:96]
act_batch = act[32:96]
test_g_out, gt = trainer.test_sequence(seq_batch[:,6:],
seq_batch[:,6:],
act_batch[:,6:])
for i in range(test_g_out.shape[1]):
save_samples(parser.output_path,
seq_batch[:,[6 + (i+1)*2 for i in range(6)]],
test_g_out,
np.array([0]),
i,
gif=True)