From 85a82d9b15a5df73c5a638e62c6835072844c75f Mon Sep 17 00:00:00 2001 From: wangguanzhong Date: Fri, 23 Apr 2021 19:41:48 +0800 Subject: [PATCH] fix voc eval on release/2.0 (#2732) --- configs/ppyolo/ppyolo_r50vd_dcn_voc.yml | 4 ++++ configs/ssd/ssd_mobilenet_v1_300_120e_voc.yml | 4 ++++ configs/ssd/ssd_vgg16_300_240e_voc.yml | 4 ++++ configs/yolov3/yolov3_darknet53_270e_voc.yml | 4 ++++ configs/yolov3/yolov3_mobilenet_v1_270e_voc.yml | 4 ++++ configs/yolov3/yolov3_mobilenet_v1_ssld_270e_voc.yml | 4 ++++ configs/yolov3/yolov3_mobilenet_v3_large_270e_voc.yml | 4 ++++ .../yolov3/yolov3_mobilenet_v3_large_ssld_270e_voc.yml | 4 ++++ ppdet/data/transform/batch_operators.py | 9 +++++++-- 9 files changed, 39 insertions(+), 2 deletions(-) diff --git a/configs/ppyolo/ppyolo_r50vd_dcn_voc.yml b/configs/ppyolo/ppyolo_r50vd_dcn_voc.yml index b383deab0..3a0a4aa92 100644 --- a/configs/ppyolo/ppyolo_r50vd_dcn_voc.yml +++ b/configs/ppyolo/ppyolo_r50vd_dcn_voc.yml @@ -21,6 +21,10 @@ TrainReader: mixup_epoch: 350 batch_size: 12 +EvalReader: + batch_transforms: + - PadBatch: {pad_gt: True} + epoch: 583 LearningRate: diff --git a/configs/ssd/ssd_mobilenet_v1_300_120e_voc.yml b/configs/ssd/ssd_mobilenet_v1_300_120e_voc.yml index 45de7733a..3453f0276 100644 --- a/configs/ssd/ssd_mobilenet_v1_300_120e_voc.yml +++ b/configs/ssd/ssd_mobilenet_v1_300_120e_voc.yml @@ -6,3 +6,7 @@ _BASE_: [ '_base_/ssd_mobilenet_reader.yml', ] weights: output/ssd_mobilenet_v1_300_120e_voc/model_final + +EvalReader: + batch_transforms: + - PadBatch: {pad_gt: True} diff --git a/configs/ssd/ssd_vgg16_300_240e_voc.yml b/configs/ssd/ssd_vgg16_300_240e_voc.yml index 58cf4b985..e2e2d307c 100644 --- a/configs/ssd/ssd_vgg16_300_240e_voc.yml +++ b/configs/ssd/ssd_vgg16_300_240e_voc.yml @@ -6,3 +6,7 @@ _BASE_: [ '_base_/ssd_reader.yml', ] weights: output/ssd_vgg16_300_240e_voc/model_final + +EvalReader: + batch_transforms: + - PadBatch: {pad_gt: True} diff --git a/configs/yolov3/yolov3_darknet53_270e_voc.yml b/configs/yolov3/yolov3_darknet53_270e_voc.yml index bb7a315ef..e24c01e31 100644 --- a/configs/yolov3/yolov3_darknet53_270e_voc.yml +++ b/configs/yolov3/yolov3_darknet53_270e_voc.yml @@ -8,3 +8,7 @@ _BASE_: [ snapshot_epoch: 5 weights: output/yolov3_darknet53_270e_voc/model_final + +EvalReader: + batch_transforms: + - PadBatch: {pad_gt: True} diff --git a/configs/yolov3/yolov3_mobilenet_v1_270e_voc.yml b/configs/yolov3/yolov3_mobilenet_v1_270e_voc.yml index a6b2303f9..9952e7ea4 100644 --- a/configs/yolov3/yolov3_mobilenet_v1_270e_voc.yml +++ b/configs/yolov3/yolov3_mobilenet_v1_270e_voc.yml @@ -40,6 +40,10 @@ TrainReader: drop_last: true mixup_epoch: 250 +EvalReader: + batch_transforms: + - PadBatch: {pad_gt: True} + LearningRate: base_lr: 0.001 schedulers: diff --git a/configs/yolov3/yolov3_mobilenet_v1_ssld_270e_voc.yml b/configs/yolov3/yolov3_mobilenet_v1_ssld_270e_voc.yml index 37cce342a..c5355941f 100644 --- a/configs/yolov3/yolov3_mobilenet_v1_ssld_270e_voc.yml +++ b/configs/yolov3/yolov3_mobilenet_v1_ssld_270e_voc.yml @@ -41,6 +41,10 @@ TrainReader: drop_last: true mixup_epoch: 250 +EvalReader: + batch_transforms: + - PadBatch: {pad_gt: True} + LearningRate: base_lr: 0.001 schedulers: diff --git a/configs/yolov3/yolov3_mobilenet_v3_large_270e_voc.yml b/configs/yolov3/yolov3_mobilenet_v3_large_270e_voc.yml index 5725accb7..8c2facec7 100644 --- a/configs/yolov3/yolov3_mobilenet_v3_large_270e_voc.yml +++ b/configs/yolov3/yolov3_mobilenet_v3_large_270e_voc.yml @@ -40,6 +40,10 @@ TrainReader: drop_last: true mixup_epoch: 250 +EvalReader: + batch_transforms: + - PadBatch: {pad_gt: True} + LearningRate: base_lr: 0.001 schedulers: diff --git a/configs/yolov3/yolov3_mobilenet_v3_large_ssld_270e_voc.yml b/configs/yolov3/yolov3_mobilenet_v3_large_ssld_270e_voc.yml index 3099703b8..13d81f45e 100644 --- a/configs/yolov3/yolov3_mobilenet_v3_large_ssld_270e_voc.yml +++ b/configs/yolov3/yolov3_mobilenet_v3_large_ssld_270e_voc.yml @@ -41,6 +41,10 @@ TrainReader: drop_last: true mixup_epoch: 250 +EvalReader: + batch_transforms: + - PadBatch: {pad_gt: True} + LearningRate: base_lr: 0.001 schedulers: diff --git a/ppdet/data/transform/batch_operators.py b/ppdet/data/transform/batch_operators.py index 85639c31d..3ae84774c 100644 --- a/ppdet/data/transform/batch_operators.py +++ b/ppdet/data/transform/batch_operators.py @@ -115,6 +115,7 @@ class PadBatch(BaseOperator): gt_box_data = -np.ones([gt_num_max, 4], dtype=np.float32) gt_class_data = -np.ones([gt_num_max], dtype=np.int32) is_crowd_data = np.ones([gt_num_max], dtype=np.int32) + difficult_data = np.ones([gt_num_max], dtype=np.int32) if pad_mask: poly_num_max = max(poly_num) @@ -127,7 +128,12 @@ class PadBatch(BaseOperator): gt_num = data['gt_bbox'].shape[0] gt_box_data[0:gt_num, :] = data['gt_bbox'] gt_class_data[0:gt_num] = np.squeeze(data['gt_class']) - is_crowd_data[0:gt_num] = np.squeeze(data['is_crowd']) + if 'is_crowd' in data: + is_crowd_data[0:gt_num] = np.squeeze(data['is_crowd']) + data['is_crowd'] = is_crowd_data + if 'difficult' in data: + difficult_data[0:gt_num] = np.squeeze(data['difficult']) + data['difficult'] = difficult_data if pad_mask: for j, poly in enumerate(data['gt_poly']): for k, p_p in enumerate(poly): @@ -136,7 +142,6 @@ class PadBatch(BaseOperator): data['gt_poly'] = gt_masks_data data['gt_bbox'] = gt_box_data data['gt_class'] = gt_class_data - data['is_crowd'] = is_crowd_data return samples -- GitLab