Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why doesn't my smplx.pkl file work? #5

Open
Ginjing-Yuan opened this issue Sep 14, 2023 · 15 comments
Open

Why doesn't my smplx.pkl file work? #5

Ginjing-Yuan opened this issue Sep 14, 2023 · 15 comments

Comments

@Ginjing-Yuan
Copy link

When I put my photo trained pkl file in DINAR, it reports:
RuntimeError: The size of tensor a (134) must match the size of tensor b (165) at non-singleton dimension 1.
If I change my pkl to random one of your pkls, the training will start. I suppose our pkl files may generate from different model. Which one are you using?

@Ginjing-Yuan
Copy link
Author

When I put my photo trained pkl file in DINAR, it reports: RuntimeError: The size of tensor a (134) must match the size of tensor b (165) at non-singleton dimension 1. If I change my pkl to random one of your pkls, the training will start. I suppose our pkl files may generate from different model. Which one are you using?

I found the 'body_pose' part of pkl you provided had more parameters.

@david-svitov
Copy link
Contributor

Hi! First please make shure that you use SMPL-X model for producing your .pkl with the same parameters as in dataloader:

gender2model = {k: smplx_flame.SMPLX(

If it doesn't help please provide some additional information. Like the line on witch you get this error. And if it's possible the example of your .pkl

@Ginjing-Yuan
Copy link
Author

Hi David! I try to follow your parameters, but it doesn't work. These are all preprocessed data I used, and I also add a pkl file produced by me from your dataset. Here is the google drive link.
https://drive.google.com/file/d/1MDfl049Ii3NlANjzuSW6psRTTFRh3BwS/view?usp=drive_link

@wf1024966
Copy link

Hi David! I try to follow your parameters, but it doesn't work. These are all preprocessed data I used, and I also add a pkl file produced by me from your dataset. Here is the google drive link. https://drive.google.com/file/d/1MDfl049Ii3NlANjzuSW6psRTTFRh3BwS/view?usp=drive_link

I have the same problem.

@Ginjing-Yuan
Copy link
Author

Moreover, when I use pickle check the pkl file, there is a parameter which is 'ltrb': (28, 65, 1046, 1083) misses too.

@wf1024966
Copy link

When I put my photo trained pkl file in DINAR, it reports: RuntimeError: The size of tensor a (134) must match the size of tensor b (165) at non-singleton dimension 1. If I change my pkl to random one of your pkls, the training will start. I suppose our pkl files may generate from different model. Which one are you using?

I found the 'body_pose' part of pkl you provided had more parameters.

你好,这个问题我已经有解决方式了,fit_single_frame.py中把result['body_pose'] = pose_embedding.detach().cpu().numpy()改成 result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63)),就可以得到正确的结果。 dict中 如果没有'ltrb': (28, 65, 1046, 1083),代码也能正常运行。

@Ginjing-Yuan
Copy link
Author

When I put my photo trained pkl file in DINAR, it reports: RuntimeError: The size of tensor a (134) must match the size of tensor b (165) at non-singleton dimension 1. If I change my pkl to random one of your pkls, the training will start. I suppose our pkl files may generate from different model. Which one are you using?

I found the 'body_pose' part of pkl you provided had more parameters.

你好,这个问题我已经有解决方式了,fit_single_frame.py中把result['body_pose'] = pose_embedding.detach().cpu().numpy()改成 result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63)),就可以得到正确的结果。 dict中 如果没有'ltrb': (28, 65, 1046, 1083),代码也能正常运行。

你好,我用修改过的代码得到了如下报错:

Traceback (most recent call last):
File "smplifyx/main.py", line 273, in
main(**args)
File "smplifyx/main.py", line 246, in main
fit_single_frame(img, keypoints[[person_id]],
File "C:\Users\91802\anaconda3\envs\sm382\smplify-x-master\smplifyx\fit_single_frame.py", line 473, in fit_single_frame
result['body_pose'] = vposer.decode(pose_embedding.get('pose_body').detach().cpu().numpy()).reshape((1,63))
AttributeError: 'Tensor' object has no attribute 'get' 请问你是怎么解决的?

@Dragonkingpan
Copy link

When I put my photo trained pkl file in DINAR, it reports: RuntimeError: The size of tensor a (134) must match the size of tensor b (165) at non-singleton dimension 1. If I change my pkl to random one of your pkls, the training will start. I suppose our pkl files may generate from different model. Which one are you using?

I found the 'body_pose' part of pkl you provided had more parameters.

你好,这个问题我已经有解决方式了,fit_single_frame.py中把result['body_pose'] = pose_embedding.detach().cpu().numpy()改成 result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63)),就可以得到正确的结果。 dict中 如果没有'ltrb': (28, 65, 1046, 1083),代码也能正常运行。

我也试图按你的办法这样进行修改,

 vp = vposer.decode(pose_embedding)
 result['body_pose'] = (vp.get('pose_body').detach().cpu().numpy()).reshape((1, 63))

但是vposer解码出来的vp没有pose_body这个东西,直接报错了。
您是否能把您用的smplx的代码给我一份,谢谢!

@wf1024966
Copy link

When I put my photo trained pkl file in DINAR, it reports: RuntimeError: The size of tensor a (134) must match the size of tensor b (165) at non-singleton dimension 1. If I change my pkl to random one of your pkls, the training will start. I suppose our pkl files may generate from different model. Which one are you using?

I found the 'body_pose' part of pkl you provided had more parameters.

你好,这个问题我已经有解决方式了,fit_single_frame.py中把result['body_pose'] = pose_embedding.detach().cpu().numpy()改成 result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63)),就可以得到正确的结果。 dict中 如果没有'ltrb': (28, 65, 1046, 1083),代码也能正常运行。

我也试图按你的办法这样进行修改,

 vp = vposer.decode(pose_embedding)
 result['body_pose'] = (vp.get('pose_body').detach().cpu().numpy()).reshape((1, 63))

但是vposer解码出来的vp没有pose_body这个东西,直接报错了。 您是否能把您用的smplx的代码给我一份,谢谢!

你能把dict发给我看一下吗?看下字典里是哪些元素

@wf1024966
Copy link

result

When I put my photo trained pkl file in DINAR, it reports: RuntimeError: The size of tensor a (134) must match the size of tensor b (165) at non-singleton dimension 1. If I change my pkl to random one of your pkls, the training will start. I suppose our pkl files may generate from different model. Which one are you using?

I found the 'body_pose' part of pkl you provided had more parameters.

你好,这个问题我已经有解决方式了,fit_single_frame.py中把result['body_pose'] = pose_embedding.detach().cpu().numpy()改成 result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63)),就可以得到正确的结果。 dict中 如果没有'ltrb': (28, 65, 1046, 1083),代码也能正常运行。

你好,我用修改过的代码得到了如下报错:

Traceback (most recent call last): File "smplifyx/main.py", line 273, in main(**args) File "smplifyx/main.py", line 246, in main fit_single_frame(img, keypoints[[person_id]], File "C:\Users\91802\anaconda3\envs\sm382\smplify-x-master\smplifyx\fit_single_frame.py", line 473, in fit_single_frame result['body_pose'] = vposer.decode(pose_embedding.get('pose_body').detach().cpu().numpy()).reshape((1,63)) AttributeError: 'Tensor' object has no attribute 'get' 请问你是怎么解决的?

你好,你这里代码写错了,pose_embedding是tensor,vposer.decode(pose_embedding)得到字典,然后才能用get方式得到这个字典里的key 'pose_body' 里的值。

@Ginjing-Yuan
Copy link
Author

result

When I put my photo trained pkl file in DINAR, it reports: RuntimeError: The size of tensor a (134) must match the size of tensor b (165) at non-singleton dimension 1. If I change my pkl to random one of your pkls, the training will start. I suppose our pkl files may generate from different model. Which one are you using?

I found the 'body_pose' part of pkl you provided had more parameters.

你好,这个问题我已经有解决方式了,fit_single_frame.py中把result['body_pose'] = pose_embedding.detach().cpu().numpy()改成 result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63)),就可以得到正确的结果。 dict中 如果没有'ltrb': (28, 65, 1046, 1083),代码也能正常运行。

你好,我用修改过的代码得到了如下报错:
Traceback (most recent call last): File "smplifyx/main.py", line 273, in main(**args) File "smplifyx/main.py", line 246, in main fit_single_frame(img, keypoints[[person_id]], File "C:\Users\91802\anaconda3\envs\sm382\smplify-x-master\smplifyx\fit_single_frame.py", line 473, in fit_single_frame result['body_pose'] = vposer.decode(pose_embedding.get('pose_body').detach().cpu().numpy()).reshape((1,63)) AttributeError: 'Tensor' object has no attribute 'get' 请问你是怎么解决的?

你好,你这里代码写错了,pose_embedding是tensor,vposer.decode(pose_embedding)得到字典,然后才能用get方式得到这个字典里的key 'pose_body' 里的值。

我copy您的代码还是报错
result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63))
AttributeError: 'Tensor' object has no attribute 'get' 。

当我在fit_single_frame前print了vposer.decode(pose_embedding),
print(vposer.decode(pose_embedding))
result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63))
报错前打出了:
tensor([[[[ 9.9986e-01, -1.6692e-02, -2.7833e-03, 1.6616e-02, 9.9954e-01,
-2.5422e-02, 3.2063e-03, 2.5372e-02, 9.9967e-01],
[ 9.9874e-01, -4.8467e-02, 1.2789e-02, 4.7347e-02, 9.9593e-01,
7.6745e-02, -1.6457e-02, -7.6043e-02, 9.9697e-01],
[ 9.9995e-01, -4.4295e-04, 1.0162e-02, 1.8311e-03, 9.9057e-01,
-1.3701e-01, -1.0005e-02, 1.3702e-01, 9.9052e-01],
[ 9.9778e-01, -8.8067e-03, -6.5952e-02, -1.0669e-02, 9.5720e-01,
-2.8923e-01, 6.5676e-02, 2.8929e-01, 9.5499e-01],
[ 9.9907e-01, 3.2578e-02, 2.8256e-02, -1.9618e-02, 9.2683e-01,
-3.7496e-01, -3.8403e-02, 3.7405e-01, 9.2661e-01],
[ 9.9926e-01, -2.4563e-02, -2.9638e-02, 2.7915e-02, 9.9255e-01,
1.1857e-01, 2.6505e-02, -1.1931e-01, 9.9250e-01],
[ 9.2808e-01, -2.0060e-01, 3.1374e-01, 7.6028e-02, 9.2683e-01,
3.6770e-01, -3.6455e-01, -3.1740e-01, 8.7542e-01],
[ 9.6471e-01, 3.9284e-02, -2.6036e-01, 4.6853e-02, 9.4742e-01,
3.1656e-01, 2.5910e-01, -3.1759e-01, 9.1214e-01],
[ 9.9987e-01, -1.5678e-02, -4.7349e-03, 1.4951e-02, 9.9181e-01,
-1.2686e-01, 6.6850e-03, 1.2677e-01, 9.9191e-01],
[ 9.9952e-01, 5.0317e-03, 3.0614e-02, -6.0931e-03, 9.9938e-01,
3.4678e-02, -3.0421e-02, -3.4848e-02, 9.9893e-01],
[ 9.9984e-01, -1.3444e-02, 1.1786e-02, 1.3680e-02, 9.9970e-01,
-2.0155e-02, -1.1512e-02, 2.0313e-02, 9.9973e-01],
[ 9.9595e-01, 3.4300e-02, 8.3116e-02, -4.4194e-02, 9.9176e-01,
1.2028e-01, -7.8305e-02, -1.2347e-01, 9.8925e-01],
[ 9.9953e-01, -9.9169e-03, 2.8893e-02, 9.0059e-03, 9.9946e-01,
3.1489e-02, -2.9190e-02, -3.1214e-02, 9.9909e-01],
[ 9.9939e-01, -3.2153e-02, 1.3901e-02, 3.1169e-02, 9.9733e-01,
6.5993e-02, -1.5986e-02, -6.5519e-02, 9.9772e-01],
[ 9.9956e-01, 1.7088e-02, 2.4266e-02, -1.7326e-02, 9.9980e-01,
9.6616e-03, -2.4096e-02, -1.0078e-02, 9.9966e-01],
[ 6.9919e-01, 6.9857e-01, -1.5208e-01, -7.0285e-01, 7.1059e-01,
3.2621e-02, 1.3086e-01, 8.4085e-02, 9.8783e-01],
[ 6.4331e-01, -7.3618e-01, 2.1023e-01, 7.5950e-01, 6.4826e-01,
-5.4001e-02, -9.6527e-02, 1.9441e-01, 9.7616e-01],
[ 9.5359e-01, 3.5420e-02, -2.9903e-01, -6.6384e-02, 9.9335e-01,
-9.4028e-02, 2.9371e-01, 1.0952e-01, 9.4960e-01],
[ 9.1868e-01, 6.3024e-02, 3.8994e-01, -5.3356e-02, 9.9794e-01,
-3.5588e-02, -3.9138e-01, 1.1888e-02, 9.2015e-01],
[ 9.9327e-01, -8.3776e-02, -7.9967e-02, 1.0367e-01, 9.5095e-01,
2.9146e-01, 5.1627e-02, -2.9779e-01, 9.5323e-01],
[ 9.9609e-01, 8.8226e-02, 5.4535e-03, -8.6616e-02, 9.6188e-01,
2.5939e-01, 1.7640e-02, -2.5885e-01, 9.6576e-01]]]],
device='cuda:0', grad_fn=)
rientation: 0%| | 0/1 [00:58<?, ?it/s]
Traceback (most recent call last):
File "smplifyx/main.py", line 273, in
main(**args)
File "smplifyx/main.py", line 246, in main
fit_single_frame(img, keypoints[[person_id]],
File "C:\Users\91802\anaconda3\envs\sm382\smplify-x-master\smplifyx\fit_single_frame.py", line 475, in fit_single_frame
result['body_pose'] = (result['body_pose'].get('pose_body').detach().cpu().numpy()).reshape((1,63))
AttributeError: 'Tensor' object has no attribute 'get'

@wf1024966
Copy link

wf1024966 commented Sep 25, 2023

result

When I put my photo trained pkl file in DINAR, it reports: RuntimeError: The size of tensor a (134) must match the size of tensor b (165) at non-singleton dimension 1. If I change my pkl to random one of your pkls, the training will start. I suppose our pkl files may generate from different model. Which one are you using?

I found the 'body_pose' part of pkl you provided had more parameters.

你好,这个问题我已经有解决方式了,fit_single_frame.py中把result['body_pose'] = pose_embedding.detach().cpu().numpy()改成 result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63)),就可以得到正确的结果。 dict中 如果没有'ltrb': (28, 65, 1046, 1083),代码也能正常运行。

