TypeError: rasterize_meshes(): incompatible function arguments

Hello,

I’m new to pytorch3d rasterization. I wanted to plot facial landmarks with shape while training my model So I came across a GitHub which is doing similar to that and using the same face model.

But now I am getting below issue. I tried many things but the issue still persists. Any suggestion where should I look in my code.

File “/home/kak/Documents/Thesis/Reconstruction/train_copy.py”, line 125, in train_epoch
** shape_images = self.render.render_shape(pred_vert, trans_vertices, input_image)**
** File “/home/kak/Documents/Thesis/Reconstruction/renderer.py”, line 274, in render_shape**
** rendering = self.rasterizer(transformed_vertices, self.faces.expand(batch_size, -1, -1), attributes)**
** File “/home/kak/anaconda3/envs/gt/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 722, in _call_impl**
** result = self.forward(input, kwargs)
** File “/home/kak/Documents/Thesis/Reconstruction/renderer.py”, line 67, in forward
*
** perspective_correct=raster_settings.perspective_correct,**
** File “/home/kak/anaconda3/envs/gt/lib/python3.6/site-packages/pytorch3d/renderer/mesh/rasterize_meshes.py”, line 150, in rasterize_meshes**
** cull_backfaces,**
** File “/home/kak/anaconda3/envs/gt/lib/python3.6/site-packages/pytorch3d/renderer/mesh/rasterize_meshes.py”, line 205, in forward**
** cull_backfaces,**
TypeError: rasterize_meshes(): incompatible function arguments. The following argument types are supported:
** 1. (arg0: at::Tensor, arg1: at::Tensor, arg2: at::Tensor, arg3: int, arg4: float, arg5: int, arg6: int, arg7: int, arg8: bool, arg9: bool, arg10: bool) → Tuple[at::Tensor, at::Tensor, at::Tensor, at::Tensor]**

Invoked with: tensor([[[-2.9129e-01, 3.8580e-01, 9.9854e+00],
** [-3.1403e-01, 3.8133e-01, 9.9865e+00],**
** [-2.8892e-01, 3.7910e-01, 9.9895e+00]],**

** [[-3.2832e-01, 4.5427e-01, 1.0014e+01],**
** [-3.4195e-01, 4.3908e-01, 1.0008e+01],**
** [-3.3878e-01, 4.2805e-01, 1.0044e+01]],**

** [[-2.9508e-01, 2.3414e-02, 1.0420e+01],**
** [-2.4708e-01, -2.5840e-04, 1.0480e+01],**
** [-2.3614e-01, 6.3354e-02, 1.0425e+01]],**

** …,**

** [[ 8.7310e-02, 2.2173e-01, 9.9789e+00],**
** [ 9.3325e-02, 2.2365e-01, 9.9810e+00],**
** [ 9.5288e-02, 2.1816e-01, 9.9787e+00]],**

    [[ 8.8948e-02,  2.1716e-01,  9.9770e+00],
     [ 9.5288e-02,  2.1816e-01,  9.9787e+00],
     [ 9.6179e-02,  2.1224e-01,  9.9768e+00]],

    [[ 9.6179e-02,  2.1224e-01,  9.9768e+00],
     [ 9.5954e-02,  2.0613e-01,  9.9754e+00],
     [ 8.9500e-02,  2.0716e-01,  9.9743e+00]]], device='cuda:0',
   grad_fn=<IndexBackward>), tensor([     0,   9976,  19952,  29928,  39904,  49880,  59856,  69832,  79808,
     89784,  99760, 109736, 119712, 129688, 139664, 149640, 159616, 169592,
    179568, 189544], device='cuda:0'), tensor([9976, 9976, 9976, 9976, 9976, 9976, 9976, 9976, 9976, 9976, 9976, 9976,
    9976, 9976, 9976, 9976, 9976, 9976, 9976, 9976], device='cuda:0'), 224.0, 0.0, 1, 16, 10000, False, False, False

Based on the error message and your input it seems that arg3: int might be wrong, since an int is expected while you are trying to pass a float as 224.0.

1 Like

Yes, you are right. I corrected it and it worked. Thank you so much for your quick reply.
:smile: :star_struck:
Have a great day ahead. :+1: