MengHao666/Minimal-Hand-pytorch

error in running demo.py

kishan1823 opened this issue · 18 comments

image

i am getting this issue on running demo.py. can you help me in resolving this error.

you can add the following three lines: pose = pose.to(device), shape=shape.to(device), mano = mano.to(device)

but then I got this new pro:
image

where should i add those lines

after you get yourfirst pose, shape and mano

after adding also, i am getting same error

yes the error resolved by adding those 3 lines, but a new error raised
image

I got the same problem.

My mother tongue is not English. I'm sorry for some grammatical mistakes.

  1. First of all, let me explain why the first error occurs. In the original manopth, if the pose parameter in the form of matrix, the input matrix will be SVD decomposed to ensure that these matrices must be rotation matrices. Please refer to line 165 of original "manopth/manolayer.py".
    屏幕截图 2021-06-08 221742
    After SVD decomposition, no matter the input pose parameter is on CPU or GPU, the output will be on GPU. In demo.py, the parameters of mano are all on the CPU, so the first error is raised.

  2. My solution is to modify manopth. Specifically, modify the batch of "manopth/rotproj.py". The result of modifying can be seen here. After modification, this function can ensure that the input and output are CPU or GPU. Just add "device = rotmat.device" and change "rotmat = rotmat.cuda()" to "rotmat = rotmat.to(device)", you can try.
    屏幕截图 2021-06-08 221944

Of course, putting mano on GPU is also a solution. As for your second problem, I think it is due to the mano.th_faces on GPU. When it is on CPU, open3d can be automatically converted to the format required by open3d, but can't on GPU. Just put mano.th_faces on CPU can fix. Like this: " mesh.triangles = open3d.utility.Vector3iVector(mano.th_faces.cpu()) "
屏幕截图 2021-06-08 222920

thx

thank you

i want to konw why i had added everthing you said but i also can not run demo

File "D:\Minimal-Hand-pytorch-main\demo.py", line 120, in <module> _, j3d_p0_ops = mano(pose0, opt_tensor_shape) File "C:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "D:\Minimal-Hand-pytorch-main\manopth\manolayer.py", line 181, in forward th_v_shaped = torch.matmul(self.th_shapedirs, RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument mat2 in method wrapper_mm)

a solution. As for your second problem, I think it is due to the mano.th_faces on GPU. When it is on CPU, open3d can be automatically converted to the format required by open3d, but can't on GPU. Just put mano.th_faces on CPU can fix. Like this: " mesh.triangles = open3d.utility.Vector3iVector(mano.th_faces.cpu()) "

it seems two arguments are not in same device, please check this issue carfully.

yeah i solved this problem but when running the demo.py i cannot display the plot

File "D:\Minimal-Hand-pytorch-main\demo.py", line 120, in <module> _, j3d_p0_ops = mano(pose0, opt_tensor_shape) File "C:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "D:\Minimal-Hand-pytorch-main\manopth\manolayer.py", line 181, in forward th_v_shaped = torch.matmul(self.th_shapedirs, RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument mat2 in method wrapper_mm)

I had the same problem as you, have you solved it yet?