From f7efca5eac59c62aad417c53498e9937ffe2fe9e Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Mon, 22 Apr 2019 05:37:29 +0000 Subject: [PATCH] add arg syncbn. --- PaddleCV/yolov3/README.md | 12 ++++++++++-- PaddleCV/yolov3/README_cn.md | 14 +++++++++++--- PaddleCV/yolov3/train.py | 2 +- PaddleCV/yolov3/utility.py | 1 + 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/PaddleCV/yolov3/README.md b/PaddleCV/yolov3/README.md index b4547b35..679eeb0c 100644 --- a/PaddleCV/yolov3/README.md +++ b/PaddleCV/yolov3/README.md @@ -134,11 +134,19 @@ Evaluation is to evaluate the performance of a trained model. This sample provid - Set ```export CUDA_VISIBLE_DEVICES=0``` to specifiy one GPU to eval. -Evalutaion result is shown as below: +If train with '--syncbn=False', Evalutaion result is shown as below: | input size | mAP(IoU=0.50:0.95) | mAP(IoU=0.50) | mAP(IoU=0.75) | | :------: | :------: | :------: | :------: | -| 608x608| 38.9 | 61.1 | 42.0 | +| 608x608 | 37.7 | 59.8 | 40.8 | +| 416x416 | 36.5 | 58.2 | 39.1 | +| 320x320 | 34.1 | 55.4 | 36.3 | + +If train with '--syncbn=True', Evalutaion result is shown as below: + +| input size | mAP(IoU=0.50:0.95) | mAP(IoU=0.50) | mAP(IoU=0.75) | +| :------: | :------: | :------: | :------: | +| 608x608 | 38.9 | 61.1 | 42.0 | | 416x416 | 37.5 | 59.6 | 40.2 | | 320x320 | 34.8 | 56.4 | 36.9 | diff --git a/PaddleCV/yolov3/README_cn.md b/PaddleCV/yolov3/README_cn.md index 6bc8dd4c..583594a9 100644 --- a/PaddleCV/yolov3/README_cn.md +++ b/PaddleCV/yolov3/README_cn.md @@ -134,15 +134,23 @@ Train Loss - 通过设置export CUDA\_VISIBLE\_DEVICES=0指定单卡GPU评估。 -模型评估结果: +若训练时指定'--syncbn=False', 模型评估精度如下: | input size | mAP(IoU=0.50:0.95) | mAP(IoU=0.50) | mAP(IoU=0.75) | | :------: | :------: | :------: | :------: | -| 608x608| 38.9 | 61.1 | 42.0 | +| 608x608 | 37.7 | 59.8 | 40.8 | +| 416x416 | 36.5 | 58.2 | 39.1 | +| 320x320 | 34.1 | 55.4 | 36.3 | + +若训练时指定'--syncbn=True', 模型评估精度如下: + +| input size | mAP(IoU=0.50:0.95) | mAP(IoU=0.50) | mAP(IoU=0.75) | +| :------: | :------: | :------: | :------: | +| 608x608 | 38.9 | 61.1 | 42.0 | | 416x416 | 37.5 | 59.6 | 40.2 | | 320x320 | 34.8 | 56.4 | 36.9 | -- **注意: **评估结果基于`pycocotools`评估器,没有滤除`score < 0.05`的预测框,其他框架有此滤除操作会导致精度下降。 +- **注意:** 评估结果基于`pycocotools`评估器,没有滤除`score < 0.05`的预测框,其他框架有此滤除操作会导致精度下降。 diff --git a/PaddleCV/yolov3/train.py b/PaddleCV/yolov3/train.py index 2ea61825..97d23d38 100644 --- a/PaddleCV/yolov3/train.py +++ b/PaddleCV/yolov3/train.py @@ -82,7 +82,7 @@ def train(): build_strategy= fluid.BuildStrategy() build_strategy.memory_optimize = True - build_strategy.sync_batch_norm = True + build_strategy.sync_batch_norm = cfg.syncbn compile_program = fluid.compiler.CompiledProgram( fluid.default_main_program()).with_data_parallel( loss_name=loss.name, build_strategy=build_strategy) diff --git a/PaddleCV/yolov3/utility.py b/PaddleCV/yolov3/utility.py index e43ac033..3f5c3c6e 100644 --- a/PaddleCV/yolov3/utility.py +++ b/PaddleCV/yolov3/utility.py @@ -112,6 +112,7 @@ def parse_args(): add_arg('no_mixup_iter', int, 40000, "Disable mixup in last N iter.") # TRAIN TEST INFER add_arg('input_size', int, 608, "Image input size of YOLOv3.") + add_arg('syncbn', bool, True, "Whether to use synchronized batch normalization.") add_arg('random_shape', bool, True, "Resize to random shape for train reader.") add_arg('valid_thresh', float, 0.005, "Valid confidence score for NMS.") add_arg('nms_thresh', float, 0.45, "NMS threshold.") -- GitLab