Refactor metrics
This commit is contained in:
parent
689be75478
commit
65e9735bd9
@ -38,16 +38,13 @@ def rectangle_from_dict(d):
|
||||
def compute_page_iou(results_boxes: Iterable[Rectangle], ground_truth_boxes: Iterable[Rectangle]):
|
||||
results = list(results_boxes)
|
||||
truth = list(ground_truth_boxes)
|
||||
if (not results) or (not truth):
|
||||
return 0
|
||||
iou_sum = 0
|
||||
denominator = max(len(results), len(truth))
|
||||
while results and truth:
|
||||
gt_box = truth.pop()
|
||||
|
||||
def find_best_iou(gt_box):
|
||||
best_match, best_iou = find_max_overlap(gt_box, results)
|
||||
results.remove(best_match)
|
||||
iou_sum += best_iou
|
||||
score = iou_sum / denominator
|
||||
return best_iou
|
||||
|
||||
score = sum(map(find_best_iou, truth)) / max(len(results), len(truth))
|
||||
return score
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user