Bbox coder for NMS-free detector. Args: pc_range (list[float]): Range of point cloud. post_center_range (list[float]): Limit of the center. Default: None. max_num (int): Max number to be kept. Default: 100. score_threshold (float): Threshold to filter
| 8 | |
| 9 | @BBOX_CODERS.register_module() |
| 10 | class NMSFreeCoder(BaseBBoxCoder): |
| 11 | """Bbox coder for NMS-free detector. |
| 12 | Args: |
| 13 | pc_range (list[float]): Range of point cloud. |
| 14 | post_center_range (list[float]): Limit of the center. |
| 15 | Default: None. |
| 16 | max_num (int): Max number to be kept. Default: 100. |
| 17 | score_threshold (float): Threshold to filter boxes based on score. |
| 18 | Default: None. |
| 19 | code_size (int): Code size of bboxes. Default: 9 |
| 20 | """ |
| 21 | |
| 22 | def __init__(self, |
| 23 | pc_range, |
| 24 | voxel_size=None, |
| 25 | post_center_range=None, |
| 26 | max_num=100, |
| 27 | score_threshold=None, |
| 28 | num_classes=10): |
| 29 | self.pc_range = pc_range |
| 30 | self.voxel_size = voxel_size |
| 31 | self.post_center_range = post_center_range |
| 32 | self.max_num = max_num |
| 33 | self.score_threshold = score_threshold |
| 34 | self.num_classes = num_classes |
| 35 | |
| 36 | def encode(self): |
| 37 | |
| 38 | pass |
| 39 | |
| 40 | def decode_single(self, cls_scores, bbox_preds): |
| 41 | """Decode bboxes. |
| 42 | Args: |
| 43 | cls_scores (Tensor): Outputs from the classification head, \ |
| 44 | shape [num_query, cls_out_channels]. Note \ |
| 45 | cls_out_channels should includes background. |
| 46 | bbox_preds (Tensor): Outputs from the regression \ |
| 47 | head with normalized coordinate format (cx, cy, w, l, cz, h, rot_sine, rot_cosine, vx, vy). \ |
| 48 | Shape [num_query, 9]. |
| 49 | Returns: |
| 50 | list[dict]: Decoded boxes. |
| 51 | """ |
| 52 | max_num = self.max_num |
| 53 | |
| 54 | cls_scores = cls_scores.sigmoid() |
| 55 | scores, indexs = cls_scores.view(-1).topk(max_num) |
| 56 | labels = indexs % self.num_classes |
| 57 | bbox_index = indexs // self.num_classes |
| 58 | bbox_preds = bbox_preds[bbox_index] |
| 59 | |
| 60 | final_box_preds = denormalize_bbox(bbox_preds, self.pc_range) |
| 61 | final_scores = scores |
| 62 | final_preds = labels |
| 63 | |
| 64 | # use score threshold |
| 65 | if self.score_threshold is not None: |
| 66 | thresh_mask = final_scores > self.score_threshold |
| 67 | tmp_score = self.score_threshold |
nothing calls this directly
no outgoing calls
no test coverage detected