zhulf0804 / PointPillars

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

Training with nclasses 1 results in error #43

Closed wojtat closed 5 months ago

wojtat commented 1 year ago

Hi, I'm trying to run train.py --nclasses 1, but it results in an IndexError:

Traceback (most recent call last):
  File "train.py", line 217, in <module>
    main(args)
  File "train.py", line 102, in main
    bbox_pred = bbox_pred[pos_idx]
IndexError: The shape of the mask [1928448] at index 0 does not match the shape of the indexed tensor [642816, 7] at index 0

It works fine with the default value of nclasses, but giving 1 gives this error. Can I ask for some help with fixing this please?

Xiong-lab commented 1 year ago

I have the same problem with you, I fix "pos_idx = (batched_bbox>=0)&(batched)bbox_labels<args.nclasses)" in train.py to "pos_idx = (batched_bbox>=0)&(batched)bbox_labels<args.nclasses+1)" to slove this problem.

Vito-Swift commented 7 months ago

This is because forward() in pointpillars.py will always pass a 3-row assigner matrix to anchor_target(). A quick fix is to select only the first nclasses assigners to proceed the program.

        if mode == 'train':
            anchor_target_dict = anchor_target(batched_anchors=batched_anchors,
                                               batched_gt_bboxes=batched_gt_bboxes,
                                               batched_gt_labels=batched_gt_labels,
                                               assigners=self.assigners[:self.nclasses],
                                               nclasses=self.nclasses)