vchoutas / smplify-x

Expressive Body Capture: 3D Hands, Face, and Body from a Single Image

Home Page:https://smpl-x.is.tue.mpg.de/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subtraction, the `-` operator, with a bool tensor is not supported.

SvenPfiffner opened this issue · comments

Hi there.

I am currently running into a problem when trying to exectute the main.py file. While the code is in vposer_smpl.py I am greeted with the following RuntimeError
Subtraction, the - operator, with a bool tensor is not supported. If you are trying to invert a mask, use the ~ or logical_not() operator instead.

Full Traceback

Traceback (most recent call last):
  File "/content/smplify-x/smplifyx/main.py", line 272, in <module>
    main(**args)
  File "/content/smplify-x/smplifyx/main.py", line 245, in main
    fit_single_frame(img, keypoints[[person_id]],
  File "/content/smplify-x/smplifyx/fit_single_frame.py", line 270, in fit_single_frame
    init_t = fitting.guess_init(body_model, gt_joints, edge_indices,
  File "/usr/local/lib/python3.9/dist-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/content/smplify-x/smplifyx/fitting.py", line 74, in guess_init
    body_pose = vposer.decode(
  File "model/vposer/vposer_smpl.py", line 114, in decode
    if output_type == 'aa': return VPoser.matrot2aa(Xout)
  File "model/vposer/vposer_smpl.py", line 152, in matrot2aa
    pose = tgm.rotation_matrix_to_angle_axis(homogen_matrot).view(batch_size, 1, -1, 3).contiguous()
  File "/usr/local/lib/python3.9/dist-packages/torchgeometry-0.1.2-py3.9.egg/torchgeometry/core/conversions.py", line 233, in rotation_matrix_to_angle_axis
    quaternion = rotation_matrix_to_quaternion(rotation_matrix)
  File "/usr/local/lib/python3.9/dist-packages/torchgeometry-0.1.2-py3.9.egg/torchgeometry/core/conversions.py", line 302, in rotation_matrix_to_quaternion
    mask_c1 = mask_d2 * (1 - mask_d0_d1)
  File "/usr/local/lib/python3.9/dist-packages/torch/_tensor.py", line 39, in wrapped
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/torch/_tensor.py", line 834, in __rsub__
    return _C._VariableFunctions.rsub(self, other)
RuntimeError: Subtraction, the `-` operator, with a bool tensor is not supported. If you are trying to invert a mask, use the `~` or `logical_not()` operator instead.

I assume that this has to do with an incompatible torch version (I am using torch 1.13.1) but I'm not entirely sure.
Does anyone have an idea how to best solve this issue?

Thanks in advance for any input or help

I found a solution to above problem. It seems to be some kind of incompatibility issue with newer torch versions. For anyone having the same problem, the following two fixes worked for me

  • Use an older torch version: torch 1.1.0 should work, maybe newer versions as well but the problem seems to come up from at least torch 1.7.0 onwards.
  • Update torchgeometry: If you would rather not use an old version of torch you can manually fix this error by changing the conversions.py file in torchgeometry/core. For my environment this file was in /usr/local/lib/python3.9/dist-packages/torchgeometry/core/conversions.py (Google Colab). In said file you should go to where mask_c0, mask_c1, mask_c2, mask_c3 are defined and replace their definition by the following
mask_c0 = mask_d2 * mask_d0_d1
mask_c1 = mask_d2 * ~(mask_d0_d1)
mask_c2 = ~(mask_d2) * mask_d0_nd1
mask_c3 = ~(mask_d2) * ~(mask_d0_nd1)

Credit to solution 2: StackOverflow