(gt_annos, det_annos, iou_thr)
| 276 | |
| 277 | |
| 278 | def ground_eval(gt_annos, det_annos, iou_thr): |
| 279 | |
| 280 | assert len(det_annos) == len(gt_annos) |
| 281 | |
| 282 | pred = {} |
| 283 | gt = {} |
| 284 | |
| 285 | object_types = [ |
| 286 | 'Easy', 'Hard', 'View-Dep', 'View-Indep', 'Unique', 'Multi', 'Overall' |
| 287 | ] |
| 288 | |
| 289 | for t in iou_thr: |
| 290 | for object_type in object_types: |
| 291 | pred.update({object_type + '@' + str(t): 0}) |
| 292 | gt.update({object_type + '@' + str(t): 1e-14}) |
| 293 | |
| 294 | for sample_id in range(len(det_annos)): |
| 295 | det_anno = det_annos[sample_id] |
| 296 | gt_anno = gt_annos[sample_id]['ann_info'] |
| 297 | |
| 298 | bboxes = det_anno['bboxes_3d'] |
| 299 | gt_bboxes = gt_anno['gt_bboxes_3d'] |
| 300 | bboxes = EulerDepthInstance3DBoxes(bboxes, origin=(0.5, 0.5, 0.5)) |
| 301 | gt_bboxes = EulerDepthInstance3DBoxes(gt_bboxes, |
| 302 | origin=(0.5, 0.5, 0.5)) |
| 303 | scores = bboxes.tensor.new_tensor( |
| 304 | det_anno['scores_3d']) # (num_query, ) |
| 305 | |
| 306 | view_dep = gt_anno['is_view_dep'] |
| 307 | hard = gt_anno['is_hard'] |
| 308 | unique = gt_anno['is_unique'] |
| 309 | |
| 310 | box_index = scores.argsort(dim=-1, descending=True)[:10] |
| 311 | top_bboxes = bboxes[box_index] |
| 312 | |
| 313 | iou = top_bboxes.overlaps(top_bboxes, gt_bboxes) # (num_query, 1) |
| 314 | |
| 315 | for t in iou_thr: |
| 316 | threshold = iou > t |
| 317 | found = int(threshold.any()) |
| 318 | if view_dep: |
| 319 | gt['View-Dep@' + str(t)] += 1 |
| 320 | pred['View-Dep@' + str(t)] += found |
| 321 | else: |
| 322 | gt['View-Indep@' + str(t)] += 1 |
| 323 | pred['View-Indep@' + str(t)] += found |
| 324 | if hard: |
| 325 | gt['Hard@' + str(t)] += 1 |
| 326 | pred['Hard@' + str(t)] += found |
| 327 | else: |
| 328 | gt['Easy@' + str(t)] += 1 |
| 329 | pred['Easy@' + str(t)] += found |
| 330 | if unique: |
| 331 | gt['Unique@' + str(t)] += 1 |
| 332 | pred['Unique@' + str(t)] += found |
| 333 | else: |
| 334 | gt['Multi@' + str(t)] += 1 |
| 335 | pred['Multi@' + str(t)] += found |
no test coverage detected