zhulf0804 / PointPillars

A Simple PointPillars PyTorch Implementation for 3D LiDAR(KITTI) Detection.
MIT License
473 stars 116 forks source link

Evaluation with empty predictions #30

Closed wojtat closed 1 year ago

wojtat commented 1 year ago

Hello!

I tried to run the model evaluation script with the pretrained model weights and a custom dataset. When the model doesn't predict anything in a point cloud, it seems that the function do_eval complains. I got the following error:

Traceback (most recent call last):
  File "evaluate.py", line 390, in <module>
    main(args)
  File "evaluate.py", line 374, in main
    do_eval(format_results, val_dataset.data_infos, CLASSES, saved_path)
  File "evaluate.py", line 63, in do_eval
    iou2d_v = iou2d(torch.from_numpy(gt_bboxes2d).cuda(), torch.from_numpy(det_bboxes2d).cuda())
  File "PointPillars/utils/process.py", line 432, in iou2d
    bboxes_x1 = torch.maximum(bboxes1[:, 0][:, None], bboxes2[:, 0][None, :]) # (n, m)
IndexError: too many indices for tensor of dimension 1

The iou2d function doesn't seem to account for empty detections. Do you have any suggestions how to fix this or how it should behave?

Thanks in advance for any help!

zhulf0804 commented 1 year ago

Hello @wojtat , good question.

Update the code https://github.com/zhulf0804/PointPillars/blob/b9948e73505c8d6bfa631ffdf76c7148e82c5942/evaluate.py#L59 to

iou2d_v = iou2d(torch.from_numpy(gt_bboxes2d).reshape(-1, 4).cuda(), torch.from_numpy(det_bboxes2d).reshape(-1, 4).cuda())

For other commands using iou2d(), .reshape(-1, 4) is also added as above.

Then have a try ?

wojtat commented 1 year ago

Hi, after reshaping some of these detection arrays, it runs without crashing.

Thanks for the help!