File "/home/mona/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 772, in __getattr__ type(self).__name__, name)) torch.nn.modules.module.ModuleAttributeError: 'Renderer' object has no attribute 'render_points'

username: Mona_Jalal
cooked: <p>How can I fix this?</p>
<pre><code class="lang-auto">(base) mona@mona:~/research/3danimals/SMALViewer$ python smal_viewer.py 
dict_keys(['f', 'J_regressor', 'kintree_table', 'weights', 'posedirs', 'v_template', 'shapedirs'])
torch.Size([4, 3889])
 Tensor J_regressor shape:  torch.Size([37, 3889])
 Tensor weights shape:  torch.Size([3889, 33])
 Tensor posedirs shape:  torch.Size([3889, 3, 288])
 Tensor v_template shape:  torch.Size([3889, 3])
 Tensor shapedirs shape:  torch.Size([3889, 3, 41])
 Tensor faces shape:  torch.Size([7774, 3])
Traceback (most recent call last):
  File "smal_viewer.py", line 13, in &lt;module&gt;
    main()
  File "smal_viewer.py", line 6, in main
    main_window = pyqt_viewer.MainWindow()
  File "/home/mona/research/3danimals/SMALViewer/pyqt_viewer.py", line 50, in __init__
    self.setup_ui()
  File "/home/mona/research/3danimals/SMALViewer/pyqt_viewer.py", line 219, in setup_ui
    self.update_render()
  File "/home/mona/research/3danimals/SMALViewer/pyqt_viewer.py", line 241, in update_render
    rendered_images, rendered_silhouettes, rendered_joints, verts, joints_3d = self.model_renderer(self.smal_params)
  File "/home/mona/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/mona/research/3danimals/SMALViewer/smal/smal3d_renderer.py", line 45, in forward
    rendered_joints = self.renderer.render_points(joints_3d[:, self.smal_info.include_classes])
  File "/home/mona/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 772, in __getattr__
    type(self).__name__, name))
torch.nn.modules.module.ModuleAttributeError: 'Renderer' object has no attribute 'render_points'

</code></pre>
<pre><code class="lang-auto">$ python
Python 3.7.6 (default, Jan  8 2020, 19:59:22) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.__version__
'1.6.0'
&gt;&gt;&gt; torch.version.cuda
'10.1'
&gt;&gt;&gt; torch.cuda.is_available()
True


$ lsb_release -a
LSB Version:	core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal
</code></pre>
<aside class="onebox githubissue">
  <header class="source">
      <a href="https://github.com/benjiebob/SMALViewer/issues/4" target="_blank" rel="nofollow noopener">github.com/benjiebob/SMALViewer</a>
  </header>
  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" aria-hidden="true"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/benjiebob/SMALViewer/issues/4" target="_blank" rel="nofollow noopener">torch.nn.modules.module.ModuleAttributeError: 'Renderer' object has no attribute 'render_points'</a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2020-09-24" data-time="18:43:39" data-timezone="UTC">06:43PM - 24 Sep 20 UTC</span>
      </div>


      <div class="user">
        <a href="https://github.com/monajalal" target="_blank" rel="nofollow noopener">
          <img alt="monajalal" src="https://avatars3.githubusercontent.com/u/1892917?v=4" class="onebox-avatar-inline" width="20" height="20">
          monajalal
        </a>
      </div>
    </div>
  </div>
</div>

<div class="github-row">
  <p class="github-content">(base) mona@mona:~/research/3danimals/SMALViewer$ python smal_viewer.py 
dict_keys(['f', 'J_regressor', 'kintree_table', 'weights', 'posedirs', 'v_template', 'shapedirs'])
torch.Size([4, 3889])
 Tensor J_regressor shape: torch.Size([37, 3889])
 Tensor weights shape: torch.Size([3889,...</p>
</div>

<div class="labels">
</div>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>

<p>Here’s the code that is throwing error (not my code):</p>
<pre><code class="lang-auto">(base) mona@mona:~/research/3danimals/SMALViewer$ cat smal/smal3d_renderer.py
import sys, os
sys.path.append(os.path.dirname(sys.path[0]))

import torch
import torch.nn as nn
import neural_renderer as nr
import torch.nn.functional as F
from SMPL.smal_torch_batch import SMALModel
from smal.joint_catalog import SMALJointInfo

import pickle as pkl

import numpy as np
import cv2
import matplotlib.pyplot as plt

class SMAL3DRenderer(nn.Module):
    def __init__(self, image_size, z_distance = 2.5, elevation = 89.9, azimuth = 0.0):
        super(SMAL3DRenderer, self).__init__()
        
        self.smal_model = SMALModel()
        self.image_size = image_size
        self.smal_info = SMALJointInfo()

        self.renderer = nr.Renderer(camera_mode='look_at')
        self.renderer.eye = nr.get_points_from_angles(z_distance, elevation, azimuth)

        self.renderer.image_size = image_size
        self.renderer.light_intensity_ambient = 1.0

        with open("smal/dog_texture.pkl", 'rb') as f:
            self.textures = pkl.load(f).cuda()

    def forward(self, batch_params):
        batch_size = batch_params['betas'].shape[0]
        
        verts, joints_3d = self.smal_model(
            batch_params['betas'],
            torch.cat((batch_params['global_rotation'], batch_params['joint_rotations']), dim = 1),
            batch_params['trans'])
   
        faces = self.smal_model.faces.unsqueeze(0).expand(batch_size, -1, -1)
        textures = self.textures.unsqueeze(0).expand(batch_size, -1, -1, -1, -1, -1)

        rendered_joints = self.renderer.render_points(joints_3d[:, self.smal_info.include_classes])
        rendered_silhouettes = self.renderer.render_silhouettes(verts, faces)
        rendered_silhouettes = rendered_silhouettes.unsqueeze(1)

        rendered_images = self.renderer.render(verts, faces, textures)    
        rendered_images = torch.clamp(rendered_images[0], 0.0, 1.0)

        return rendered_images, rendered_silhouettes, rendered_joints, verts, joints_3d
</code></pre>

username: ptrblck
cooked: <p>The <code>render_points</code> method seems to be implemented in <code>nr.Renderer(camera_mode='look_at')</code>, which seems to come from <code>neural_renderer</code>.<br>
I would thus suggest to create an issue in their repository, if that’s not already done with the cross post in the <code>SMALViewer</code> repo.</p>

username: Mona_Jalal
cooked: <p>Thank you. I will create an issue in neural_renderer repo and update here with an answer if I get one. I guess I made the cross post in the wrong repo. Thanks for noting that.</p>

username: Mona_Jalal
cooked: <p>Solution is listed here by the author of GitHub repo:</p>
<aside class="onebox githubissue">
  <header class="source">
      <a href="https://github.com/benjiebob/SMALViewer/issues/1#issuecomment-699561018" target="_blank" rel="noopener nofollow ugc">github.com/benjiebob/SMALViewer</a>
  </header>
  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" aria-hidden="true"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/benjiebob/SMALViewer/issues/1#issuecomment-699561018" target="_blank" rel="noopener nofollow ugc">cannot find function "render_points" in smal3d_renderer.py</a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2020-05-24" data-time="10:41:36" data-timezone="UTC">10:41AM - 24 May 20 UTC</span>
      </div>

        <div class="date">
          closed <span class="discourse-local-date" data-format="ll" data-date="2020-09-26" data-time="23:35:06" data-timezone="UTC">11:35PM - 26 Sep 20 UTC</span>
        </div>

      <div class="user">
        <a href="https://github.com/xjsxujingsong" target="_blank" rel="noopener nofollow ugc">
          <img alt="xjsxujingsong" src="https://avatars2.githubusercontent.com/u/1683858?v=4" class="onebox-avatar-inline" width="20" height="20">
          xjsxujingsong
        </a>
      </div>
    </div>
  </div>
</div>

<div class="github-row">
  <p class="github-content">Hi,
I am trying to use your tool and have successuly installed all files.
During running, it came to an error:
in "smal3d_renderer.py", line...</p>
</div>

<div class="labels">
</div>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>