Skip to content
Snippets Groups Projects
Commit 8fc57a85 authored by Akinmukomi Oluwaseun's avatar Akinmukomi Oluwaseun
Browse files

Revert "- Added code for ap50 calculation"

This reverts commit 99564e18.
parent 99564e18
No related branches found
No related tags found
1 merge request!1- Added code for ap50 calculation
...@@ -334,12 +334,6 @@ if __name__ == "__main__": ...@@ -334,12 +334,6 @@ if __name__ == "__main__":
if args.no_evaluation: if args.no_evaluation:
continue continue
# Initialize variables for AP50 calculation
tp = 0
fp = 0
total_gt_boxes = len(gt_bbxs)
ap50 = 0
# Compare prediction to GT boxes # Compare prediction to GT boxes
for pred in preds: for pred in preds:
if len(preds) == 0: if len(preds) == 0:
...@@ -351,31 +345,19 @@ if __name__ == "__main__": ...@@ -351,31 +345,19 @@ if __name__ == "__main__":
ious = bbox_iou(torch.from_numpy(pred), torch.from_numpy(np.asarray(gt_bbxs))) ious = bbox_iou(torch.from_numpy(pred), torch.from_numpy(np.asarray(gt_bbxs)))
# TODO: This calculates the corloc # TODO: This calculates the corloc
# we need to calculate the AP50
if torch.any(ious >= 0.50): if torch.any(ious >= 0.50):
#corloc[im_id] = 1 #corloc[im_id] = 1
corloc[im_id] = 0 corloc[im_id] = 0
for i in ious: for i in ious:
if i >= 0.50: if i >= 0.50:
corloc[im_id] += 1 corloc[im_id] += 1
# Count true positives and false positives at IoU threshold of 0.5
if torch.any(ious >= 0.50):
tp += 1
else:
fp += 1
cnt += len(gt_bbxs) cnt += len(gt_bbxs)
if cnt % 50 == 0: if cnt % 50 == 0:
pbar.set_description(f"Found {int(np.sum(corloc))}/{cnt}") pbar.set_description(f"Found {int(np.sum(corloc))}/{cnt}")
# Calculate precision and recall at IoU threshold of 0.5
precision = tp / (tp + fp)
recall = tp / total_gt_boxes
# Calculate AP50 as average precision at IoU threshold of 0.5
ap50 = precision * recall
print(f"AP50: {ap50:.2f}")
# Save predicted bounding boxes # Save predicted bounding boxes
if args.save_predictions: if args.save_predictions:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment