From ceadca02e3a0e6e44e09a27a923aa87d10738711 Mon Sep 17 00:00:00 2001 From: Hunor Laczko Date: Fri, 3 Feb 2023 11:35:48 +0000 Subject: [PATCH] basic test --- .gitignore | 1 + main.py | 17 +++++++++++++++++ smpl_tf.py | 12 ++++++------ utils.py | 0 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 utils.py diff --git a/.gitignore b/.gitignore index 5d381cc..f3b1260 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,4 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +.vscode/launch.json diff --git a/main.py b/main.py index e69de29..10cee62 100644 --- a/main.py +++ b/main.py @@ -0,0 +1,17 @@ +import os + +os.environ["CUDA_VISIBLE_DEVICES"] = '6' + +import numpy as np +from smpl_tf import SMPL + +if __name__ == '__main__': + smpl_tf : SMPL = SMPL('model_files') + + betas = np.zeros((1, 11), dtype=np.float32) + poses = np.zeros((1, 72), dtype=np.float32) + R = smpl_tf.run_rodrigues(poses) + posed = smpl_tf.run(R, betas) + + + pass \ No newline at end of file diff --git a/smpl_tf.py b/smpl_tf.py index 77d09c6..3ec5af6 100644 --- a/smpl_tf.py +++ b/smpl_tf.py @@ -34,7 +34,7 @@ eval_joints = { class SMPL: - def __init__(self, orig_smpl=False, use_one_hot=False, is_skirt=False): + def __init__(self, path, orig_smpl=False, use_one_hot=False, is_skirt=False): self.J_regressor = [] self.v_template = [] self.shapedirs = [] @@ -44,7 +44,7 @@ class SMPL: self.is_skirt = is_skirt # Load SMPL models # path = os.path.abspath(os.path.dirname(__file__)) - with open(os.path.join('custom_utils/super_model_f.pkl'), 'rb') as f: + with open(os.path.join(path, 'super_model_f.pkl'), 'rb') as f: if sys.version_info[0]<3: female = pickle.load(f) else: @@ -54,7 +54,7 @@ class SMPL: self.posedirs.append(tf.constant(female['posedirs'], dtype=np.float32)) self.shapedirs.append(tf.constant(female['shapedirs'], dtype=np.float32)) self.weights.append(tf.constant(female['weights'], dtype=np.float32)) - with open(os.path.join('custom_utils/super_model_m.pkl'), 'rb') as f: + with open(os.path.join(path, 'super_model_m.pkl'), 'rb') as f: if sys.version_info[0]<3: male = pickle.load(f) else: @@ -77,11 +77,11 @@ class SMPL: self.weights_one_hot = tf.one_hot(self.weights_one_hot, 24) # Topology no head/hands/feet - F = sio.loadmat('custom_utils/ssmpl_faces.mat') + F = sio.loadmat(os.path.join(path, 'ssmpl_faces.mat')) self.f = np.array(F['faces_default']) self.f_skirt = np.array(F['faces_skirt']) - 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.nn = np.array(sio.loadmat(os.path.join(path, 'NN.mat'))) + self.to_keep = sio.loadmat(os.path.join(path, 'keep_remove.mat'))['keep'].reshape(-1) self.weights_all = self.weights if use_one_hot: diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..e69de29