Skip to content

Commit

Permalink
Save coco summarize print information to logger (open-mmlab#6505)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaAndroid authored and ZwwWayne committed Jul 18, 2022
1 parent 28b0333 commit 9c43956
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mmdet/datasets/coco.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
import contextlib
import io
import itertools
import logging
import os.path as osp
Expand Down Expand Up @@ -490,7 +492,13 @@ def evaluate(self,
cocoEval.params.useCats = 0
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()

# Save coco summarize print information to logger
redirect_string = io.StringIO()
with contextlib.redirect_stdout(redirect_string):
cocoEval.summarize()
print_log('\n' + redirect_string.getvalue(), logger=logger)

if metric_items is None:
metric_items = [
'AR@100', 'AR@300', 'AR@1000', 'AR_s@1000',
Expand All @@ -504,7 +512,13 @@ def evaluate(self,
else:
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()

# Save coco summarize print information to logger
redirect_string = io.StringIO()
with contextlib.redirect_stdout(redirect_string):
cocoEval.summarize()
print_log('\n' + redirect_string.getvalue(), logger=logger)

if classwise: # Compute per-category AP
# Compute per-category AP
# from https://github.com/facebookresearch/detectron2/
Expand Down

0 comments on commit 9c43956

Please sign in to comment.