Example #1
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)
        
Example #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)
        
# 2021
# 13283

for _ in range(10):

    index = rng.randint(X.shape[0].eval())
    print(index)
    Xorgi = np.array(X[index:index + 1].eval())
    Xnois = ((Xorgi * rng.binomial(size=Xorgi.shape, n=1, p=0.5)) /
             0.5).astype(theano.config.floatX)
    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)
Example #4
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
    joints[:, :, :,
Example #5
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)
Example #6
0
            4], Xkinect[index + 3:index + 4, :,
                        Xkinect.shape[2] // 4:-Xkinect.shape[2] // 4],
    Xkinect[index + 4:index + 5, :, Xkinect.shape[2] // 4:-Xkinect.shape[2] //
            4], Xkinect[index + 5:index + 6, :,
                        Xkinect.shape[2] // 4:-Xkinect.shape[2] // 4],
    Xkinect[index + 6:index + 7, :, Xkinect.shape[2] // 4:-Xkinect.shape[2] //
            4], Xkinect[index + 7:index + 8, :,
                        Xkinect.shape[2] // 4:-Xkinect.shape[2] // 4]
],
                            axis=2)

Xorgi = np.array(Xsensclip.eval())
Xnois = np.array(Xkinectclip.eval())
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].copy())),
                  alpha=0.01,
                  iterations=100)

animation_plot([Xnois, Xrecn, Xorgi], interval=15.15)
Example #7
0
 Xrecn = np.concatenate([Xrecn_Torso[:,0:3,:], Xrecn_Leftleg, Xrecn_Rightleg, Xrecn_Torso[:,3:15,:], Xrecn_Leftarm, Xrecn_Rightarm, Xorgi[:,63:73,:]], axis=1)
 
 
 Xorgi = (Xorgi * preprocess['Xstd']) + preprocess['Xmean']
 Xnois = (Xnois * preprocess['Xstd']) + preprocess['Xmean']
 Xrecn = (Xrecn * preprocess['Xstd']) + preprocess['Xmean']
 
 np.save("./denoise/Xorgi.npy",Xorgi)
 np.save("./denoise/Xnois.npy",Xnois)
 
 print(Xorgi[:,-7:-4].shape)
 # H'=argmin[Pos(H)+Bone(H)+Traj(H)]
 Xrecn = constrain(Xrecn, network[0], network[1], preprocess, multiconstraint(
     foot_sliding(Xorgi[:,-4:].copy()),#foot sliding information(-4,-3,-2,-1)
     joint_lengths(),
     trajectory(Xorgi[:,-7:-4])), alpha=0.01, iterations=50)#input trajectory(-7,-6,-5)
 
 Xrecn[:,-7:-4] = Xorgi[:,-7:-4]
 
 np.save("./denoise/Xrecn.npy",Xrecn)
 print("construction done")
 
 animation_plot([Xnois, Xrecn, Xorgi], interval=15.15)
 
 """
 Xnois = ((Xorgi * rng.binomial(size=Xorgi.shape, n=1, p=0.5)) / 0.5).astype(theano.config.floatX)
 #Xnois = (Xorgi + 0.05*np.random.randn(1,73,240)+0.1).astype(theano.config.floatX)
 Xrecn = np.array(network(Xnois).eval())    
 #print(Xrecn.shape)
 """
 """