diff --git a/example/auto_compression/detection/README.md b/example/auto_compression/detection/README.md index 40973d36936d16198fa6c12930bdf3a99aa85784..ebca44870a38987e64b51adabe46c9ab1fccd75a 100644 --- a/example/auto_compression/detection/README.md +++ b/example/auto_compression/detection/README.md @@ -23,6 +23,7 @@ | :-------- |:-------- |:--------: | :---------------------: | :----------------: | :----------------: | :---------------: | :----------------------: | :---------------------: | | PP-YOLOE-l | 50.9 | - | 50.6 | 11.2ms | 7.7ms | **6.7ms** | [config](https://github.com/PaddlePaddle/PaddleSlim/blob/develop/example/auto_compression/detection/configs/ppyoloe_l_qat_dis.yaml) | [Model](https://bj.bcebos.com/v1/paddle-slim-models/act/ppyoloe_crn_l_300e_coco_quant.tar) | | PP-YOLOE-s | 43.1 | 41.2 | 42.6 | 6.51ms | 2.77ms | **2.12ms** | [config](https://github.com/PaddlePaddle/PaddleSlim/blob/develop/example/auto_compression/detection/configs/ppyoloe_s_qat_dis.yaml) | [Model](https://bj.bcebos.com/v1/paddle-slim-models/act/ppyoloe_s_quant.tar) | +| PP-YOLOE+ s | 43.7 | - | 42.7 | - | - | - | [config](https://github.com/PaddlePaddle/PaddleSlim/blob/develop/example/auto_compression/detection/configs/ppyoloe_plus_s_qat_dis.yaml) | [Model](https://bj.bcebos.com/v1/paddle-slim-models/act/ppyoloe_plus_crn_s_80e_coco_no_nms_quant.tar) | - mAP的指标均在COCO val2017数据集中评测得到,IoU=0.5:0.95。 - PP-YOLOE-l模型在Tesla V100的GPU环境下测试,并且开启TensorRT,batch_size=1,包含NMS,测试脚本是[benchmark demo](https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.4/deploy/python)。 diff --git a/example/auto_compression/detection/configs/ppyoloe_l_qat_dis.yaml b/example/auto_compression/detection/configs/ppyoloe_l_qat_dis.yaml index d1c28b0603d94314e3a8525ec0085e6d6d61e5b5..7102142ed0c35029872abaff97965ba31bb5cd71 100644 --- a/example/auto_compression/detection/configs/ppyoloe_l_qat_dis.yaml +++ b/example/auto_compression/detection/configs/ppyoloe_l_qat_dis.yaml @@ -1,7 +1,8 @@ Global: reader_config: configs/yolo_reader.yml - arch: YOLO + arch: PPYOLOE + include_nms: True Evaluation: True model_dir: ./ppyoloe_crn_l_300e_coco model_filename: model.pdmodel diff --git a/example/auto_compression/detection/configs/ppyoloe_plus_reader.yml b/example/auto_compression/detection/configs/ppyoloe_plus_reader.yml new file mode 100644 index 0000000000000000000000000000000000000000..5f3795f29be025e6836a7c88b51dd79ecb04a9f4 --- /dev/null +++ b/example/auto_compression/detection/configs/ppyoloe_plus_reader.yml @@ -0,0 +1,26 @@ +metric: COCO +num_classes: 80 + +# Datset configuration +TrainDataset: + !COCODataSet + image_dir: train2017 + anno_path: annotations/instances_train2017.json + dataset_dir: dataset/coco/ + +EvalDataset: + !COCODataSet + image_dir: val2017 + anno_path: annotations/instances_val2017.json + dataset_dir: dataset/coco/ + +worker_num: 0 + +# preprocess reader in test +EvalReader: + sample_transforms: + - Decode: {} + - Resize: {target_size: [640, 640], keep_ratio: False, interp: 2} + - NormalizeImage: {mean: [0., 0., 0.], std: [1., 1., 1.], norm_type: none} + - Permute: {} + batch_size: 4 diff --git a/example/auto_compression/detection/configs/ppyoloe_plus_s_qat_dis.yaml b/example/auto_compression/detection/configs/ppyoloe_plus_s_qat_dis.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9525f4a14e6dd1ec33a3f41595a875758ef06cf4 --- /dev/null +++ b/example/auto_compression/detection/configs/ppyoloe_plus_s_qat_dis.yaml @@ -0,0 +1,34 @@ + +Global: + reader_config: configs/ppyoloe_plus_reader.yml + arch: PPYOLOE + include_nms: False + Evaluation: True + model_dir: ./ppyoloe_plus_crn_s_80e_coco_no_nms # https://bj.bcebos.com/v1/paddle-slim-models/act/ppyoloe_plus_crn_s_80e_coco_no_nms.tar + model_filename: model.pdmodel + params_filename: model.pdiparams + +Distillation: + alpha: 1.0 + loss: soft_label + +QuantAware: + onnx_format: true + use_pact: true + activation_quantize_type: 'moving_average_abs_max' + quantize_op_types: + - conv2d + - depthwise_conv2d + +TrainConfig: + train_iter: 5000 + eval_iter: 1000 + learning_rate: + type: CosineAnnealingDecay + learning_rate: 0.00003 + T_max: 6000 + optimizer_builder: + optimizer: + type: SGD + weight_decay: 4.0e-05 + diff --git a/example/auto_compression/detection/configs/ppyoloe_s_qat_dis.yaml b/example/auto_compression/detection/configs/ppyoloe_s_qat_dis.yaml index 2090babab8e6df10a03243e9c6df2a0f1eed65ed..3f6ade72b3f1ffb708a6f0843df1c3d859e1d782 100644 --- a/example/auto_compression/detection/configs/ppyoloe_s_qat_dis.yaml +++ b/example/auto_compression/detection/configs/ppyoloe_s_qat_dis.yaml @@ -1,7 +1,8 @@ Global: reader_config: configs/yolo_reader.yml - arch: PPYOLOE # When export exclude_nms=True, need set arch: PPYOLOE + arch: PPYOLOE + include_nms: False Evaluation: True model_dir: ./ppyoloe_crn_s_300e_coco model_filename: model.pdmodel diff --git a/example/auto_compression/detection/eval.py b/example/auto_compression/detection/eval.py index 3dc0d4033736a535a366306d418f6eb18c723f07..0f80b124c91fd6df395161a8970cfb45c0df0602 100644 --- a/example/auto_compression/detection/eval.py +++ b/example/auto_compression/detection/eval.py @@ -85,9 +85,13 @@ def eval(): if 'arch' in global_config and global_config['arch'] == 'keypoint': res = keypoint_post_process(data, data_input, exe, val_program, fetch_targets, outs) - if 'arch' in global_config and global_config['arch'] == 'PPYOLOE': - postprocess = PPYOLOEPostProcess( - score_threshold=0.01, nms_threshold=0.6) + elif 'include_nms' in global_config and not global_config[ + 'include_nms']: + if 'arch' in global_config and global_config['arch'] == 'PPYOLOE': + postprocess = PPYOLOEPostProcess( + score_threshold=0.01, nms_threshold=0.6) + else: + assert "Not support arch={} now.".format(global_config['arch']) res = postprocess(np.array(outs[0]), data_all['scale_factor']) else: for out in outs: diff --git a/example/auto_compression/detection/run.py b/example/auto_compression/detection/run.py index 0dc94130e86ac5dcaf030f76a4ab097e0b725754..90c90c5f5fb94d043c1f32b1be7e8829ccab0086 100644 --- a/example/auto_compression/detection/run.py +++ b/example/auto_compression/detection/run.py @@ -100,9 +100,13 @@ def eval_function(exe, compiled_test_program, test_feed_names, test_fetch_list): res = keypoint_post_process(data, data_input, exe, compiled_test_program, test_fetch_list, outs) - if 'arch' in global_config and global_config['arch'] == 'PPYOLOE': - postprocess = PPYOLOEPostProcess( - score_threshold=0.01, nms_threshold=0.6) + elif 'include_nms' in global_config and not global_config[ + 'include_nms']: + if 'arch' in global_config and global_config['arch'] == 'PPYOLOE': + postprocess = PPYOLOEPostProcess( + score_threshold=0.01, nms_threshold=0.6) + else: + assert "Not support arch={} now.".format(global_config['arch']) res = postprocess(np.array(outs[0]), data_all['scale_factor']) else: for out in outs: