vchoutas / smplify-x

Expressive Body Capture: 3D Hands, Face, and Body from a Single Image
https://smpl-x.is.tue.mpg.de/
Other
1.75k stars 336 forks source link

RuntimeError: The size of tensor a (118) must match the size of tensor b (111) at non-singleton dimension 1 #208

Open bohanfeng opened 1 year ago

bohanfeng commented 1 year ago

python smplifyx/main.py --config cfg_files/fit_smplx.yaml --data_folder input_image1/ --output_folder OUTPUT_FOLDER --visualize="True" --model_folder models_smplx_v1_1/ --vposer_ckpt V02_05/ --part_segm_fn smplx_parts_segm.pkl Processing: input_image1/images/2023-09-15-165143.jpg 2023-09-15 17:08:35.404 | INFO | human_body_prior.tools.model_loader:load_model:77 - No GPU detected. Loading on CPU! 2023-09-15 17:08:35.435 | INFO | human_body_prior.tools.model_loader:load_model:97 - Loaded model in eval mode with trained weights: V02_05/snapshots/V02_05_epoch=13_val_loss=0.03.ckpt /home/user/Desktop/smplify-x/smplifyx/optimizers/lbfgsls.py:238: UserWarning: This overload of add is deprecated: add(Number alpha, Tensor other) Consider using one of the following signatures instead: add(Tensor other, *, Number alpha) (Triggered internally at ../torch/csrc/utils/python_argparser.cpp:1485.) p.data.add(step_size, update[offset:offset + numel].view_as(p.data)) Camera initialization done after 6.5344 Camera initialization final loss 1871.7843 Stage: 0%| | 0/5 [00:00<?, ?it/s] Orientation: 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "smplifyx/main.py", line 272, in main(args) File "smplifyx/main.py", line 245, in main fit_single_frame(img, keypoints[[person_id]], File "/home/user/Desktop/smplify-x/smplifyx/fit_single_frame.py", line 440, in fit_single_frame final_loss_val = monitor.run_fitting( File "/home/user/Desktop/smplify-x/smplifyx/fitting.py", line 174, in run_fitting loss = optimizer.step(closure) File "/home/user/.local/lib/python3.8/site-packages/torch/optim/optimizer.py", line 280, in wrapper out = func(*args, *kwargs) File "/home/user/Desktop/smplify-x/smplifyx/optimizers/lbfgs_ls.py", line 280, in step orig_loss = closure() File "/home/user/Desktop/smplify-x/smplifyx/fitting.py", line 241, in fitting_func total_loss = loss(body_model_output, camera=camera, File "/home/user/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/home/user/Desktop/smplify-x/smplifyx/fitting.py", line 366, in forward weights = (joint_weights * joints_conf RuntimeError: The size of tensor a (118) must match the size of tensor b (111) at non-singleton dimension 1

I meet with this runtime error problem, I have add --face and --hand option in openpose, and use_hands: True use_face: True in fit_smplx.yaml. I wonder how to solve this problem, thanks!

Realinxc commented 12 months ago

Stage: 0%| | 0/5 [00:00<?, ?it/s] Orientation: 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "smplifyx/main.py", line 272, in main(args) File "smplifyx/main.py", line 245, in main fit_single_frame(img, keypoints[[person_id]], File "E:\MyCode\pythoncode\smplify-x\smplifyx\fit_single_frame.py", line 442, in fit_single_frame final_loss_val = monitor.run_fitting( File "E:\MyCode\pythoncode\smplify-x\smplifyx\fitting.py", line 176, in run_fitting loss = optimizer.step(closure) File "E:\Applications\tools\Anaconda\envs\smplx\lib\site-packages\torch\optim\optimizer.py", line 88, in wrapper return func(*args, *kwargs) File "E:\MyCode\pythoncode\smplify-x\smplifyx\optimizers\lbfgs_ls.py", line 280, in step orig_loss = closure() File "E:\MyCode\pythoncode\smplify-x\smplifyx\fitting.py", line 247, in fitting_func total_loss = loss(body_model_output, camera=camera, File "E:\Applications\tools\Anaconda\envs\smplx\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(input, kwargs) File "E:\MyCode\pythoncode\smplify-x\smplifyx\fitting.py", line 374, in forward weights = (joint_weights * joints_conf RuntimeError: The size of tensor a (118) must match the size of tensor b (18) at non-singleton dimension 1

I meet a similar problem. Have you solved it yet? I hope to receive your help.

Realinxc commented 12 months ago

I have solved it! you can set "--model_pose BODY_25" in openpose option.

slatiec commented 11 months ago

its seems I can only get the 25 pose keypoints from openpose. how can I get all 118 of them?

Realinxc commented 11 months ago

It depends on your openpose and smplx settings.

sakuradash commented 8 months ago

try this tensor118 is body plus face plus hands bin\OpenPoseDemo.exe --model_pose BODY_25 --face -hand --image_dir .\examples\media --write_json .\test

BowenTan02 commented 8 months ago

try this tensor118 is body plus face plus hands bin\OpenPoseDemo.exe --model_pose BODY_25 --face -hand --image_dir .\examples\media --write_json .\test

I think OpenPose BODY_25 with face and hand requires >= 16GB of GPU... May I ask if you have used any Colab/Linux scripts for OpenPose? Thanks!