Beispiel #1
0
    network_first, network_second, network = create_network(
        batchsize=T.shape[0], window=T.shape[2], hidden=T.shape[1])
    network_func = theano.function([input],
                                   network(input),
                                   allow_input_downcast=True)

    start = time.clock()
    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
Beispiel #2
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)
        
Beispiel #3
0
feet = np.array([9,10,11,12,13,14,21,22,23,24,25,26])

Y = X[:,feet]

batchsize = 1
window = X.shape[2]

network_first = create_regressor(batchsize=batchsize, window=window, input=Y.shape[1], dropout=0.0)
network_second = create_core(batchsize=batchsize, 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)