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'

How can I fix this?

(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 <module>
    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'

$ 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.
>>> import torch
>>> torch.__version__
'1.6.0'
>>> torch.version.cuda
'10.1'
>>> 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

Here’s the code that is throwing error (not my code):

(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

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

1 Like

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.

Solution is listed here by the author of GitHub repo: