TypeError: rasterize_meshes(): incompatible function arguments

Shriya_Kak: <p>Hello,</p>
<p>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.</p><aside class="onebox githubblob">
  <header class="source">
      <a href="https://github.com/HavenFeng/photometric_optimization/blob/master/renderer.py" target="_blank" rel="noopener nofollow ugc">github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://github.com/HavenFeng/photometric_optimization/blob/master/renderer.py" target="_blank" rel="noopener nofollow ugc">HavenFeng/photometric_optimization/blob/master/renderer.py</a></h4>
<pre><code class="lang-py">"""
Author: Yao Feng
Copyright (c) 2020, Yao Feng
All rights reserved.
"""
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from skimage.io import imread
from pytorch3d.structures import Meshes
from pytorch3d.io import load_obj
from pytorch3d.renderer.mesh import rasterize_meshes
import util


class Pytorch3dRasterizer(nn.Module):
    """
    This class implements methods for rasterizing a batch of heterogenous
    Meshes.
</code></pre>

  This file has been truncated. <a href="https://github.com/HavenFeng/photometric_optimization/blob/master/renderer.py" target="_blank" rel="noopener nofollow ugc">show original</a>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>
<p>
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.</p>
<p><strong>File “/home/kak/Documents/Thesis/Reconstruction/train_copy.py”, line 125, in train_epoch</strong><br>
**    shape_images = self.render.render_shape(pred_vert, trans_vertices, input_image)**<br>
**  File “/home/kak/Documents/Thesis/Reconstruction/renderer.py”, line 274, in render_shape**<br>
**    rendering = self.rasterizer(transformed_vertices, self.faces.expand(batch_size, -1, -1), attributes)**<br>
**  File “/home/kak/anaconda3/envs/gt/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 722, in _call_impl**<br>
**    result = self.forward(<em>input, <strong>kwargs)</strong><br>
**  File “/home/kak/Documents/Thesis/Reconstruction/renderer.py”, line 67, in forward</em>*<br>
**    perspective_correct=raster_settings.perspective_correct,**<br>
**  File “/home/kak/anaconda3/envs/gt/lib/python3.6/site-packages/pytorch3d/renderer/mesh/rasterize_meshes.py”, line 150, in rasterize_meshes**<br>
**    cull_backfaces,**<br>
**  File “/home/kak/anaconda3/envs/gt/lib/python3.6/site-packages/pytorch3d/renderer/mesh/rasterize_meshes.py”, line 205, in forward**<br>
**    cull_backfaces,**<br>
<strong>TypeError: rasterize_meshes(): incompatible function arguments. The following argument types are supported:</strong><br>
**    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]**</p>
<p><strong>Invoked with: tensor([[[-2.9129e-01,  3.8580e-01,  9.9854e+00],</strong><br>
**         [-3.1403e-01,  3.8133e-01,  9.9865e+00],**<br>
**         [-2.8892e-01,  3.7910e-01,  9.9895e+00]],**</p>
<p>**        [[-3.2832e-01,  4.5427e-01,  1.0014e+01],**<br>
**         [-3.4195e-01,  4.3908e-01,  1.0008e+01],**<br>
**         [-3.3878e-01,  4.2805e-01,  1.0044e+01]],**</p>
<p>**        [[-2.9508e-01,  2.3414e-02,  1.0420e+01],**<br>
**         [-2.4708e-01, -2.5840e-04,  1.0480e+01],**<br>
**         [-2.3614e-01,  6.3354e-02,  1.0425e+01]],**</p>
<p>**        …,**</p>
<p>**        [[ 8.7310e-02,  2.2173e-01,  9.9789e+00],**<br>
**         [ 9.3325e-02,  2.2365e-01,  9.9810e+00],**<br>
**         [ 9.5288e-02,  2.1816e-01,  9.9787e+00]],**</p>
<pre><code>    [[ 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=&lt;IndexBackward&gt;), 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</code></pre>

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

Shriya_Kak: <p>Yes,  you are right. I corrected it and it worked. Thank you so much for your quick reply.<br>
<img src="https://discuss.pytorch.org/images/emoji/apple/smile.png?v=9" title=":smile:" class="emoji" alt=":smile:">  <img src="https://discuss.pytorch.org/images/emoji/apple/star_struck.png?v=9" title=":star_struck:" class="emoji" alt=":star_struck:"><br>
Have a great day ahead. <img src="https://discuss.pytorch.org/images/emoji/apple/+1.png?v=9" title=":+1:" class="emoji" alt=":+1:"></p>