Open tshrjn opened 1 year ago
Hi, nosmpl is aiming at rid out of any pkl files, you can using onnx file directly.
Actually, pk files are just model coodinates, you can not get a mesh from your predicted 3d cordiniates just using pkl.
In nosmpl, you don't need any pkl or any related python libs, just an onnx model you can directly get the final mesh.
But what if I already have those files, and what to use it to get mesh or convert to bvh. Or edit it, etc. How can we load it in nosmpl
?
@tshrjn It's quite simple, just replace the body
and global_orient
with the poses
and trans
you'll find in your npz
file.
Here is an example of loading the amass datasets' .npz
file:
import os
from nosmpl.smpl_onnx import SMPLOnnxRuntime
from nosmpl.vis.vis_o3d import vis_mesh_o3d
import numpy as np
file_path = 'amass/ACCAD/Female1General_c3d/A9 - lie t2_poses.npz'
data = dict(np.load(file_path))
body = data['poses'].astype('float32')
body = body[0, :69]
body = body.reshape([1, 23, 3])
global_orient = data['trans'].astype('float32')
global_orient = global_orient[0]
global_orient = global_orient.reshape([1, 1, 3])
smpl = SMPLOnnxRuntime()
outputs = smpl.forward(body, global_orient)
vertices, joints, faces = outputs
vertices = vertices[0].squeeze()
joints = joints[0].squeeze()
faces = faces.astype(np.int32)
vis_mesh_o3d(vertices, faces)
Yes, good example, just treat SMPLOnnxRuntime a replacement of original smpl in python, with this model, you can convert any 3d body poses, into joints and faces and vertices. With the joints, you can take any joints your want from smpl with according index.
How to load a smpl file
.npz
orpkl
file as used in many places.