def get_rescore_bboxes(self, guided_anchors, cls_scores, anchor_labels, img_metas, cfg): det_bboxes = list() det_scores = list() det_labels = list() for i in range(len(img_metas)): bbox_pred = guided_anchors[i] scores = cls_scores[i] labels = anchor_labels[i] if scores.numel() == 0: det_bboxes.append(None) det_scores.append(None) det_labels.append(None) continue bbox_pred = bbox_pred.view(-1, 7) scores = torch.sigmoid(scores).view(-1) select = scores > cfg.score_thr bbox_pred = bbox_pred[select, :] scores = scores[select] labels = labels[select] if scores.numel() == 0: det_bboxes.append(None) det_scores.append(None) det_labels.append(None) continue boxes_for_nms = boxes3d_to_bev_torch(bbox_pred) keep = rotate_nms_torch(boxes_for_nms, scores, iou_threshold=cfg.nms.iou_thr) bbox_pred = bbox_pred[keep, :] scores = scores[keep] labels = labels[keep] det_bboxes.append(bbox_pred.detach().cpu().numpy()) det_scores.append(scores.detach().cpu().numpy()) det_labels.append(labels.detach().cpu().numpy()) return det_bboxes, det_scores, det_labels
def get_det_bboxes(self, rois, cls_scores, bbox_preds, img_metas, cfg): det_bboxes = list() det_scores = list() for i in range(len(img_metas)): inds = torch.nonzero(rois[:, 0] == i).squeeze() roi = rois[inds, 1:] scores = cls_scores[inds, :] if bbox_preds is not None: bbox_pred = bbox_preds[inds, :] else: bbox_pred = roi scores = torch.sigmoid(scores).view(-1) select = scores > cfg.score_thr bbox_pred = bbox_pred[select, :] roi = roi[select, :] scores = scores[select] if scores.numel() == 0: det_bboxes.append(bbox_pred) det_scores.append(scores) continue if bbox_preds is not None: bbox_pred = delta2rbbox3d(roi, bbox_pred, self.target_means, self.target_stds) boxes_for_nms = boxes3d_to_bev_torch(bbox_pred) keep = rotate_nms_torch(boxes_for_nms, scores, iou_threshold=cfg.nms.iou_thr) bbox_pred = bbox_pred[keep, :] scores = scores[keep] det_bboxes.append(bbox_pred.detach().cpu().numpy()) det_scores.append(scores.detach().cpu().numpy()) return det_bboxes, det_scores