Spaces:
Runtime error
Runtime error
File size: 2,711 Bytes
4409449 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import os
from pathlib import Path
# load example data
def load_example_input(txt_path):
file = open(txt_path, "r")
Lines = file.readlines()
count = 0
texts, lens = [], []
# Strips the newline character
for line in Lines:
count += 1
s = line.strip()
s_l = s.split(" ")[0]
s_t = s[(len(s_l) + 1):]
lens.append(int(s_l))
texts.append(s_t)
print("Length-{}: {}".format(s_l, s_t))
return texts, lens
# render batch
def render_batch(npy_dir, execute_python="./scripts/visualize_motion.sh", mode="sequence"):
os.system(f"{execute_python} {npy_dir} {mode}")
# render
def render(execute_python, npy_path, jointtype, cfg_path):
# execute_python = "/apdcephfs/share_1227775/shingxchen/libs/blender_bpy/blender-2.93.2-linux-x64/blender"
# execute_python = "/apdcephfs/share_1227775/mingzhenzhu/jiangbiao/libs/blender-2.93.2-linux-x64/blender"
export_scripts = "render.py"
os.system(
f"{execute_python} --background --python {export_scripts} -- --cfg={cfg_path} --npy={npy_path} --joint_type={jointtype}"
)
fig_path = Path(str(npy_path).replace(".npy", ".png"))
return fig_path
# origin render
# def render(npy_path, jointtype):
# execute_python = '/apdcephfs/share_1227775/shingxchen/libs/blender_bpy/blender-2.93.2-linux-x64/blender'
# export_scripts = 'render.py'
# os.system(f"{execute_python} --background --python {export_scripts} -- npy={npy_path} jointstype={jointtype}")
# fig_path = Path(str(npy_path).replace(".npy",".png"))
# return fig_path
# export fbx with hand params from pkl files
# refer to /apdcephfs/share_1227775/shingxchen/AIMotion/TMOST/scripts/fbx_output_smplx.py
def export_fbx_hand(pkl_path):
input = pkl_path
output = pkl_path.replace(".pkl", ".fbx")
execute_python = "/apdcephfs/share_1227775/shingxchen/libs/blender_bpy/blender-2.93.2-linux-x64/blender"
export_scripts = "./scripts/fbx_output_smplx.py"
os.system(
f"{execute_python} -noaudio --background --python {export_scripts}\
--input {input} \
--output {output}"
)
# export fbx without hand params from pkl files
# refer to /apdcephfs/share_1227775/shingxchen/AIMotion/TMOST/scripts/fbx_output.py
def export_fbx(pkl_path):
input = pkl_path
output = pkl_path.replace(".pkl", ".fbx")
execute_python = "/apdcephfs/share_1227775/shingxchen/libs/blender_bpy/blender-2.93.2-linux-x64/blender"
export_scripts = "./scripts/fbx_output.py"
os.system(
f"{execute_python} -noaudio --background --python {export_scripts}\
--input {input} \
--output {output}"
)
|