示例#1
0
def plotting(predict_joints, predict_groundtruth_seq, X_1):
    for x in range(batch):
        #out_seq=np.array(predict_joints[x].data.tolist()).reshape(-1,66)
        out_seq = np.array(predict_joints[x].data.tolist()).reshape(-1, 66)
        out_gt_seq = np.array(
            predict_groundtruth_seq[x].data.tolist()).reshape(-1, 66)
        print('out_seq size:', out_seq.shape)
        print('out_seq:', out_seq)

    output_format = np.zeros((1, 73))
    output_format[:out_seq.shape[0], :out_seq.shape[1]] = out_seq
    print('output_format:', output_format.shape)
    output = output_format[:, :, np.newaxis]
    print('output:', output.shape)

    output_gt_format = np.zeros((1, 73))
    output_gt_format[:out_gt_seq.shape[0], :out_gt_seq.shape[1]] = out_gt_seq
    print('output_format:', output_gt_format.shape)
    output_gt = output_gt_format[:, :, np.newaxis]
    print('output:', output_gt.shape)

    preprocess_data = np.load('D:/motionsynth_data/synth/preprocess_core.npz')
    output = (output * preprocess_data['Xstd']) + preprocess_data['Xmean']
    output_gt = (output_gt *
                 preprocess_data['Xstd']) + preprocess_data['Xmean']
    X_1 = (X_1 * preprocess_data['Xstd']) + preprocess_data['Xmean']

    from AnimationPlot import animation_plot

    animation_plot([output, output_gt, X_1], interval=15.15)
