From b38a4f22ad6daa919d820ab6b509641ca4cbacde Mon Sep 17 00:00:00 2001 From: "PJLAB\\huanghaian" <1286304229@qq.com> Date: Mon, 15 Nov 2021 15:22:26 +0800 Subject: [PATCH] Save coco summarize print information to logger --- mmdet/datasets/coco.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mmdet/datasets/coco.py b/mmdet/datasets/coco.py index 6c0bd963bee..5c776763993 100644 --- a/mmdet/datasets/coco.py +++ b/mmdet/datasets/coco.py @@ -1,4 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. +import contextlib +import io import itertools import logging import os.path as osp @@ -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', @@ -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/