ShichenLiu / SoftRas

Project page of paper "Soft Rasterizer: A Differentiable Renderer for Image-based 3D Reasoning"
MIT License
1.2k stars 156 forks source link

Please specify parameter 'dim' when calling torch.cross #62

Closed thuliu-yt16 closed 3 years ago

thuliu-yt16 commented 3 years ago

I failed to render meshes using SoftRenderer with batch_size=3. Finally, I found that it is because torch.cross is not called with the specific dim parameter.

For example, in soft_renderer/functional/look_at.py, line 49-50 if batch_size=3, then both up.shape and z_axis.shape will be (3, 3). According to torch documentation,

截屏2020-10-16 下午10 06 11

the dim is not given and it will find the dimension 0 with the size 3 and apply cross product column by column, rather than row by row. To fix the bug, please specify dim=1.

I will not create a pull request since I think I cannot find everywhere the problem occurs. Hope you fix the bug.

ShichenLiu commented 3 years ago

Hi,

Thanks for bringing this up. I will try to update the code shortly.

ShichenLiu commented 3 years ago

Fixed!