你好,我用修改过的代码得到了如下报错:
Traceback (most recent call last): File "smplifyx/main.py", line 273, in main(**args) File "smplifyx/main.py", line 246, in main fit_single_frame(img, keypoints[[person_id]], File "C:\Users\91802\anaconda3\envs\sm382\smplify-x-master\smplifyx\fit_single_frame.py", line 473, in fit_single_frame result['body_pose'] = vposer.decode(pose_embedding.get('pose_body').detach().cpu().numpy()).reshape((1,63)) AttributeError: 'Tensor' object has no attribute 'get' 请问你是怎么解决的?

你好,你这里代码写错了,pose_embedding是tensor,vposer.decode(pose_embedding)得到字典,然后才能用get方式得到这个字典里的key 'pose_body' 里的值。

我copy您的代码还是报错 result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63)) AttributeError: 'Tensor' object has no attribute 'get' 。

当我在fit_single_frame前print了vposer.decode(pose_embedding), print(vposer.decode(pose_embedding)) result['body_pose'] = (vposer.decode(pose_embedding).get('pose_body').detach().cpu().numpy()).reshape((1,63)) 报错前打出了: tensor([[[[ 9.9986e-01, -1.6692e-02, -2.7833e-03, 1.6616e-02, 9.9954e-01, -2.5422e-02, 3.2063e-03, 2.5372e-02, 9.9967e-01], [ 9.9874e-01, -4.8467e-02, 1.2789e-02, 4.7347e-02, 9.9593e-01, 7.6745e-02, -1.6457e-02, -7.6043e-02, 9.9697e-01], [ 9.9995e-01, -4.4295e-04, 1.0162e-02, 1.8311e-03, 9.9057e-01, -1.3701e-01, -1.0005e-02, 1.3702e-01, 9.9052e-01], [ 9.9778e-01, -8.8067e-03, -6.5952e-02, -1.0669e-02, 9.5720e-01, -2.8923e-01, 6.5676e-02, 2.8929e-01, 9.5499e-01], [ 9.9907e-01, 3.2578e-02, 2.8256e-02, -1.9618e-02, 9.2683e-01, -3.7496e-01, -3.8403e-02, 3.7405e-01, 9.2661e-01], [ 9.9926e-01, -2.4563e-02, -2.9638e-02, 2.7915e-02, 9.9255e-01, 1.1857e-01, 2.6505e-02, -1.1931e-01, 9.9250e-01], [ 9.2808e-01, -2.0060e-01, 3.1374e-01, 7.6028e-02, 9.2683e-01, 3.6770e-01, -3.6455e-01, -3.1740e-01, 8.7542e-01], [ 9.6471e-01, 3.9284e-02, -2.6036e-01, 4.6853e-02, 9.4742e-01, 3.1656e-01, 2.5910e-01, -3.1759e-01, 9.1214e-01], [ 9.9987e-01, -1.5678e-02, -4.7349e-03, 1.4951e-02, 9.9181e-01, -1.2686e-01, 6.6850e-03, 1.2677e-01, 9.9191e-01], [ 9.9952e-01, 5.0317e-03, 3.0614e-02, -6.0931e-03, 9.9938e-01, 3.4678e-02, -3.0421e-02, -3.4848e-02, 9.9893e-01], [ 9.9984e-01, -1.3444e-02, 1.1786e-02, 1.3680e-02, 9.9970e-01, -2.0155e-02, -1.1512e-02, 2.0313e-02, 9.9973e-01], [ 9.9595e-01, 3.4300e-02, 8.3116e-02, -4.4194e-02, 9.9176e-01, 1.2028e-01, -7.8305e-02, -1.2347e-01, 9.8925e-01], [ 9.9953e-01, -9.9169e-03, 2.8893e-02, 9.0059e-03, 9.9946e-01, 3.1489e-02, -2.9190e-02, -3.1214e-02, 9.9909e-01], [ 9.9939e-01, -3.2153e-02, 1.3901e-02, 3.1169e-02, 9.9733e-01, 6.5993e-02, -1.5986e-02, -6.5519e-02, 9.9772e-01], [ 9.9956e-01, 1.7088e-02, 2.4266e-02, -1.7326e-02, 9.9980e-01, 9.6616e-03, -2.4096e-02, -1.0078e-02, 9.9966e-01], [ 6.9919e-01, 6.9857e-01, -1.5208e-01, -7.0285e-01, 7.1059e-01, 3.2621e-02, 1.3086e-01, 8.4085e-02, 9.8783e-01], [ 6.4331e-01, -7.3618e-01, 2.1023e-01, 7.5950e-01, 6.4826e-01, -5.4001e-02, -9.6527e-02, 1.9441e-01, 9.7616e-01], [ 9.5359e-01, 3.5420e-02, -2.9903e-01, -6.6384e-02, 9.9335e-01, -9.4028e-02, 2.9371e-01, 1.0952e-01, 9.4960e-01], [ 9.1868e-01, 6.3024e-02, 3.8994e-01, -5.3356e-02, 9.9794e-01, -3.5588e-02, -3.9138e-01, 1.1888e-02, 9.2015e-01], [ 9.9327e-01, -8.3776e-02, -7.9967e-02, 1.0367e-01, 9.5095e-01, 2.9146e-01, 5.1627e-02, -2.9779e-01, 9.5323e-01], [ 9.9609e-01, 8.8226e-02, 5.4535e-03, -8.6616e-02, 9.6188e-01, 2.5939e-01, 1.7640e-02, -2.5885e-01, 9.6576e-01]]]], device='cuda:0', grad_fn=) rientation: 0%| | 0/1 [00:58<?, ?it/s] Traceback (most recent call last): File "smplifyx/main.py", line 273, in main(**args) File "smplifyx/main.py", line 246, in main fit_single_frame(img, keypoints[[person_id]], File "C:\Users\91802\anaconda3\envs\sm382\smplify-x-master\smplifyx\fit_single_frame.py", line 475, in fit_single_frame result['body_pose'] = (result['body_pose'].get('pose_body').detach().cpu().numpy()).reshape((1,63)) AttributeError: 'Tensor' object has no attribute 'get'

step 1

human_body_prior工程不要用cvpr19分支去安装编译,git checkout到master分支去安装编译

step 2 - change

old version

from human_body_prior.tools.model_loader import load_vposer

new version

from human_body_prior.tools.model_loader import load_model
from human_body_prior.models.vposer_model import VPoser

step 3 - change

old version

vposer, _ = load_vposer(vposer_ckpt, vp_model='snapshot')

new version

vposer, _ = load_model(vposer_ckpt, model_code=VPoser, remove_words_in_model_weights='vp_model.', disable_grad=True).

step 4

官网去下载新的vposer的ckpt文件,替换原来的pt文件,放到相应文件夹下。

@mayank64ce
Copy link

Hi @wf1024966 I tried to follow your steps but it gives the following error:

Traceback (most recent call last):
  File "smplifyx/main.py", line 274, in <module>
    main(**args)
  File "smplifyx/main.py", line 247, in main
    fit_single_frame(img, keypoints[[person_id]],
  File "/home/ma982513/Projects/smplify-x/smplifyx/fit_single_frame.py", line 274, in fit_single_frame
    init_t = fitting.guess_init(body_model, gt_joints, edge_indices,
  File "/home/ma982513/.conda/envs/smplifyx/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 26, in decorate_context
    return func(*args, **kwargs)
  File "/home/ma982513/Projects/smplify-x/smplifyx/fitting.py", line 74, in guess_init
    body_pose = vposer.decode(
TypeError: decode() got an unexpected keyword argument 'output_type'

@mayank64ce
Copy link

@Dragonkingpan @wf1024966 @Ginjing-Yuan anyone of you getting strange output from smplifyx like this : vchoutas/smplify-x#210

@david-svitov
Copy link
Contributor

I see there was quite a long discussion here. I took a new machine, ran the code on it, and wrote down all the steps I took to fix it in this document:
https://docs.google.com/document/d/1LTua0D7XDpVJ9Jrk7s1WSjXIYIHBN89txCUXl1wCsvk/edit?usp=sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants