From f3caf39c000f67f9b8f0d88deedcc196be6b885d Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Fri, 18 Dec 2020 18:45:59 +0800 Subject: [PATCH] unify setup_logger (#1928) --- ppdet/data/source/coco.py | 4 ++-- ppdet/data/source/voc.py | 5 +++-- ppdet/data/source/widerface.py | 5 +++-- ppdet/data/transform/batch_operator.py | 4 ++-- ppdet/data/transform/batch_operators.py | 4 ++-- ppdet/data/transform/operator.py | 4 ++-- ppdet/data/transform/operators.py | 4 ++-- ppdet/optimizer.py | 5 ++--- ppdet/utils/bbox_utils.py | 6 +++--- ppdet/utils/check.py | 5 +++-- ppdet/utils/checkpoint.py | 5 +++-- ppdet/utils/coco_eval.py | 4 ++-- ppdet/utils/download.py | 4 ++-- ppdet/utils/eval_utils.py | 5 +++-- ppdet/utils/map_utils.py | 5 +++-- ppdet/utils/post_process.py | 6 +++--- ppdet/utils/voc_eval.py | 4 ++-- 17 files changed, 42 insertions(+), 37 deletions(-) diff --git a/ppdet/data/source/coco.py b/ppdet/data/source/coco.py index 394ffdc86..4dad8265f 100644 --- a/ppdet/data/source/coco.py +++ b/ppdet/data/source/coco.py @@ -14,11 +14,11 @@ import os import numpy as np -import logging from ppdet.core.workspace import register, serializable from .dataset import DetDataset -logger = logging.getLogger(__name__) +from ppdet.utils.logger import setup_logger +logger = setup_logger(__name__) @register diff --git a/ppdet/data/source/voc.py b/ppdet/data/source/voc.py index fa28b12df..6ef016f3e 100644 --- a/ppdet/data/source/voc.py +++ b/ppdet/data/source/voc.py @@ -20,8 +20,9 @@ import xml.etree.ElementTree as ET from ppdet.core.workspace import register, serializable from .dataset import DetDataset -import logging -logger = logging.getLogger(__name__) + +from ppdet.utils.logger import setup_logger +logger = setup_logger(__name__) @register diff --git a/ppdet/data/source/widerface.py b/ppdet/data/source/widerface.py index f866d8d0f..3a2b5224e 100644 --- a/ppdet/data/source/widerface.py +++ b/ppdet/data/source/widerface.py @@ -14,12 +14,13 @@ import os import numpy as np -import logging -logger = logging.getLogger(__name__) from ppdet.core.workspace import register, serializable from .dataset import DataSet +from ppdet.utils.logger import setup_logger +logger = setup_logger(__name__) + @register @serializable diff --git a/ppdet/data/transform/batch_operator.py b/ppdet/data/transform/batch_operator.py index acfc326bb..ad68fb199 100644 --- a/ppdet/data/transform/batch_operator.py +++ b/ppdet/data/transform/batch_operator.py @@ -21,14 +21,14 @@ try: except Exception: from collections import Sequence -import logging import cv2 import numpy as np from .operator import register_op, BaseOperator, ResizeOp from .op_helper import jaccard_overlap, gaussian2D from scipy import ndimage -logger = logging.getLogger(__name__) +from ppdet.utils.logger import setup_logger +logger = setup_logger(__name__) __all__ = [ 'PadBatchOp', diff --git a/ppdet/data/transform/batch_operators.py b/ppdet/data/transform/batch_operators.py index dbb640496..424b0b2b0 100644 --- a/ppdet/data/transform/batch_operators.py +++ b/ppdet/data/transform/batch_operators.py @@ -21,14 +21,14 @@ try: except Exception: from collections import Sequence -import logging import cv2 import numpy as np from .operator import register_op, BaseOperator from .op_helper import jaccard_overlap, gaussian2D from .operators import NormalizeImage, Permute -logger = logging.getLogger(__name__) +from ppdet.utils.logger import setup_logger +logger = setup_logger(__name__) __all__ = [ 'PadBatch', diff --git a/ppdet/data/transform/operator.py b/ppdet/data/transform/operator.py index 6c39ed6e9..0392e7fe6 100644 --- a/ppdet/data/transform/operator.py +++ b/ppdet/data/transform/operator.py @@ -28,7 +28,6 @@ except Exception: from numbers import Number, Integral import uuid -import logging import random import math import numpy as np @@ -47,7 +46,8 @@ from .op_helper import (satisfy_sample_constraint, filter_and_process, generate_sample_bbox_square, bbox_area_sampling, is_poly, gaussian_radius, draw_gaussian) -logger = logging.getLogger(__name__) +from ppdet.utils.logger import setup_logger +logger = setup_logger(__name__) registered_ops = [] diff --git a/ppdet/data/transform/operators.py b/ppdet/data/transform/operators.py index cf2cef7a9..ef4e5eb09 100644 --- a/ppdet/data/transform/operators.py +++ b/ppdet/data/transform/operators.py @@ -28,7 +28,6 @@ except Exception: from numbers import Number import uuid -import logging import random import math import numpy as np @@ -47,7 +46,8 @@ from .op_helper import (satisfy_sample_constraint, filter_and_process, generate_sample_bbox_square, bbox_area_sampling, is_poly, gaussian_radius, draw_gaussian) -logger = logging.getLogger(__name__) +from ppdet.utils.logger import setup_logger +logger = setup_logger(__name__) @register_op diff --git a/ppdet/optimizer.py b/ppdet/optimizer.py index 21e9e4ce7..a11fde40d 100644 --- a/ppdet/optimizer.py +++ b/ppdet/optimizer.py @@ -17,8 +17,6 @@ from __future__ import division from __future__ import print_function import math -import logging - import paddle import paddle.nn as nn @@ -30,7 +28,8 @@ from ppdet.core.workspace import register, serializable __all__ = ['LearningRate', 'OptimizerBuilder'] -logger = logging.getLogger(__name__) +from ppdet.utils.logger import setup_logger +logger = setup_logger(__name__) @serializable diff --git a/ppdet/utils/bbox_utils.py b/ppdet/utils/bbox_utils.py index c6204d73b..63c93976c 100644 --- a/ppdet/utils/bbox_utils.py +++ b/ppdet/utils/bbox_utils.py @@ -16,12 +16,12 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import logging import numpy as np -__all__ = ["bbox_overlaps", "box_to_delta"] +from .logger import setup_logger +logger = setup_logger(__name__) -logger = logging.getLogger(__name__) +__all__ = ["bbox_overlaps", "box_to_delta"] def bbox_overlaps(boxes_1, boxes_2): diff --git a/ppdet/utils/check.py b/ppdet/utils/check.py index 32f889c03..4fc1d14f1 100644 --- a/ppdet/utils/check.py +++ b/ppdet/utils/check.py @@ -19,10 +19,11 @@ from __future__ import print_function import sys import paddle -import logging import six import paddle.version as fluid_version -logger = logging.getLogger(__name__) + +from .logger import setup_logger +logger = setup_logger(__name__) __all__ = ['check_gpu', 'check_version', 'check_config'] diff --git a/ppdet/utils/checkpoint.py b/ppdet/utils/checkpoint.py index 44e3f8269..89b22b8b2 100644 --- a/ppdet/utils/checkpoint.py +++ b/ppdet/utils/checkpoint.py @@ -24,8 +24,9 @@ import re import numpy as np import paddle from .download import get_weights_path -import logging -logger = logging.getLogger(__name__) + +from .logger import setup_logger +logger = setup_logger(__name__) def is_url(path): diff --git a/ppdet/utils/coco_eval.py b/ppdet/utils/coco_eval.py index b065a276a..b5ad0de75 100644 --- a/ppdet/utils/coco_eval.py +++ b/ppdet/utils/coco_eval.py @@ -23,8 +23,8 @@ import json import cv2 import numpy as np -import logging -logger = logging.getLogger(__name__) +from .logger import setup_logger +logger = setup_logger(__name__) __all__ = [ 'bbox_eval', diff --git a/ppdet/utils/download.py b/ppdet/utils/download.py index 64bdc09fa..279d33206 100644 --- a/ppdet/utils/download.py +++ b/ppdet/utils/download.py @@ -27,8 +27,8 @@ import zipfile from .voc_utils import create_list -import logging -logger = logging.getLogger(__name__) +from .logger import setup_logger +logger = setup_logger(__name__) __all__ = [ 'get_weights_path', 'get_dataset_path', 'download_dataset', diff --git a/ppdet/utils/eval_utils.py b/ppdet/utils/eval_utils.py index 6049cb635..60cbbc6c4 100644 --- a/ppdet/utils/eval_utils.py +++ b/ppdet/utils/eval_utils.py @@ -6,8 +6,9 @@ import os import sys import json from ppdet.py_op.post_process import get_det_res, get_seg_res -import logging -logger = logging.getLogger(__name__) + +from .logger import setup_logger +logger = setup_logger(__name__) def json_eval_results(metric, json_directory=None, dataset=None): diff --git a/ppdet/utils/map_utils.py b/ppdet/utils/map_utils.py index 085556972..65ec2bb9e 100644 --- a/ppdet/utils/map_utils.py +++ b/ppdet/utils/map_utils.py @@ -19,8 +19,9 @@ from __future__ import unicode_literals import sys import numpy as np -import logging -logger = logging.getLogger(__name__) + +from .logger import setup_logger +logger = setup_logger(__name__) __all__ = ['bbox_area', 'jaccard_overlap', 'DetectionMAP'] diff --git a/ppdet/utils/post_process.py b/ppdet/utils/post_process.py index ad8f2f233..45f9f9908 100644 --- a/ppdet/utils/post_process.py +++ b/ppdet/utils/post_process.py @@ -16,13 +16,13 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import logging import numpy as np import cv2 -__all__ = ['nms'] +from .logger import setup_logger +logger = setup_logger(__name__) -logger = logging.getLogger(__name__) +__all__ = ['nms'] def box_flip(boxes, im_shape): diff --git a/ppdet/utils/voc_eval.py b/ppdet/utils/voc_eval.py index 2bf14489b..4210c1009 100644 --- a/ppdet/utils/voc_eval.py +++ b/ppdet/utils/voc_eval.py @@ -25,8 +25,8 @@ from ..data.source.voc import pascalvoc_label from .map_utils import DetectionMAP from .coco_eval import bbox2out -import logging -logger = logging.getLogger(__name__) +from .logger import setup_logger +logger = setup_logger(__name__) __all__ = ['bbox_eval', 'bbox2out', 'get_category_info'] -- GitLab