From 5d7f09edce44223ea97cc0405d5190c55c17a110 Mon Sep 17 00:00:00 2001 From: Feng Ni Date: Fri, 22 Jan 2021 11:45:17 +0800 Subject: [PATCH] [Dygraph] Fix SSD-MobileNet (#2109) * fix ssd mbv1 config * fix trt infer --- dygraph/configs/ssd/README.md | 2 +- dygraph/configs/ssd/_base_/optimizer_120e.yml | 6 +++--- dygraph/configs/ssd/_base_/ssd_mobilenet_reader.yml | 11 ++++------- dygraph/configs/ssd/_base_/ssdlite300_reader.yml | 2 +- dygraph/configs/ssd/_base_/ssdlite320_reader.yml | 2 +- dygraph/ppdet/engine/export_utils.py | 6 +++--- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/dygraph/configs/ssd/README.md b/dygraph/configs/ssd/README.md index b62eb9dcc..442fa2c0b 100644 --- a/dygraph/configs/ssd/README.md +++ b/dygraph/configs/ssd/README.md @@ -7,7 +7,7 @@ | 骨架网络 | 网络类型 | 每张GPU图片个数 | 学习率策略 |推理时间(fps) | Box AP | 下载 | 配置文件 | | :-------------- | :------------- | :-----: | :-----: | :------------: | :-----: | :-----------------------------------------------------: | :-----: | | VGG | SSD | 8 | 240e | ---- | 78.2 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/dygraph/ssd_vgg16_300_240e_voc.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/ssd_vgg16_300_240e_voc.yml) | -| MobileNet v1 | SSD | 32 | 120e | ---- | 73.1 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/dygraph/ssd_mobilenet_v1_300_120e_voc.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/ssd_mobilenet_v1_300_120e_voc.yml) | +| MobileNet v1 | SSD | 32 | 120e | ---- | 73.3 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/dygraph/ssd_mobilenet_v1_300_120e_voc.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/ssd_mobilenet_v1_300_120e_voc.yml) | **注意:** SSD-VGG使用4GPU在总batch size为32下训练240个epoch。SSD-MobileNetv1使用2GPU在总batch size为64下训练120周期。 diff --git a/dygraph/configs/ssd/_base_/optimizer_120e.yml b/dygraph/configs/ssd/_base_/optimizer_120e.yml index 908745c6c..0625b6694 100644 --- a/dygraph/configs/ssd/_base_/optimizer_120e.yml +++ b/dygraph/configs/ssd/_base_/optimizer_120e.yml @@ -10,8 +10,8 @@ LearningRate: OptimizerBuilder: optimizer: - momentum: 0.9 - type: Momentum + momentum: 0.0 + type: RMSProp regularizer: - factor: 0.0005 + factor: 0.00005 type: L2 diff --git a/dygraph/configs/ssd/_base_/ssd_mobilenet_reader.yml b/dygraph/configs/ssd/_base_/ssd_mobilenet_reader.yml index b43d97d18..087ea7e68 100644 --- a/dygraph/configs/ssd/_base_/ssd_mobilenet_reader.yml +++ b/dygraph/configs/ssd/_base_/ssd_mobilenet_reader.yml @@ -2,21 +2,18 @@ worker_num: 8 TrainReader: inputs_def: num_max_boxes: 90 - sample_transforms: - DecodeOp: {} - RandomDistortOp: {brightness: [0.5, 1.125, 0.875], random_apply: False} - RandomExpandOp: {fill_value: [127.5, 127.5, 127.5]} - RandomCropOp: {allow_no_crop: Fasle} - RandomFlipOp: {} + - ResizeOp: {target_size: [300, 300], keep_ratio: False, interp: 1} - NormalizeBoxOp: {} - - ResizeImage: {target_size: 300, interp: 1, use_cv2: false} - PadBoxOp: {num_max_boxes: 90} - batch_transforms: - NormalizeImageOp: {mean: [127.5, 127.5, 127.5], std: [127.502231, 127.502231, 127.502231], is_scale: false} - - Permute: {to_bgr: true} - + - Permute: {} batch_size: 32 shuffle: true drop_last: true @@ -27,7 +24,7 @@ EvalReader: - DecodeOp: {} - ResizeOp: {target_size: [300, 300], keep_ratio: False, interp: 1} - NormalizeImageOp: {mean: [127.5, 127.5, 127.5], std: [127.502231, 127.502231, 127.502231], is_scale: false} - - Permute: {to_bgr: true} + - Permute: {} batch_size: 1 drop_empty: false @@ -39,5 +36,5 @@ TestReader: - DecodeOp: {} - ResizeOp: {target_size: [300, 300], keep_ratio: False, interp: 1} - NormalizeImageOp: {mean: [127.5, 127.5, 127.5], std: [127.502231, 127.502231, 127.502231], is_scale: false} - - Permute: {to_bgr: true} + - Permute: {} batch_size: 1 diff --git a/dygraph/configs/ssd/_base_/ssdlite300_reader.yml b/dygraph/configs/ssd/_base_/ssdlite300_reader.yml index bbce81b31..c4f3095b6 100644 --- a/dygraph/configs/ssd/_base_/ssdlite300_reader.yml +++ b/dygraph/configs/ssd/_base_/ssdlite300_reader.yml @@ -8,8 +8,8 @@ TrainReader: - RandomExpandOp: {fill_value: [123.675, 116.28, 103.53]} - RandomCropOp: {allow_no_crop: Fasle} - RandomFlipOp: {} + - ResizeOp: {target_size: [300, 300], keep_ratio: False, interp: 1} - NormalizeBoxOp: {} - - ResizeImage: {target_size: 300, interp: 1, use_cv2: false} - PadBoxOp: {num_max_boxes: 90} batch_transforms: - NormalizeImageOp: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: true} diff --git a/dygraph/configs/ssd/_base_/ssdlite320_reader.yml b/dygraph/configs/ssd/_base_/ssdlite320_reader.yml index dd7a0f3bf..7c206a933 100644 --- a/dygraph/configs/ssd/_base_/ssdlite320_reader.yml +++ b/dygraph/configs/ssd/_base_/ssdlite320_reader.yml @@ -8,8 +8,8 @@ TrainReader: - RandomExpandOp: {fill_value: [123.675, 116.28, 103.53]} - RandomCropOp: {allow_no_crop: Fasle} - RandomFlipOp: {} + - ResizeOp: {target_size: [320, 320], keep_ratio: False, interp: 1} - NormalizeBoxOp: {} - - ResizeImage: {target_size: 320, interp: 1, use_cv2: false} - PadBoxOp: {num_max_boxes: 90} batch_transforms: - NormalizeImageOp: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: true} diff --git a/dygraph/ppdet/engine/export_utils.py b/dygraph/ppdet/engine/export_utils.py index d724f179a..938288d72 100644 --- a/dygraph/ppdet/engine/export_utils.py +++ b/dygraph/ppdet/engine/export_utils.py @@ -28,13 +28,13 @@ logger = setup_logger(__name__) # Global dictionary TRT_MIN_SUBGRAPH = { 'YOLO': 3, - 'SSD': 3, + 'SSD': 40, 'RCNN': 40, 'RetinaNet': 40, 'EfficientDet': 40, 'Face': 3, - 'TTFNet': 3, - 'FCOS': 3, + 'TTFNet': 40, + 'FCOS': 40, 'SOLOv2': 60, } -- GitLab