vchoutas / smplify-x

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

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

Closed SvenPfiffner closed 1 year ago

SvenPfiffner commented 1 year ago

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

```python Traceback (most recent call last): File "/content/smplify-x/smplifyx/main.py", line 272, in 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

SvenPfiffner commented 1 year ago

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

Credit to solution 2: StackOverflow