Exemplo n.º 1
0
parser.add_argument('--restart',
                    type=bool,
                    default=True,
                    help='restart training from zero')

args = parser.parse_args()

restart = args.restart

np.random.seed(args.seed)
nz = args.nz
print("Loading data .. ")
reference_mesh_file = 'data/template_ceasar.obj'
facedata = FaceData(nVal=100,
                    train_file=args.data + '/train.npy',
                    test_file=args.data + '/test.npy',
                    reference_mesh_file=reference_mesh_file,
                    pca_n_comp=nz)

ds_factors = [4, 4, 4,
              4]  # Sampling factor of the mesh at each stage of sampling
print("Generating Transform Matrices ..")

# Generates adjecency matrices A, downsampling matrices D, and upsamling matrices U by sampling
# the mesh 4 times. Each time the mesh is sampled by a factor of 4

M, A, D, U = mesh_sampling.generate_transform_matrices(facedata.reference_mesh,
                                                       ds_factors)

#A = list(map(lambda x:x.astype('float32'), A))
D = list(map(lambda x: x.astype('float32'), D))
Exemplo n.º 2
0
                    help='random seed (default: 1)')
parser.add_argument('--mode', default='train', type=str, help='train or test')
parser.add_argument('--viz', type=int, default=0, help='visualize while test')
parser.add_argument('--loss', default='l1', help='l1 or l2')
parser.add_argument('--mesh1', default='m1', help='for mesh interpolation')
parser.add_argument('--mesh2', default='m1', help='for mesh interpolation')

args = parser.parse_args()

np.random.seed(args.seed)
nz = args.nz
print("Loading data .. ")
reference_mesh_file = 'cloned-coma-repo/data/template.obj'
facedata = FaceData(nVal=100,
                    train_file=args.data + '/train.npy',
                    test_file=args.data + '/test.npy',
                    reference_mesh_file=reference_mesh_file,
                    pca_n_comp=nz)

ds_factors = [4, 4, 4,
              4]  # Sampling factor of the mesh at each stage of sampling
print("Generating Transform Matrices ..")

# Generates adjacency matrices A, downsampling matrices D, and upsampling matrices U by sampling
# the mesh 4 times. Each time the mesh is sampled by a factor of 4

M, A, D, U = mesh_sampling.generate_transform_matrices(facedata.reference_mesh,
                                                       ds_factors)

A = map(lambda x: x.astype('float32'), A)
D = map(lambda x: x.astype('float32'), D)
Exemplo n.º 3
0
                    help='size of the latent z vector')
parser.add_argument('--save', default='save', help='path to dataset')

opt = parser.parse_args()

if not os.path.exists(opt.save):
    os.makedirs(opt.save)
    os.makedirs(opt.save + '/cnn')
    os.makedirs(opt.save + '/pca')
    os.makedirs(opt.save + '/gt')
    os.makedirs(opt.save + '/plt')

reference_mesh_file = 'data/template.obj'
facedata = FaceData(nVal=100,
                    train_file=opt.data + '/train.npy',
                    test_file=opt.data + '/test.npy',
                    reference_mesh_file=reference_mesh_file,
                    pca_n_comp=opt.nz,
                    fitpca=True)
nv = facedata.n_vertex * 3
nTest = facedata.vertices_test.shape[0]

cnn_outputs = np.load(opt.cnn)
pca_outputs = facedata.pca.inverse_transform(
    facedata.pca.transform(
        np.reshape(facedata.vertices_test,
                   (facedata.vertices_test.shape[0], facedata.n_vertex * 3))))

cnn_vertices = (cnn_outputs * facedata.std) + facedata.mean
pca_vertices = (np.reshape(pca_outputs,
                           (pca_outputs.shape[0], facedata.n_vertex, 3)) *
                facedata.std) + facedata.mean
Exemplo n.º 4
0
from facemesh import FaceData
from psbody.mesh import MeshViewers
import numpy as np
import argparse
import time
import readchar

parser = argparse.ArgumentParser()
parser.add_argument('--cnn', default='.', help='path to dataset')
parser.add_argument('--data', default='allset', help='path to dataset')
parser.add_argument('--nz', type=int, default=8, help='size of the latent z vector')

opt = parser.parse_args()

reference_mesh_file = 'data/template.obj'
facedata = FaceData(nVal=1, train_file=opt.data+'_train.npy',
    test_file=opt.data+'_test.npy', reference_mesh_file=reference_mesh_file, pca_n_comp=int(opt.nz))
nv = facedata.n_vertex*3
nTest = facedata.vertices_test.shape[0]


cnn_outputs = np.load(opt.cnn)
pca_outputs = facedata.pca.inverse_transform(facedata.pca.transform(facedata.vertices_test))

cnn_vertices = (cnn_outputs * facedata.std) + facedata.mean
pca_vertices = (np.reshape(pca_outputs,(pca_outputs.shape[0],facedata.n_vertex, 3)) * facedata.std) + facedata.mean
test_vertices = (np.reshape(facedata.vertices_test, (facedata.vertices_test.shape[0], facedata.n_vertex, 3)) * facedata.std) + facedata.mean

viewer = MeshViewers(window_width=800, window_height=200, shape=[1, 4], titlebar='Meshes')

i = np.random.randint(0,nTest-1)
while(1):