OpenMotionLab/MotionGPT
118
1import os2from pathlib import Path3 4 5# load example data6def load_example_input(txt_path):7 file = open(txt_path, "r")8 Lines = file.readlines()9 count = 010 texts, lens = [], []11 # Strips the newline character12 for line in Lines:13 count += 114 s = line.strip()15 s_l = s.split(" ")[0]16 s_t = s[(len(s_l) + 1):]17 lens.append(int(s_l))18 texts.append(s_t)19 print("Length-{}: {}".format(s_l, s_t))20 return texts, lens21 22 23# render batch24def render_batch(npy_dir, execute_python="./scripts/visualize_motion.sh", mode="sequence"):25 os.system(f"{execute_python} {npy_dir} {mode}")26 27 28# render29def render(execute_python, npy_path, jointtype, cfg_path):30 # execute_python = "/apdcephfs/share_1227775/shingxchen/libs/blender_bpy/blender-2.93.2-linux-x64/blender"31 # execute_python = "/apdcephfs/share_1227775/mingzhenzhu/jiangbiao/libs/blender-2.93.2-linux-x64/blender"32 export_scripts = "render.py"33 34 os.system(35 f"{execute_python} --background --python {export_scripts} -- --cfg={cfg_path} --npy={npy_path} --joint_type={jointtype}"36 )37 38 fig_path = Path(str(npy_path).replace(".npy", ".png"))39 return fig_path40 41 42# origin render43# def render(npy_path, jointtype):44# execute_python = '/apdcephfs/share_1227775/shingxchen/libs/blender_bpy/blender-2.93.2-linux-x64/blender'45# export_scripts = 'render.py'46 47# os.system(f"{execute_python} --background --python {export_scripts} -- npy={npy_path} jointstype={jointtype}")48 49# fig_path = Path(str(npy_path).replace(".npy",".png"))50# return fig_path51 52# export fbx with hand params from pkl files53# refer to /apdcephfs/share_1227775/shingxchen/AIMotion/TMOST/scripts/fbx_output_smplx.py54def export_fbx_hand(pkl_path):55 input = pkl_path56 output = pkl_path.replace(".pkl", ".fbx")57 58 execute_python = "/apdcephfs/share_1227775/shingxchen/libs/blender_bpy/blender-2.93.2-linux-x64/blender"59 export_scripts = "./scripts/fbx_output_smplx.py"60 os.system(61 f"{execute_python} -noaudio --background --python {export_scripts}\62 --input {input} \63 --output {output}"64 )65 66 67# export fbx without hand params from pkl files68# refer to /apdcephfs/share_1227775/shingxchen/AIMotion/TMOST/scripts/fbx_output.py69def export_fbx(pkl_path):70 input = pkl_path71 output = pkl_path.replace(".pkl", ".fbx")72 73 execute_python = "/apdcephfs/share_1227775/shingxchen/libs/blender_bpy/blender-2.93.2-linux-x64/blender"74 export_scripts = "./scripts/fbx_output.py"75 os.system(76 f"{execute_python} -noaudio --background --python {export_scripts}\77 --input {input} \78 --output {output}"79 )80 