Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update coco_evaluation.py #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions coco_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ def getDetections(groundtruth, evaluation, imgIds = [], annIds = [], detection_t

for gt_box_id in gt_bboxes:
gt_box = groundtruth.anns[gt_box_id]['bbox']
max_iou = detection_threshold
max_iou = 0.0
match = None
for eval_box_id in eval_bboxes:
eval_box = evaluation.anns[eval_box_id]['bbox']
iou = iou_score(gt_box,eval_box)
if iou > max_iou:
if iou >= detection_threshold and iou > max_iou: # seek best match
max_iou = iou
match = eval_box_id
if match:
detectRes['true_positives'].append({'gt_id': gt_box_id, 'eval_id': eval_box_id})
eval_bboxes.remove(eval_box_id)
if match is not None:
detectRes['true_positives'].append({'gt_id': gt_box_id, 'eval_id': match})
eval_bboxes.remove(match)
else:
detectRes['false_negatives'].append({'gt_id': gt_box_id})
if len(eval_bboxes)>0:
Expand Down Expand Up @@ -125,22 +126,23 @@ def evaluateEndToEnd(groundtruth, evaluation, imgIds = [], annIds = [], detectio
continue
gt_val = decode(groundtruth.anns[gt_box_id]['utf8_string'])

max_iou = detection_threshold
max_iou = 0.0

match = None
for eval_box_id in eval_bboxes:
eval_box = evaluation.anns[eval_box_id]['bbox']
iou = iou_score(gt_box,eval_box)

if iou > max_iou:
if iou >= detection_threshold and iou > max_iou:
max_iou = iou
match = eval_box_id
if 'utf8_string' in evaluation.anns[eval_box_id]:
eval_val = decode(evaluation.anns[eval_box_id]['utf8_string'])
if editdistance.eval(gt_val, eval_val)==0:
break
if match is not None:
detectRes['true_positives'].append({'gt_id': gt_box_id, 'eval_id': eval_box_id})
eval_bboxes.remove(eval_box_id)
detectRes['true_positives'].append({'gt_id': gt_box_id, 'eval_id': match})
eval_bboxes.remove(match)
else:
detectRes['false_negatives'].append({'gt_id': gt_box_id})
if len(eval_bboxes)>0:
Expand Down