(preds: dict, gt_path: str, print_result=True)
| 337 | return np.diag(hist) / (hist.sum(1) + hist.sum(0) - np.diag(hist)) |
| 338 | |
| 339 | def evaluate(preds: dict, gt_path: str, print_result=True): |
| 340 | matches = {} |
| 341 | for (k, v) in tqdm(preds.items(), desc="evaluate instances"): |
| 342 | gt_file = os.path.join(gt_path, k + ".txt") |
| 343 | if not os.path.isfile(gt_file): |
| 344 | util.print_error('Scan {} does not match any gt file'.format(k), user_fault=True) |
| 345 | |
| 346 | matches_key = os.path.abspath(gt_file) |
| 347 | # assign gt to predictions |
| 348 | gt2pred, pred2gt = assign_instances_for_scan(v, gt_file) |
| 349 | matches[matches_key] = {} |
| 350 | matches[matches_key]['gt'] = gt2pred |
| 351 | matches[matches_key]['pred'] = pred2gt |
| 352 | |
| 353 | ap_scores = evaluate_matches(matches) |
| 354 | avgs = compute_averages(ap_scores) |
| 355 | |
| 356 | if print_result: |
| 357 | print_results(avgs) |
| 358 | |
| 359 | return avgs |
| 360 | |
| 361 |
no test coverage detected