def __call__(self, skeleton):
        predicted = Data(np.zeros_like(self.output_norm[0]), self.output_norm,
                         "output")

        x = torch.from_numpy(skeleton.local.normed()[None]).cuda()
        y = self.model(x).cpu().detach().numpy()[0]
        predicted.set_normed(y)

        return predicted
Esempio n. 2
0
def load_data():
    # Loading
    data = np.load('data/test16.npy').astype(np.float32)
    sequences = np.loadtxt('./data/TestSequences.txt')
    input_norm = np.load('data/input_norm.npy').astype(np.float32)
    output_norm = np.load('data/output_norm.npy').astype(np.float32)

    # Normalize
    input_data = Data(data[:, :input_norm.shape[1]], input_norm, "input",
                      sequences)
    output_data = Data(data[:, input_norm.shape[1]:], output_norm, "output",
                       sequences)

    return input_data, output_data
    def __call__(self, skeleton):
        # x = torch.from_numpy(skeleton.local.normed()[None]).cuda()

        # if self.X is None:
        #     self.X = x

        # y = self.model(x).cpu().detach().numpy()[0]

        x = skeleton.local.normed()[:575]
        if self.x is None:
            self.x = np.zeros((100, len(x)))
            self.x[:] = x
        self.x[:-1] = self.x[1:]
        self.x[-1] = x

        prediction_normed = self.model.predict(self.x)

        # prediction_normed = self.model.predict(input_numpy[:100, :575])

        prediction = skeleton.local.copy()
        prediction = Data(np.zeros(575), self.input_norm[:, :575], "input")
        prediction.set_normed(prediction_normed[0])

        return prediction
    parser.add_argument("--show-phase", action="store_true", default=False, help = "Visualize the phase")
    parser.add_argument("--show-input", action="store_true", default=False, help = "Visualize the actual input to the network")
    parser.add_argument("--hide-output", action="store_true", default=False, help = "Do not show the output frame")
    
    args = parser.parse_args()
    start = 240 * args.starting_clip
    size = 240 * args.n

    # Loading
    data = np.load('data/test16.npy').astype(np.float32)
    sequences = np.loadtxt('./data/TestSequences.txt')
    input_norm = np.load('data/input_norm.npy').astype(np.float32)
    output_norm = np.load('data/output_norm.npy').astype(np.float32)
    
    # Normalize
    input_data = Data(data[:,:input_norm.shape[1]], input_norm, "input", sequences)
    output_data = Data(data[:,input_norm.shape[1]:], output_norm, "output", sequences)

    clip_idx = 24
    clip = input_data(clip_idx)
    clip_out = output_data(clip_idx)

    current = clip[0]

    model = torch.load(args.model_name).cuda()
    model.input_shape = [419,156,2034,2048,650]
    
    frames = []
    predicted = Data(clip_out[0].data, output_norm, "output")
    
    for i in range(len(clip)):
Esempio n. 5
0
                print('%d %s (%d %d%%) %.4f' %
                      (iter, timeSince(start_time, iter / n_iters), iter,
                       iter / n_iters * 100, print_loss_avg))

            if iter % plot_every == 0:
                plot_loss_avg = plot_loss_total / plot_every
                plot_losses.append(plot_loss_avg)
                plot_loss_total = 0
    except KeyboardInterrupt:
        print("Stopped")

    showPlot(plot_losses)
    torch.save(encoder, "models/seq2seq/%d/encoder.pt" % model_idx)
    torch.save(decoder, "models/seq2seq/%d/decoder.pt" % model_idx)


if __name__ == "__main__":
    model_idx = 3
    data = np.load('./data/train16.npy')
    sequences = np.loadtxt('./data/TrainSequences.txt')

    input_data = Data(data, np.load('./data/input_norm.npy'), "input",
                      sequences)
    output_data = Data(data, np.load('./data/output_norm.npy'), "output",
                       sequences)

    hidden_size = 256
    encoder1 = EncoderRNN(575, hidden_size).to(device)
    decoder1 = DecoderRNN(hidden_size, 575).to(device)

    train(encoder1, decoder1, 75000, print_every=10)
Esempio n. 6
0
import unicodedata
import string
import re
import random

import torch
import torch.nn as nn
from torch import optim
import torch.nn.functional as F

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

data = np.load('./data/test16.npy')
sequences = np.loadtxt('./data/TestSequences.txt')

input_data = Data(data, np.load('./data/input_norm.npy'), "input", sequences)
output_data = Data(data, np.load('./data/output_norm.npy'), "output", sequences)

class Seq2Seq:
    def __init__(self):
        self.MAX_LENGTH = 100
        self.input_size = 575
        self.encoder = torch.load('models/seq2seq/1/encoder.pt')
        self.decoder = torch.load('models/seq2seq/1/decoder.pt')

    def encode(self, input_tensor):
        encoder_hidden = self.encoder.initHidden()
        input_length = input_tensor.size(0)
        encoder_outputs = torch.zeros(MAX_LENGTH, self.encoder.hidden_size).cuda()

        for ei in range(input_length):
from src.viz import GLWindow
import numpy as np
from src.gl import *
from src.data.ShapeManager import Data

frame_idx = 0

def draw():
    draw_ground(2)
    global frame_idx
    draw_skeleton(data[frame_idx].bone_position)
    frame_idx += 1
    if frame_idx == len(data):
        frame_idx = 0
    window.frame_idx = frame_idx

def update():
    # glRotate(1,1,1,1)
    pass

dims = 276
norm = np.load('./data/input_norm.npy')

if len(sys.argv) > 1:
    data = np.load(sys.argv[1])
else:
    data = np.load('./data/test_clip.npy')
data = Data(data, norm[:,:dims], "input")

window = GLWindow(draw, update)
window.run()