smplx icon indicating copy to clipboard operation
smplx copied to clipboard

Bug on shapedirs of MANO

Open mks0601 opened this issue 3 years ago • 5 comments

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.

스크린샷 2020-11-04 오전 1 07 56 스크린샷 2020-11-04 오전 1 08 00

Setting left_hand_mano.shapedirs[:,0,:] *= -1 and forward the betas outputs good result. 스크린샷 2020-11-04 오전 1 09 18 스크린샷 2020-11-04 오전 1 09 20

mks0601 avatar Nov 03 '20 16:11 mks0601

@mks0601 Hi, it seems like you save a offline hand mesh and open it at meshlab. How do you save the hand mesh offline?

MengHao666 avatar Dec 01 '20 08:12 MengHao666

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')

mks0601 avatar Dec 01 '20 10:12 mks0601

This is the testing code. You should add indentation in the definition of save_obj

mks0601 avatar Dec 01 '20 10:12 mks0601

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 !

MengHao666 avatar Dec 01 '20 11:12 MengHao666

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.

pgrady3 avatar Oct 30 '23 03:10 pgrady3