smplx
smplx copied to clipboard
Bug on shapedirs of MANO
Hi,
I found a bug on shapedirs
of MANO.
Although the v_template
of the right and left hands, are different, shapedirs
is the same.
This can make the same betas
value make different hand shape.
Setting betas=torch.FloatTensor([4.4785, 0.3873, -0.3134, -4.4374, -1.7321, -2.1621, -0.0627, 5.1609, -1.5386, -0.3230]).view(1,-1)
outputs below results. The left hand right hands have very different hand shape although the betas
is the same.
Setting left_hand_mano.shapedirs[:,0,:] *= -1
and forward the betas
outputs good result.
@mks0601 Hi, it seems like you save a offline hand mesh and open it at meshlab. How do you save the hand mesh offline?
import smplx import torch import numpy as np
def save_obj(v, f, file_name='output.obj'): obj_file = open(file_name, 'w') for i in range(len(v)): obj_file.write('v ' + str(v[i][0]) + ' ' + str(v[i][1]) + ' ' + str(v[i][2]) + '\n') for i in range(len(f)): obj_file.write('f ' + str(f[i][0]+1) + '/' + str(f[i][0]+1) + ' ' + str(f[i][1]+1) + '/' + str(f[i][1]+1) + ' ' + str(f[i][2]+1) + '/' + str(f[i][2]+1) + '\n') obj_file.close()
mano_path = '' # set your MANO path mano_right_layer = smplx.create(mano_path, 'mano', use_pca=False, is_rhand=True) mano_left_layer = smplx.create(mano_path, 'mano', use_pca=False, is_rhand=False) betas=torch.FloatTensor([4.4785, 0.3873, -0.3134, -4.4374, -1.7321, -2.1621, -0.0627, 5.1609, -1.5386, -0.3230]).view(1,-1)
right_output = mano_right_layer(betas=betas) right_mesh = right_output.vertices[0].detach().numpy() save_obj(right_mesh, mano_right_layer.faces, 'right.obj')
left_output = mano_left_layer(betas=betas) left_mesh = left_output.vertices[0].detach().numpy() save_obj(left_mesh, mano_left_layer.faces, 'left.obj')
This is the testing code. You should add indentation in the definition of save_obj
import smplx import torch import numpy as np
def save_obj(v, f, file_name='output.obj'): obj_file = open(file_name, 'w') for i in range(len(v)): obj_file.write('v ' + str(v[i][0]) + ' ' + str(v[i][1]) + ' ' + str(v[i][2]) + '\n') for i in range(len(f)): obj_file.write('f ' + str(f[i][0]+1) + '/' + str(f[i][0]+1) + ' ' + str(f[i][1]+1) + '/' + str(f[i][1]+1) + ' ' + str(f[i][2]+1) + '/' + str(f[i][2]+1) + '\n') obj_file.close()
mano_path = '' # set your MANO path mano_right_layer = smplx.create(mano_path, 'mano', use_pca=False, is_rhand=True) mano_left_layer = smplx.create(mano_path, 'mano', use_pca=False, is_rhand=False) betas=torch.FloatTensor([4.4785, 0.3873, -0.3134, -4.4374, -1.7321, -2.1621, -0.0627, 5.1609, -1.5386, -0.3230]).view(1,-1)
right_output = mano_right_layer(betas=betas) right_mesh = right_output.vertices[0].detach().numpy() save_obj(right_mesh, mano_right_layer.faces, 'right.obj')
left_output = mano_left_layer(betas=betas) left_mesh = left_output.vertices[0].detach().numpy() save_obj(left_mesh, mano_left_layer.faces, 'left.obj')
Thanks !
I also found this bug after bashing my head against this problem for a day. The shapedirs variable in the left hand is incorrect. I have tested and concur with the solution proposed in the first post.