diff --git a/PaddleCV/yolov3/train.py b/PaddleCV/yolov3/train.py index 5f2284cf0c264e261c1cd6cab1a675c59b1981a7..a89c6b30ea71804e017ad87eb0e6fef232c12de1 100644 --- a/PaddleCV/yolov3/train.py +++ b/PaddleCV/yolov3/train.py @@ -41,6 +41,7 @@ from utility import (parse_args, print_arguments, import paddle import paddle.fluid as fluid +from paddle.fluid import profiler import reader from models.yolov3 import YOLOv3 from learning_rate import exponential_with_warmup_decay @@ -186,6 +187,13 @@ def train(): iter_id, lr[0], smoothed_loss.get_mean_value(), start_time - prev_start_time)) sys.stdout.flush() + #add profiler tools + if args.is_profiler and iter_id == 5: + profiler.start_profiler("All") + elif args.is_profiler and iter_id == 10: + profiler.stop_profiler("total", args.profiler_path) + return + if (iter_id + 1) % cfg.snapshot_iter == 0: save_model("model_iter{}".format(iter_id)) print("Snapshot {} saved, average loss: {}, \ diff --git a/PaddleCV/yolov3/utility.py b/PaddleCV/yolov3/utility.py index 3e0f308289397143abdef77ed6c42f483d546bf3..9d442f4ee79b29691b84ec95b78ccfe76c4c55a0 100644 --- a/PaddleCV/yolov3/utility.py +++ b/PaddleCV/yolov3/utility.py @@ -146,6 +146,9 @@ def parse_args(): add_arg('draw_thresh', float, 0.5, "Confidence score threshold to draw prediction box in image in debug mode") add_arg('enable_ce', bool, False, "If set True, enable continuous evaluation job.") + # args for profiler tools + add_arg('is_profiler', int, 0, "the switch of profiler") + add_arg('profiler_path', str, './', "the path to save profiler output files") # yapf: enable args = parser.parse_args() file_name = sys.argv[0]