From a3bf27da01aad0e0397a3db083eb5a1cf66a7c11 Mon Sep 17 00:00:00 2001 From: CodesFarmer Date: Mon, 18 May 2020 16:37:22 +0800 Subject: [PATCH] keep the option 'num_classes' and 'with_background' consistent (#727) --- configs/anchor_free/fcos_dcn_r50_fpn_1x.yml | 12 ++++++------ configs/anchor_free/fcos_r50_fpn_1x.yml | 10 +++++----- configs/anchor_free/fcos_r50_fpn_multiscale_2x.yml | 10 +++++----- ppdet/data/transform/batch_operators.py | 2 +- ppdet/modeling/anchor_heads/fcos_head.py | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/configs/anchor_free/fcos_dcn_r50_fpn_1x.yml b/configs/anchor_free/fcos_dcn_r50_fpn_1x.yml index 7a4d770cd..1cbedb53e 100644 --- a/configs/anchor_free/fcos_dcn_r50_fpn_1x.yml +++ b/configs/anchor_free/fcos_dcn_r50_fpn_1x.yml @@ -8,7 +8,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/fcos_dcn_r50_fpn_1x/model_final -num_classes: 81 +num_classes: 80 FCOS: backbone: ResNet @@ -32,7 +32,7 @@ FPN: has_extra_convs: true FCOSHead: - num_classes: 81 + num_classes: 80 fpn_stride: [8, 16, 32, 64, 128] num_convs: 4 norm_type: "gn" @@ -81,7 +81,7 @@ TrainReader: image_dir: train2017 anno_path: annotations/instances_train2017.json dataset_dir: dataset/coco - with_background: true + with_background: false sample_transforms: - !DecodeImage to_rgb: true @@ -111,7 +111,7 @@ TrainReader: norm_reg_targets: True batch_size: 2 shuffle: true - worker_num: 16 + worker_num: 4 use_process: false EvalReader: @@ -144,9 +144,9 @@ EvalReader: - !PadBatch pad_to_stride: 128 use_padded_im_info: true - batch_size: 8 + batch_size: 1 shuffle: false - worker_num: 2 + worker_num: 1 use_process: false TestReader: diff --git a/configs/anchor_free/fcos_r50_fpn_1x.yml b/configs/anchor_free/fcos_r50_fpn_1x.yml index 5ce9b7ce7..9729ced12 100644 --- a/configs/anchor_free/fcos_r50_fpn_1x.yml +++ b/configs/anchor_free/fcos_r50_fpn_1x.yml @@ -8,7 +8,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/fcos_r50_fpn_1x/model_final -num_classes: 81 +num_classes: 80 FCOS: backbone: ResNet @@ -31,7 +31,7 @@ FPN: has_extra_convs: true FCOSHead: - num_classes: 81 + num_classes: 80 fpn_stride: [8, 16, 32, 64, 128] num_convs: 4 norm_type: "gn" @@ -80,7 +80,7 @@ TrainReader: image_dir: train2017 anno_path: annotations/instances_train2017.json dataset_dir: dataset/coco - with_background: true + with_background: false sample_transforms: - !DecodeImage to_rgb: true @@ -110,7 +110,7 @@ TrainReader: norm_reg_targets: True batch_size: 2 shuffle: true - worker_num: 16 + worker_num: 4 use_process: false EvalReader: @@ -143,7 +143,7 @@ EvalReader: - !PadBatch pad_to_stride: 128 use_padded_im_info: true - batch_size: 8 + batch_size: 1 shuffle: false worker_num: 2 use_process: false diff --git a/configs/anchor_free/fcos_r50_fpn_multiscale_2x.yml b/configs/anchor_free/fcos_r50_fpn_multiscale_2x.yml index f9369e313..5b215da19 100644 --- a/configs/anchor_free/fcos_r50_fpn_multiscale_2x.yml +++ b/configs/anchor_free/fcos_r50_fpn_multiscale_2x.yml @@ -8,7 +8,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/fcos_r50_fpn_multiscale_2x/model_final -num_classes: 81 +num_classes: 80 FCOS: backbone: ResNet @@ -31,7 +31,7 @@ FPN: has_extra_convs: true FCOSHead: - num_classes: 81 + num_classes: 80 fpn_stride: [8, 16, 32, 64, 128] num_convs: 4 norm_type: "gn" @@ -80,7 +80,7 @@ TrainReader: image_dir: train2017 anno_path: annotations/instances_train2017.json dataset_dir: dataset/coco - with_background: true + with_background: false sample_transforms: - !DecodeImage to_rgb: true @@ -110,7 +110,7 @@ TrainReader: norm_reg_targets: True batch_size: 2 shuffle: true - worker_num: 16 + worker_num: 4 use_process: false EvalReader: @@ -143,7 +143,7 @@ EvalReader: - !PadBatch pad_to_stride: 128 use_padded_im_info: true - batch_size: 8 + batch_size: 1 shuffle: false worker_num: 2 use_process: false diff --git a/ppdet/data/transform/batch_operators.py b/ppdet/data/transform/batch_operators.py index 5510465ac..8da0b1e35 100644 --- a/ppdet/data/transform/batch_operators.py +++ b/ppdet/data/transform/batch_operators.py @@ -439,7 +439,7 @@ class Gt2FCOSTarget(BaseOperator): points2gtarea[is_match_current_level == 0] = self.INF points2min_area = points2gtarea.min(axis=1) points2min_area_ind = points2gtarea.argmin(axis=1) - labels = gt_class[points2min_area_ind] + labels = gt_class[points2min_area_ind] + 1 labels[points2min_area == self.INF] = 0 reg_targets = reg_targets[range(xs.shape[0]), points2min_area_ind] ctn_targets = np.sqrt((reg_targets[:, [0, 2]].min(axis=1) / \ diff --git a/ppdet/modeling/anchor_heads/fcos_head.py b/ppdet/modeling/anchor_heads/fcos_head.py index 9b5c4b3c0..a08e02976 100644 --- a/ppdet/modeling/anchor_heads/fcos_head.py +++ b/ppdet/modeling/anchor_heads/fcos_head.py @@ -50,7 +50,7 @@ class FCOSHead(object): __shared__ = ['num_classes'] def __init__(self, - num_classes=81, + num_classes=80, fpn_stride=[8, 16, 32, 64, 128], prior_prob=0.01, num_convs=4, @@ -65,7 +65,7 @@ class FCOSHead(object): keep_top_k=100, nms_threshold=0.45, background_label=-1).__dict__): - self.num_classes = num_classes - 1 + self.num_classes = num_classes self.fpn_stride = fpn_stride[::-1] self.prior_prob = prior_prob self.num_convs = num_convs -- GitLab