diff --git a/PaddleCV/object_detection/configs/faster_rcnn_r50_fpn_1x.yml b/PaddleCV/object_detection/configs/faster_rcnn_r50_fpn_1x.yml index cc0dea95e8bf657cb4970b337557ee5f2147e94b..594bd0d63a4628d00bfa0ab811e0b2ab809f32ae 100644 --- a/PaddleCV/object_detection/configs/faster_rcnn_r50_fpn_1x.yml +++ b/PaddleCV/object_detection/configs/faster_rcnn_r50_fpn_1x.yml @@ -21,7 +21,7 @@ FasterRCNN: ResNet: norm_type: affine_channel - norm_decay: true + norm_decay: 0. depth: 50 feature_maps: [2, 3, 4, 5] freeze_at: 2 diff --git a/PaddleCV/object_detection/configs/faster_rcnn_r50_fpn_2x.yml b/PaddleCV/object_detection/configs/faster_rcnn_r50_fpn_2x.yml index e4ba3ce1d7b308cc0b19b3b1fd06c9999cbe8d4b..895442e0501a0ef421b87ff70b9c46dd179e82bb 100644 --- a/PaddleCV/object_detection/configs/faster_rcnn_r50_fpn_2x.yml +++ b/PaddleCV/object_detection/configs/faster_rcnn_r50_fpn_2x.yml @@ -21,7 +21,7 @@ FasterRCNN: ResNet: norm_type: affine_channel - norm_decay: true + norm_decay: 0. depth: 50 feature_maps: [2, 3, 4, 5] freeze_at: 2 diff --git a/PaddleCV/object_detection/configs/mask_rcnn_r50_2x.yml b/PaddleCV/object_detection/configs/mask_rcnn_r50_2x.yml index 1c67e59a209709c9bee74b54eaa7d16b300a127f..fb08e1740e6c0661203dede973e33a9dbb4e6efa 100644 --- a/PaddleCV/object_detection/configs/mask_rcnn_r50_2x.yml +++ b/PaddleCV/object_detection/configs/mask_rcnn_r50_2x.yml @@ -23,7 +23,7 @@ MaskRCNN: ResNet: norm_type: affine_channel - norm_decay: true + norm_decay: 0. depth: 50 feature_maps: 4 freeze_at: 2 diff --git a/PaddleCV/object_detection/ppdet/modeling/architectures/mask_rcnn.py b/PaddleCV/object_detection/ppdet/modeling/architectures/mask_rcnn.py index 15ef6c7f842c8051cc5357a27a220cedbbdf375d..116e0eaad1acf61002a98dea79e57cd2124feabb 100644 --- a/PaddleCV/object_detection/ppdet/modeling/architectures/mask_rcnn.py +++ b/PaddleCV/object_detection/ppdet/modeling/architectures/mask_rcnn.py @@ -64,13 +64,16 @@ class MaskRCNN(object): def build(self, feed_vars, mode='train'): im = feed_vars['image'] - assert mode in ['train', 'test'], "only support 'train' and 'test' mode" + assert mode in ['train', 'test'], \ + "only 'train' and 'test' mode is supported" if mode == 'train': - required_fields = ['gt_label', 'gt_box', 'gt_mask', 'is_crowd', 'im_info'] + required_fields = ['gt_label', 'gt_box', 'gt_mask', + 'is_crowd', 'im_info'] else: required_fields = ['im_shape', 'im_info'] for var in required_fields: - assert var in feed_vars, "{} has no {} field".format(feed_vars, var) + assert var in feed_vars, \ + "{} has no {} field".format(feed_vars, var) im_info = feed_vars['im_info'] body_feats = self.backbone(im) @@ -144,7 +147,8 @@ class MaskRCNN(object): with switch.case(cond): fluid.layers.assign(input=bbox_pred, output=mask_pred) with switch.default(): - bbox = fluid.layers.slice(bbox_pred, [1], starts=[2], ends=[6]) + bbox = fluid.layers.slice(bbox_pred, [1], + starts=[2], ends=[6]) im_scale = fluid.layers.slice( im_info, [1], starts=[2], ends=[3]) @@ -155,8 +159,8 @@ class MaskRCNN(object): mask_feat = self.roi_extractor(last_feat, mask_rois) mask_feat = self.bbox_head.get_head_feat(mask_feat) else: - mask_feat = self.roi_extractor(body_feats, mask_rois, - spatial_scale, is_mask=True) + mask_feat = self.roi_extractor( + body_feats, mask_rois, spatial_scale, is_mask=True) mask_out = self.mask_head.get_prediction(mask_feat, bbox) fluid.layers.assign(input=mask_out, output=mask_pred) diff --git a/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py b/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py index 7d879ba7521370fa3ae2eda759da1efe850b713d..3d36bfa21c85de848a86009671945a12cca20c38 100644 --- a/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py +++ b/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py @@ -39,11 +39,11 @@ class ResNet(object): Args: depth (int): ResNet depth, should be 18, 34, 50, 101, 152. freeze_at (int): freeze the backbone at which stage - norm_type (str): normalization type, 'bn', 'sync_bn' or 'affine_channel' + norm_type (str): normalization type, 'bn'/'sync_bn'/'affine_channel' freeze_norm (bool): freeze normalization layers norm_decay (float): weight decay for normalization layer weights variant (str): ResNet variant, supports 'a', 'b', 'c', 'd' currently - feature_maps (list): index of the stages whose feature maps are returned + feature_maps (list): index of stages whose feature maps are returned """ def __init__(self, @@ -330,6 +330,7 @@ class ResNetC5(ResNet): norm_decay=0., variant='b', feature_maps=[5]): - super(ResNetC5, self).__init__(depth, freeze_at, norm_type, freeze_norm, - norm_decay, variant, feature_maps) + super(ResNetC5, self).__init__( + depth, freeze_at, norm_type, freeze_norm, norm_decay, + variant, feature_maps) self.severed_head = True