示例#2
0
def run(*args):
    for i in range(1):
        start = time.time()
        Xbasis0 = np.zeros((1, 256, window // 2), dtype=theano.config.floatX)
        Xbasis1 = np.zeros((1, 256, window // 2), dtype=theano.config.floatX)
        Xbasis2 = np.zeros((1, 256, window // 2), dtype=theano.config.floatX)

        Xbasis0[:, i * 3 +
                0] = 1 + 2 * np.sin(np.linspace(0.0, np.pi * 8, window // 2))
        Xbasis1[:, i * 3 +
                1] = 1 + 2 * np.sin(np.linspace(0.0, np.pi * 8, window // 2))
        Xbasis2[:, i * 3 +
                2] = 1 + 2 * np.sin(np.linspace(0.0, np.pi * 8, window // 2))

        Xbasis0 = np.array(network[1](theano.shared(Xbasis0,
                                                    borrow=True)).eval())
        a = (theano.shared(Xbasis0, borrow=True)).eval()
        print a, a.shape
        Xbasis1 = np.array(network[1](theano.shared(Xbasis1,
                                                    borrow=True)).eval())
        b = (theano.shared(Xbasis1, borrow=True)).eval()
        print b, b.shape
        Xbasis2 = np.array(network[1](theano.shared(Xbasis2,
                                                    borrow=True)).eval())

        Xbasis0 = (Xbasis0 * preprocess['Xstd']) + preprocess['Xmean']
        Xbasis1 = (Xbasis1 * preprocess['Xstd']) + preprocess['Xmean']
        Xbasis2 = (Xbasis2 * preprocess['Xstd']) + preprocess['Xmean']
        print start - time.time()
        animation_plot([Xbasis0, Xbasis1, Xbasis2], interval=15.15)
def plotting(predict_joints, predict_groundtruth_seq, X_1):

    reshape = feet = np.array([
        15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 12, 13, 14,
        9, 10, 11, 6, 7, 8, 3, 4, 5, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
        43, 44, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 63, 64, 65, 66,
        67, 68, 69, 70, 71, 72, 73, 74
    ])
    predict_joints = predict_joints[:, reshape]
    predict_groundtruth_seq = predict_groundtruth_seq[:, reshape]
    for x in range(batch):
        #out_seq=np.array(predict_joints[x].data.tolist()).reshape(-1,66)
        out_seq = np.array(predict_joints[x].data.tolist()).reshape(-1, 66)
        out_gt_seq = np.array(
            predict_groundtruth_seq[x].data.tolist()).reshape(-1, 66)
        print('out_seq size:', out_seq.shape)
        print('out_seq:', out_seq)

    output_format = np.zeros((1, 73))
    output_format[:out_seq.shape[0], :out_seq.shape[1]] = out_seq
    print('output_format:', output_format.shape)
    output = output_format[:, :, np.newaxis]
    print('output:', output.shape)

    output_gt_format = np.zeros((1, 73))
    output_gt_format[:out_gt_seq.shape[0], :out_gt_seq.shape[1]] = out_gt_seq
    print('output_format:', output_gt_format.shape)
    output_gt = output_gt_format[:, :, np.newaxis]
    print('output:', output_gt.shape)

    preprocess_data = np.load('D:/motionsynth_data/synth/preprocess_core.npz')
    output = (output * preprocess_data['Xstd']) + preprocess_data['Xmean']
    output_gt = (output_gt *
                 preprocess_data['Xstd']) + preprocess_data['Xmean']
    X_1 = (X_1 * preprocess_data['Xstd']) + preprocess_data['Xmean']

    from AnimationPlot import animation_plot

    animation_plot([output, output_gt, X_1], interval=15.15)

for i in range(10):
    Xbasis0 = np.zeros((1, 256, window // 2))
    Xbasis1 = np.zeros((1, 256, window // 2))
    Xbasis2 = np.zeros((1, 256, window // 2))

    Xbasis0[:, i * 3 +
            0] = 1 + 2 * np.sin(np.linspace(0.0, np.pi * 8, window // 2))
    Xbasis1[:, i * 3 +
            1] = 1 + 2 * np.sin(np.linspace(0.0, np.pi * 8, window // 2))
    Xbasis2[:, i * 3 +
            2] = 1 + 2 * np.sin(np.linspace(0.0, np.pi * 8, window // 2))

    Xbasis0 = decoder(network,
                      torch.from_numpy(Xbasis0).cuda().to(dtype=torch.float))
    Xbasis1 = decoder(network,
                      torch.from_numpy(Xbasis1).cuda().to(dtype=torch.float))
    Xbasis2 = decoder(network,
                      torch.from_numpy(Xbasis2).cuda().to(dtype=torch.float))

    Xbasis0 = Xbasis0.cpu().numpy()
    Xbasis1 = Xbasis1.cpu().numpy()
    Xbasis2 = Xbasis2.cpu().numpy()

    Xbasis0 = (Xbasis0 * preprocess['Xstd']) + preprocess['Xmean']
    Xbasis1 = (Xbasis1 * preprocess['Xstd']) + preprocess['Xmean']
    Xbasis2 = (Xbasis2 * preprocess['Xstd']) + preprocess['Xmean']

    animation_plot([Xbasis0, Xbasis1, Xbasis2], interval=15.15)
示例#5
0
        dtype=theano.config.floatX) * preprocess['Xstd']) + preprocess['Xmean']
    
    def style_transfer(H, V):
        s, c =  style_amount, 1.0
        s, c = s / (s + c), c / (s + c)
        return s * T.mean((gram_matrix(H) - G)**2) + c * T.mean((H - network_C[0](C))**2)

    Xstyl = (S * preprocess['Xstd']) + preprocess['Xmean']
    Xcntn = (C * preprocess['Xstd']) + preprocess['Xmean']
    Xtrsf = N
    Xtrsf = constrain(Xtrsf, network_C[0], network_C[1], preprocess, style_transfer, iterations=250, alpha=0.01)
    
    Xtrsfvel = np.mean(np.sqrt(Xtrsf[:,-7:-6]**2 + Xtrsf[:,-6:-5]**2), axis=2)[:,:,np.newaxis]
    Xcntnvel = np.mean(np.sqrt(Xcntn[:,-7:-6]**2 + Xcntn[:,-6:-5]**2), axis=2)[:,:,np.newaxis]
    
    Xtail = Xtrsfvel * (Xcntn[:,-7:] / Xcntnvel)
    Xtail[:,-5:] = Xcntn[:,-5:]
    
    Xtrsf = constrain(Xtrsf, network_C[0], network_C[1], preprocess, multiconstraint(
        foot_sliding(Xtail[:,-4:]),
        joint_lengths(),
        trajectory(Xtail[:,:3])), alpha=0.01, iterations=100)
    Xtrsf[:,-7:] = Xtail
    
    Xstyl = np.concatenate([Xstyl, Xstyl], axis=2)
    
    from AnimationPlot import animation_plot
    
    animation_plot([Xstyl, Xcntn, Xtrsf], interval=15.15)
        
示例#6
0
batchsize = 1
window = X.shape[2]

X = theano.shared(X, borrow=True)

network = create_core(batchsize=batchsize, window=window, dropout=0.0, depooler=lambda x,**kw: x/2)
network.load(np.load('network_core.npz'))

from AnimationPlot import animation_plot

for _ in range(10):

    index = rng.randint(X.shape[0].eval())
    Xorgi = np.array(X[index:index+1].eval())
    Xnois = Xorgi.copy()
    Xnois[:,16*3-1:17*3] = 0.0
    Xrecn = np.array(network(Xnois).eval())    

    Xorgi = (Xorgi * preprocess['Xstd']) + preprocess['Xmean']
    Xnois = (Xnois * preprocess['Xstd']) + preprocess['Xmean']
    Xrecn = (Xrecn * preprocess['Xstd']) + preprocess['Xmean']

    Xrecn = constrain(Xrecn, network[0], network[1], preprocess, multiconstraint(
        foot_sliding(Xorgi[:,-4:].copy()),
        joint_lengths(),
        trajectory(Xorgi[:,-7:-4])), alpha=0.01, iterations=50)

    Xrecn[:,-7:-4] = Xorgi[:,-7:-4]
        
    animation_plot([Xnois, Xrecn, Xorgi], interval=15.15)
        
示例#7
0
    X = network_func(T)
    X = (X * preprocess['Xstd']) + preprocess['Xmean']
    Xtail = (T * preprocess['Xstd'][:, -7:]) + preprocess['Xmean'][:, -7:]
    X = constrain(X,
                  network_second[0],
                  network_second[1],
                  preprocess,
                  multiconstraint(foot_sliding(Xtail[:, -4:]), joint_lengths(),
                                  trajectory(Xtail[:, :3])),
                  alpha=0.01,
                  iterations=10)
    X[:, -7:] = Xtail

    #############

    animation_plot([X[0:1, :, :200], X[10:11, :, :200], X[20:21, :, :200]],
                   interval=15.15)

    X = np.swapaxes(X, 1, 2)

    joints = X[:, :, :-7].reshape((X.shape[0], X.shape[1], -1, 3))
    joints = -Quaternions(
        data[scene + '_rot'][:, cstart:cend])[:, :, np.newaxis] * joints
    joints[:, :, :,
           0] += data[scene + '_pos'][:, cstart:cend][:, :,
                                                      np.newaxis][:, :, :, 0]
    joints[:, :, :,
           2] += data[scene + '_pos'][:, cstart:cend][:, :,
                                                      np.newaxis][:, :, :, 2]

    #np.savez_compressed('./videos/crowd/'+scene+'.npz', X=joints)
示例#8
0
    #Y shape:(1,12,240)
    network_func = theano.function([], network(Y[i:i + 1]))
    Y_pad_ori = np.array(Y_pad[i:i + 1])
    Xorig = np.array(X[i:i + 1])
    print('X shape: ', X.shape)
    #X shape: 121,73,240
    print('Xorig shape: ', Xorig.shape)
    #Xorig shape : 1,73,240
    start = time.clock()
    print('before network_func')
    Xrecn = network_func()
    # meaning that Y is inserted into network function then output will be Xrecn
    print('Xrecn shape: ', Xrecn.shape)
    #Xrecn shape: (1,73,240)
    Xorig = (Xorig * preprocess['Xstd']) + preprocess['Xmean']
    Xrecn = (Xrecn * preprocess['Xstd']) + preprocess['Xmean']
    Y_pad_ori = (Y_pad_ori * preprocess['Xstd']) + preprocess['Xmean']
    print
    print('before constrain')
    #here Xrecn already same as Xorig, but next is add constraint
    Xrecn = constrain(Xrecn,
                      network_second[0],
                      network_second[1],
                      preprocess,
                      multiconstraint(foot_sliding(Xrecn[:, -4:].copy()),
                                      joint_lengths()),
                      alpha=0.01,
                      iterations=50)
    #print(data_kicking_cmu[i])
    animation_plot([Xorig], interval=15.15)
示例#9
0
    print('Footsteps: %0.4f' % (time.clock() - start))

    #############

    network_first, network_second, network = create_network(
        Torig.shape[2], Torig.shape[1])
    network_func = theano.function([input],
                                   network(input),
                                   allow_input_downcast=True)

    start = time.clock()
    Xrecn = network_func(Torig)
    Xrecn = (Xrecn * preprocess['Xstd']) + preprocess['Xmean']
    Xtraj = ((Torig * preprocess['Xstd'][:, -7:]) +
             preprocess['Xmean'][:, -7:]).copy()
    print('Synthesis: %0.4f' % (time.clock() - start))

    Xnonc = Xrecn.copy()
    Xrecn = constrain(Xrecn,
                      network_second[0],
                      network_second[1],
                      preprocess,
                      multiconstraint(foot_sliding(Xtraj[:, -4:]),
                                      trajectory(Xtraj[:, :3]),
                                      joint_lengths()),
                      alpha=0.01,
                      iterations=250)
    Xrecn[:, -7:] = Xtraj

    animation_plot([Xnonc, Xrecn], interval=15.15)
                             window=window,
                             dropout=0.0,
                             depooler=lambda x, **kw: x / 2)
network_second.load(np.load('network_core.npz'))
network = Network(network_first,
                  network_second[1],
                  params=network_first.params)
network.load(np.load('network_regression_kick.npz'))

from AnimationPlot import animation_plot

for i in range(len(X)):

    network_func = theano.function([], network(Y[i:i + 1]))

    Xorig = np.array(X[i:i + 1])
    start = time.clock()
    Xrecn = network_func()
    Xorig = (Xorig * preprocess['Xstd']) + preprocess['Xmean']
    Xrecn = (Xrecn * preprocess['Xstd']) + preprocess['Xmean']
    Xrecn = constrain(Xrecn,
                      network_second[0],
                      network_second[1],
                      preprocess,
                      multiconstraint(foot_sliding(Xrecn[:, -4:].copy()),
                                      joint_lengths()),
                      alpha=0.01,
                      iterations=50)

    animation_plot([Xorig, Xrecn], interval=15.15)