backup
This commit is contained in:
@@ -196,4 +196,10 @@ def sparse_to_tensor(L):
|
||||
idx = np.mat([L.row, L.col]).transpose().astype(np.float32)
|
||||
data = L.data.astype(dtype=np.float32)
|
||||
shape = L.shape
|
||||
return tf.SparseTensor(idx, data, shape)
|
||||
return tf.SparseTensor(idx, data, shape)
|
||||
|
||||
|
||||
def load_model(model, checkpoint):
|
||||
ckpt = tf.train.Checkpoint(model=model)
|
||||
manager = tf.train.CheckpointManager(ckpt, checkpoint, max_to_keep=1)
|
||||
ckpt.restore(manager.latest_checkpoint)
|
||||
|
||||
@@ -69,6 +69,7 @@ class SMPL:
|
||||
self.nn = np.array(sio.loadmat('custom_utils/NN.mat'))
|
||||
self.to_keep = sio.loadmat(os.path.join('custom_utils/keep_remove.mat'))['keep'].reshape(-1)
|
||||
|
||||
self.weights_all = self.weights
|
||||
self.weights = tf.gather(self.weights, self.to_keep, axis=1)
|
||||
|
||||
def Q2R(self, w, x, y, z):
|
||||
@@ -132,7 +133,7 @@ class SMPL:
|
||||
v_shaped.append(tf.tensordot(betas[:,:10], self.shapedirs[1], axes=[[1], [2]]) + tf.reshape(self.v_template[1], shape=(1,27578,3))) # male
|
||||
v_shaped = tf.stack(v_shaped, axis=-1)
|
||||
|
||||
def single_run(x, J_regressor=self.J_regressor, posedirs=self.posedirs, weights=self.weights, parent=self.parent):
|
||||
def single_run(x, J_regressor=self.J_regressor, posedirs=self.posedirs, weights=self.weights_all, parent=self.parent):
|
||||
R = x[0]
|
||||
v_shaped = x[1]
|
||||
g = x[2]
|
||||
@@ -160,7 +161,7 @@ class SMPL:
|
||||
|
||||
return v, tf.squeeze(J), v_posed
|
||||
|
||||
gender = tf.cast(tf.greater_equal(betas[:, 10] , 0), tf.int32)
|
||||
gender = tf.cast(tf.greater_equal(betas[:, 10] , 0.5), tf.int32)
|
||||
T_out, J_out, v_posed = tf.map_fn(single_run, (R, v_shaped, gender), (tf.float32, tf.float32, tf.float32))
|
||||
|
||||
J0 = tf.reshape(J_out[:,0,:], (-1, 1, 3))
|
||||
@@ -215,7 +216,7 @@ class SMPL:
|
||||
|
||||
return v, tf.squeeze(J)
|
||||
|
||||
gender = tf.cast(tf.greater_equal(betas[:, 10] , 0), tf.int32)
|
||||
gender = tf.cast(tf.greater_equal(betas[:, 10] , 0.5), tf.int32)
|
||||
T_out, J_out = tf.map_fn(single_run, (R, v_shaped, gender, v_cloth), (tf.float32, tf.float32))
|
||||
|
||||
J0 = tf.reshape(J_out[:,0,:], (-1, 1, 3))
|
||||
@@ -235,7 +236,7 @@ class SMPL:
|
||||
J = tf.matmul(J_regressor[g], v_shaped[:, :, g])
|
||||
return J
|
||||
|
||||
gender = tf.cast(tf.greater(betas[:, 10] , 0), tf.int32)
|
||||
gender = tf.cast(tf.greater(betas[:, 10] , 0.5), tf.int32)
|
||||
J = tf.map_fn(single_run, (v_shaped, gender), (tf.float32))
|
||||
J0 = tf.reshape(J[:,0,:], (-1, 1, 3))
|
||||
|
||||
@@ -274,7 +275,7 @@ class SMPL:
|
||||
|
||||
return v, tf.squeeze(J)
|
||||
|
||||
gender = tf.cast(tf.greater(betas[:, 10] , 0), tf.int32)
|
||||
gender = tf.cast(tf.greater(betas[:, 10] , 0.5), tf.int32)
|
||||
T_out, J_out = tf.map_fn(single_run, (R, J, gender, v_cloth), (tf.float32, tf.float32))
|
||||
|
||||
J0 = tf.reshape(J_out[:,0,:], (-1, 1, 3))
|
||||
|
||||
Reference in New Issue
Block a user