diff --git a/dygraph/configs/solov2/_base_/solov2_r50_fpn.yml b/dygraph/configs/solov2/_base_/solov2_r50_fpn.yml index e67a6e1b64ff9f58a33ccf5d10005cf3dbb75825..92ebe213e0f0c07ab388c59cbc803d3c17d2baf6 100644 --- a/dygraph/configs/solov2/_base_/solov2_r50_fpn.yml +++ b/dygraph/configs/solov2/_base_/solov2_r50_fpn.yml @@ -9,7 +9,6 @@ SOLOv2: mask_head: SOLOv2MaskHead ResNet: - # index 0 stands for res2 depth: 50 norm_type: bn freeze_at: 0 @@ -17,11 +16,7 @@ ResNet: num_stages: 4 FPN: - in_channels: [256, 512, 1024, 2048] out_channel: 256 - min_level: 0 - max_level: 4 - spatial_scale: [0.25, 0.125, 0.0625, 0.03125] SOLOv2Head: seg_feat_channels: 512 @@ -32,7 +27,6 @@ SOLOv2Head: mask_nms: MaskMatrixNMS SOLOv2MaskHead: - in_channels: 256 mid_channels: 128 out_channels: 256 start_level: 0 diff --git a/dygraph/ppdet/data/transform/batch_operator.py b/dygraph/ppdet/data/transform/batch_operator.py index aabd0cf5dfed9ecac51ea9b55c7d80452df76560..1e876c7545f4579547aa3e774b8d73928d6c5500 100644 --- a/dygraph/ppdet/data/transform/batch_operator.py +++ b/dygraph/ppdet/data/transform/batch_operator.py @@ -644,7 +644,7 @@ class Gt2Solov2TargetOp(BaseOperator): max_ins_num = [0] * len(self.num_grids) for sample in samples: gt_bboxes_raw = sample['gt_bbox'] - gt_labels_raw = sample['gt_class'] + gt_labels_raw = sample['gt_class'] + 1 im_c, im_h, im_w = sample['image'].shape[:] gt_masks_raw = sample['gt_segm'].astype(np.uint8) mask_feat_size = [ diff --git a/dygraph/ppdet/modeling/architectures/solov2.py b/dygraph/ppdet/modeling/architectures/solov2.py index d7a34c0d223fb9d8b8b3b85400b80b33e336730a..4e5fc211863b92ba609c958ac9206f99573ecfe4 100644 --- a/dygraph/ppdet/modeling/architectures/solov2.py +++ b/dygraph/ppdet/modeling/architectures/solov2.py @@ -18,7 +18,7 @@ from __future__ import print_function import paddle -from ppdet.core.workspace import register +from ppdet.core.workspace import register, create from .meta_arch import BaseArch __all__ = ['SOLOv2'] @@ -37,7 +37,6 @@ class SOLOv2(BaseArch): """ __category__ = 'architecture' - __inject__ = ['backbone', 'neck', 'solov2_head', 'mask_head'] def __init__(self, backbone, solov2_head, mask_head, neck=None): super(SOLOv2, self).__init__() @@ -46,11 +45,28 @@ class SOLOv2(BaseArch): self.solov2_head = solov2_head self.mask_head = mask_head + @classmethod + def from_config(cls, cfg, *args, **kwargs): + backbone = create(cfg['backbone']) + + kwargs = {'input_shape': backbone.out_shape} + neck = create(cfg['neck'], **kwargs) + + kwargs = {'input_shape': neck.out_shape} + solov2_head = create(cfg['solov2_head'], **kwargs) + mask_head = create(cfg['mask_head'], **kwargs) + + return { + 'backbone': backbone, + 'neck': neck, + 'solov2_head': solov2_head, + 'mask_head': mask_head, + } + def model_arch(self): body_feats = self.backbone(self.inputs) - if self.neck is not None: - body_feats, spatial_scale = self.neck(body_feats) + body_feats = self.neck(body_feats) self.seg_pred = self.mask_head(body_feats) diff --git a/dygraph/ppdet/modeling/heads/solov2_head.py b/dygraph/ppdet/modeling/heads/solov2_head.py index f43271a860ee7418e595f24a62140f7db03728ad..d24b0b029fc3a5a15ee4831451c918f42b2a88f6 100644 --- a/dygraph/ppdet/modeling/heads/solov2_head.py +++ b/dygraph/ppdet/modeling/heads/solov2_head.py @@ -190,7 +190,7 @@ class SOLOv2Head(nn.Layer): self.num_classes = num_classes self.in_channels = in_channels self.seg_num_grids = num_grids - self.cate_out_channels = self.num_classes - 1 + self.cate_out_channels = self.num_classes self.seg_feat_channels = seg_feat_channels self.stacked_convs = stacked_convs self.kernel_out_channels = kernel_out_channels diff --git a/dygraph/ppdet/py_op/post_process.py b/dygraph/ppdet/py_op/post_process.py index 04fabaa31001942290495e28e90b3a924b58dd7a..0c02cdba317290829422b8723de570490b098b0d 100755 --- a/dygraph/ppdet/py_op/post_process.py +++ b/dygraph/ppdet/py_op/post_process.py @@ -87,7 +87,7 @@ def get_solov2_segm_res(results, image_id, num_id_to_cat_id_map): return None # for each sample for i in range(lengths - 1): - clsid = int(clsid_labels[i]) + 1 + clsid = int(clsid_labels[i]) catid = num_id_to_cat_id_map[clsid] score = float(clsid_scores[i]) mask = segms[i]