EPro-PnP icon indicating copy to clipboard operation
EPro-PnP copied to clipboard

The Cv2.solvepnp function prompts that the dimensions do not match

Open breeze623 opened this issue 2 years ago • 4 comments

IndexError: boolean index did not match indexed array along dimension 1; dimension is 64 but corresponding boolean dimension is 2. I found that dim=1 in pred_conf_np = w2d.mean(dim=1).cpu().numpy() needs to be modified to -1. But after that there is a new error as follow. Traceback (most recent call last): File "main.py", line 108, in main() File "main.py", line 77, in main _, preds = test(0, cfg, test_loader, network, obj_vtx, obj_info, criterions) File "/home/raid/james/EPro-PnP-main/EPro-PnP-6DoF/tools/../lib/test.py", line 223, in test pose_init=pose_opt, force_init_solve=False, fast_mode=True) File "/home/raid/james/EPro-PnP-main/EPro-PnP-6DoF/tools/../lib/ops/pnp/epropnp.py", line 144, in monte_carlo_forward new_trans_distr, new_rot_distr = self.gen_new_distr(i, *distr_params) File "/home/raid/james/EPro-PnP-main/EPro-PnP-6DoF/tools/../lib/ops/pnp/epropnp.py", line 306, in gen_new_distr new_trans_distr = MultivariateStudentT(3, trans_mode[iter_id], trans_cov_tril[iter_id]) File "/home/ubuntu/.local/lib/python3.6/site-packages/pyro/distributions/distribution.py", line 18, in call return super().call(*args, **kwargs) File "/home/ubuntu/.local/lib/python3.6/site-packages/pyro/distributions/multivariate_studentt.py", line 45, in init super().init(batch_shape, event_shape, validate_args=validate_args) File "/home/ubuntu/.local/lib/python3.6/site-packages/torch/distributions/distribution.py", line 53, in init raise ValueError("The parameter {} has invalid values".format(param)) ValueError: The parameter loc has invalid values

breeze623 avatar Aug 01 '22 03:08 breeze623

The dimension-related issue is a duplicate of #17, which has been fixed in the latest commit. We've never encountered the invalid parameter issue. Can you try printing trans_mode[iter_id]?

Lakonik avatar Aug 01 '22 09:08 Lakonik

trans_mode: tensor([[nan, nan, nan], [nan, nan, nan], [nan, nan, nan], [nan, nan, nan], [nan, nan, nan], [nan, nan, nan], [nan, nan, nan], [nan, nan, nan]], device='cuda:0') trans_mode.shape: torch.Size([8, 3]) trans_cov_tril: tensor([[[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]],

    [[1., 0., 0.],
     [0., 1., 0.],
     [0., 0., 1.]],

    [[1., 0., 0.],
     [0., 1., 0.],
     [0., 0., 1.]],

    [[1., 0., 0.],
     [0., 1., 0.],
     [0., 0., 1.]],

    [[1., 0., 0.],
     [0., 1., 0.],
     [0., 0., 1.]],

    [[1., 0., 0.],
     [0., 1., 0.],
     [0., 0., 1.]],

    [[1., 0., 0.],
     [0., 1., 0.],
     [0., 0., 1.]],

    [[1., 0., 0.],
     [0., 1., 0.],
     [0., 0., 1.]]], device='cuda:0')

trans_cov_tril.shape: torch.Size([8, 3, 3])

breeze623 avatar Aug 01 '22 09:08 breeze623

Are you testing the pre-trained models? If so, it looks like the model is not loaded correctly. Make sure the load_model argument in the config file points to the pre-trained checkpoint.

Lakonik avatar Aug 01 '22 10:08 Lakonik

I modified line 13 of epropnp_basic.yaml and it work(another bug ^_^),thanks

breeze623 avatar Aug 01 '22 10:08 breeze623