"git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "49859788f478b37adcf8fd13438c79f3a465d1ed"
Commit cbb98068 authored by liyinhao's avatar liyinhao
Browse files

mv gt_infos out of the function

parent 0fdcb06d
...@@ -200,7 +200,7 @@ def eval_map_recall(det_infos, gt_infos, ovthresh=None): ...@@ -200,7 +200,7 @@ def eval_map_recall(det_infos, gt_infos, ovthresh=None):
Args: Args:
det_infos (List): Label, bbox and score of the detection result. det_infos (List): Label, bbox and score of the detection result.
gt_infos (List[dict]): Information of the ground truth. gt_infos (List): Label, bbox of the groundtruth.
ovthresh (List[float]): iou threshold. ovthresh (List[float]): iou threshold.
Default: None. Default: None.
...@@ -210,22 +210,12 @@ def eval_map_recall(det_infos, gt_infos, ovthresh=None): ...@@ -210,22 +210,12 @@ def eval_map_recall(det_infos, gt_infos, ovthresh=None):
dict: {classname: scalar}. dict: {classname: scalar}.
""" """
pred_all = {} pred_all = {}
gt_all = {}
scan_cnt = 0 scan_cnt = 0
for batch_pred_map_cls in det_infos: for batch_pred_map_cls in det_infos:
for i in range(len(batch_pred_map_cls)): for i in range(len(batch_pred_map_cls)):
pred_all[scan_cnt] = batch_pred_map_cls[i] pred_all[scan_cnt] = batch_pred_map_cls[i]
scan_cnt += 1 scan_cnt += 1
# cacge gt infos
scan_cnt = 0
for gt_info in gt_infos:
cur_gt = list()
for n in range(gt_info['gt_num']):
cur_gt.append(
(gt_info['class'][n], gt_info['gt_boxes_upright_depth'][n]))
gt_all[scan_cnt] = cur_gt
scan_cnt += 1
pred = {} # map {classname: pred} pred = {} # map {classname: pred}
gt = {} # map {classname: gt} gt = {} # map {classname: gt}
for img_id in pred_all.keys(): for img_id in pred_all.keys():
...@@ -240,8 +230,8 @@ def eval_map_recall(det_infos, gt_infos, ovthresh=None): ...@@ -240,8 +230,8 @@ def eval_map_recall(det_infos, gt_infos, ovthresh=None):
gt[int(label)][img_id] = [] gt[int(label)][img_id] = []
pred[int(label)][img_id].append((bbox, score)) pred[int(label)][img_id].append((bbox, score))
for img_id in gt_all.keys(): for img_id in range(len(gt_infos)):
for label, bbox in gt_all[img_id]: for label, bbox in gt_infos[img_id]:
if label not in gt: if label not in gt:
gt[label] = {} gt[label] = {}
if img_id not in gt[label]: if img_id not in gt[label]:
...@@ -284,31 +274,24 @@ def indoor_eval(gt_annos, dt_annos, metric, label2cat): ...@@ -284,31 +274,24 @@ def indoor_eval(gt_annos, dt_annos, metric, label2cat):
Return: Return:
dict: Dict of results. dict: Dict of results.
""" """
gt_infos = []
for gt_anno in gt_annos: for gt_anno in gt_annos:
if gt_anno['gt_num'] != 0: if gt_anno['gt_num'] != 0:
# convert to lidar coor for evaluation # convert to lidar coor for evaluation
bbox_lidar_bottom = boxes3d_depth_to_lidar( bbox_lidar_bottom = boxes3d_depth_to_lidar(
gt_anno['gt_boxes_upright_depth'], mid_to_bottom=True) gt_anno['gt_boxes_upright_depth'], mid_to_bottom=True)
if gt_anno['gt_boxes_upright_depth'].shape[-1] == 6: if bbox_lidar_bottom.shape[-1] == 6:
gt_anno['gt_boxes_upright_depth'] = np.pad( bbox_lidar_bottom = np.pad(bbox_lidar_bottom, ((0, 0), (0, 1)),
bbox_lidar_bottom, ((0, 0), (0, 1)), 'constant') 'constant')
else: gt_info_temp = []
gt_anno['gt_boxes_upright_depth'] = bbox_lidar_bottom for i in range(gt_anno['gt_num']):
# gt_infos = [] gt_info_temp.append(
# for gt_anno in gt_annos: [gt_anno['class'][i], bbox_lidar_bottom[i]])
# if gt_anno['gt_num'] != 0: gt_infos.append(gt_info_temp)
# # convert to lidar coor for evaluation
# bbox_lidar_bottom = boxes3d_depth_to_lidar(
# gt_anno['gt_boxes_upright_depth'], mid_to_bottom=True)
# if bbox_lidar_bottom.shape[-1] == 6:
# bbox_lidar_bottom= np.pad(
# bbox_lidar_bottom, ((0, 0), (0, 1)), 'constant')
# for i in range(gt_anno['gt_num']):
# gt_infos.append([gt_anno['class'][i], bbox_lidar_bottom[i]])
result_str = str() result_str = str()
result_str += 'mAP' result_str += 'mAP'
rec, prec, ap = eval_map_recall(dt_annos, gt_annos, metric) rec, prec, ap = eval_map_recall(dt_annos, gt_infos, metric)
ret_dict = {} ret_dict = {}
for i, iou_thresh in enumerate(metric): for i, iou_thresh in enumerate(metric):
for label in ap[i].keys(): for label in ap[i].keys():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment