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

tests: data: coco_evaluation: Fix test #5298

Open
wants to merge 1 commit into
base: main
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
9 changes: 7 additions & 2 deletions tests/data/test_coco_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_fast_eval(self):
api_exception = None
try:
with contextlib.redirect_stdout(io.StringIO()):
coco_dt = coco_api.loadRes(dt)
coco_dt = coco_api.loadRes(copy.deepcopy(dt))
coco_eval = COCOeval(coco_api, coco_dt, iou_type)
for p, v in params.items():
setattr(coco_eval.params, p, v)
Expand All @@ -98,7 +98,7 @@ def test_fast_eval(self):
opt_exception = None
try:
with contextlib.redirect_stdout(io.StringIO()):
coco_dt = coco_api.loadRes(dt)
coco_dt = coco_api.loadRes(copy.deepcopy(dt))
coco_eval_opt = COCOeval_opt(coco_api, coco_dt, iou_type)
for p, v in params.items():
setattr(coco_eval_opt.params, p, v)
Expand All @@ -115,6 +115,11 @@ def test_fast_eval(self):
opt_error = "" if opt_exception is None else type(opt_exception).__name__
msg = "%s: comparing COCO APIs, '%s' != '%s'" % (name, api_error, opt_error)
self.assertTrue(api_error == opt_error, msg=msg)
elif (api_exception is None) ^ (opt_exception is None):
self.fail(
f"One of the APIs threw an exception while the other did not (api != opt): "
f"{api_exception} != {opt_exception}"
)
else:
# Original API and optimized API should produce the same precision/recalls
for k in ["precision", "recall"]:
Expand Down