benjiebob / SMALify

This repository contains an implementation for performing 3D animal (quadruped) reconstruction from a monocular image or video. The system adapts the pose (limb positions) and shape (animal type/height/weight) parameters for the SMAL deformable quadruped model, as well as camera parameters until the projected SMAL model aligns with 2D keypoints and silhouette segmentations extracted from the input frame(s).
110 stars 18 forks source link

Pytorch3D error on running optimize_to_joints.py #30

Open dishitamidha opened 1 year ago

dishitamidha commented 1 year ago

Hey, I am facing the following error while running optimize_to_joints.py. I have followed all the instructions exactly as described but I am still facing this issue. Kindly help out.

100% 1/1 [00:00<00:00, 4.07it/s] Dataset size: 1 0% 0/150 [00:00<?, ?it/s] Traceback (most recent call last): File "smal_fitter/optimize_to_joints.py", line 149, in <module> main() File "smal_fitter/optimize_to_joints.py", line 123, in main loss, losses = model(batch_range, opt_weight, stage_id) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/content/drive/MyDrive/Jio/SMALify/smal_fitter/smal_fitter.py", line 134, in forward rendered_silhouettes, rendered_joints = self.renderer( File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/content/drive/MyDrive/Jio/SMALify/smal_fitter/p3d_renderer.py", line 68, in forward proj_points = self.cameras.transform_points_screen(points, screen_size)[:, :, [1, 0]] File "/usr/local/lib/python3.8/dist-packages/pytorch3d/renderer/cameras.py", line 353, in transform_points_screen points_ndc = self.transform_points_ndc(points, eps=eps, **kwargs) File "/usr/local/lib/python3.8/dist-packages/pytorch3d/renderer/cameras.py", line 323, in transform_points_ndc return world_to_ndc_transform.transform_points(points, eps=eps) File "/usr/local/lib/python3.8/dist-packages/pytorch3d/transforms/transform3d.py", line 400, in transform_points points_out = points_out[..., :3] / denom RuntimeError: The size of tensor a (3) must match the size of tensor b (2) at non-singleton dimension 2

mshooter commented 1 year ago

@dishitamidha what solved for me is: proj_points = self.cameras.transform_points_screen(points, image_size=screen_size)[:, :, [1, 0]]

yichuan1998 commented 1 year ago

@dishitamidha what solved for me is: proj_points = self.cameras.transform_points_screen(points, image_size=screen_size)[:, :, [1, 0]]

Hi, thanks for your code. I changed the IMAGE_RANGE in config.py from range(0,1) to range(0, 20) for training on 20 frames and got this error. Could you help me with that? Thanks! image