docstr: SMPL model constructor
docstr_tok: ["SMPL","model","constructor"]
code: def __init__(self, model_path, gender="neutral", device=None):
      """SMPL model constructor"""
      super(SMPL, self).__init__()
      dtype = torch.float32
      self.dtype = dtype
      self.device = device
      # create the SMPL model
      if osp.isdir(model_path):
          model_fn = "SMPL_{}.{ext}".format(gender.upper(), ext="pkl")
          smpl_path = osp.join(model_path, model_fn)
      else:
          smpl_path = model_path
      assert osp.exists(smpl_path), "Path {} does not exist!".format(
          smpl_path
      )
  
      with open(smpl_path, "rb") as smpl_file:
          data_struct = Struct(
              **pickle.load(smpl_file, encoding="latin1")
          )
      self.faces = data_struct.f
      self.register_buffer(
          "faces_tensor",
          to_tensor(
              to_np(self.faces, dtype=np.int64),
              dtype=torch.long,
              device=device,
          ),
      )
  
      # The vertices of the template model
      self.register_buffer(
          "v_template",
          to_tensor(
              to_np(data_struct.v_template), dtype=dtype, device=device
          ),
      )
  
      # The shape components
      self.register_buffer(
          "shapedirs",
          to_tensor(
              to_np(data_struct.shapedirs), dtype=dtype, device=device
          ),
      )
  
      self.register_buffer(
          "J_regressor",
          to_tensor(
              to_np(data_struct.J_regressor), dtype=dtype, device=device
          ),
      )
  
      # Pose blend shape basis: 6890 x 3 x 207, reshaped to 6890*3 x 207
      num_pose_basis = data_struct.posedirs.shape[-1]
      # 207 x 20670
      posedirs = np.reshape(
          data_struct.posedirs, [-1, num_pose_basis]
      ).T
      self.register_buffer(
          "posedirs",
          to_tensor(to_np(posedirs), dtype=dtype, device=device),
      )
  
      # indices of parents for each joints
      parents = to_tensor(
          to_np(data_struct.kintree_table[0]), device=device
      ).long()
      parents[0] = -1
      self.register_buffer("parents", parents)
  
      self.register_buffer(
          "lbs_weights",
          to_tensor(
              to_np(data_struct.weights), dtype=dtype, device=device
          ),
      )
  
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import division
  import os.path
  import pickle
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new SMPL object from inherited base classes: nn with example: obj = SMPL(model_path, gender, device)