diff --git a/tools/__init__.py b/tools/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d0c32e26092f6ea25771279418582a24ea449ab2 --- /dev/null +++ b/tools/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/tools/configure.py b/tools/configure.py index 8b43b00bc2e694eb13fe0dd721b4c048e20f05d0..4a565aed9da87d38af7442771160f9c18ee21f73 100644 --- a/tools/configure.py +++ b/tools/configure.py @@ -151,9 +151,7 @@ def generate_config(**kwargs): print(dump_config(s, minimal)) -# FIXME this is pretty hackish, maybe implement a custom YAML printer? -def analyze_config(**kwargs): - config = load_config(kwargs['file']) +def print_total_cfg(config): modules = get_registered_modules() green = '___{}___'.format(color_tty.colors.index('green') + 31) @@ -222,6 +220,12 @@ def analyze_config(**kwargs): print(buffer) +# FIXME this is pretty hackish, maybe implement a custom YAML printer? +def analyze_config(**kwargs): + config = load_config(kwargs['file']) + print_total_cfg(config) + + if __name__ == '__main__': argv = sys.argv[1:] diff --git a/tools/eval.py b/tools/eval.py index eea606ec32019a1150938fa8b934413a38f7c089..089beec22701facabd1dc6ea2b5373fc9069e0a0 100644 --- a/tools/eval.py +++ b/tools/eval.py @@ -33,6 +33,7 @@ set_paddle_flags( import paddle.fluid as fluid +from tools.configure import print_total_cfg from ppdet.utils.eval_utils import parse_fetches, eval_run, eval_results, json_eval_results import ppdet.utils.checkpoint as checkpoint from ppdet.utils.cli import ArgsParser @@ -61,6 +62,7 @@ def main(): # check if set use_gpu=True in paddlepaddle cpu version check_gpu(cfg.use_gpu) + print_total_cfg(cfg) if 'eval_feed' not in cfg: eval_feed = create(main_arch + 'EvalFeed') diff --git a/tools/infer.py b/tools/infer.py index ac1fd215b9f540c8d78959864a041f43376e1be1..47684ed5de5fd916c06890b0acf8abecc9937fe1 100644 --- a/tools/infer.py +++ b/tools/infer.py @@ -22,11 +22,13 @@ import glob import numpy as np from PIL import Image + def set_paddle_flags(**kwargs): for key, value in kwargs.items(): if os.environ.get(key, None) is None: os.environ[key] = str(value) + # NOTE(paddle-dev): All of these flags should be set before # `import paddle`. Otherwise, it would not take any effect. set_paddle_flags( @@ -35,6 +37,7 @@ set_paddle_flags( from paddle import fluid +from tools.configure import print_total_cfg from ppdet.core.workspace import load_config, merge_config, create from ppdet.modeling.model_input import create_feed from ppdet.data.data_feed import create_reader @@ -147,6 +150,7 @@ def main(): # check if set use_gpu=True in paddlepaddle cpu version check_gpu(cfg.use_gpu) + print_total_cfg(cfg) if 'test_feed' not in cfg: test_feed = create(main_arch + 'TestFeed') diff --git a/tools/train.py b/tools/train.py index 95bba5fd2ceaa9097c42711905fa30fad984cfa5..c6a40842cd158247b1c0ff50965a5f3411ab4335 100644 --- a/tools/train.py +++ b/tools/train.py @@ -21,6 +21,7 @@ import time import numpy as np import datetime from collections import deque +from tools.configure import print_total_cfg def set_paddle_flags(**kwargs): @@ -36,7 +37,6 @@ set_paddle_flags( ) from paddle import fluid - from ppdet.core.workspace import load_config, merge_config, create from ppdet.data.data_feed import create_reader @@ -66,6 +66,7 @@ def main(): # check if set use_gpu=True in paddlepaddle cpu version check_gpu(cfg.use_gpu) + print_total_cfg(cfg) if cfg.use_gpu: devices_num = fluid.core.get_cuda_device_count()