From 19f551fdc467ccf3114414435061dc4a83ad97c2 Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Tue, 24 Nov 2020 10:20:23 +0800 Subject: [PATCH] fix smoe model paddle version check (#1748) --- ppdet/modeling/anchor_heads/solov2_head.py | 3 --- ppdet/modeling/anchor_heads/ttf_head.py | 6 +++++- ppdet/modeling/architectures/cascade_mask_rcnn.py | 2 ++ ppdet/modeling/architectures/cascade_rcnn.py | 2 ++ ppdet/modeling/architectures/cascade_rcnn_cls_aware.py | 2 ++ ppdet/modeling/architectures/htc.py | 2 ++ ppdet/modeling/architectures/solov2.py | 2 ++ 7 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ppdet/modeling/anchor_heads/solov2_head.py b/ppdet/modeling/anchor_heads/solov2_head.py index 18546593a..21cdad729 100644 --- a/ppdet/modeling/anchor_heads/solov2_head.py +++ b/ppdet/modeling/anchor_heads/solov2_head.py @@ -24,8 +24,6 @@ from paddle.fluid.regularizer import L2Decay from ppdet.modeling.ops import ConvNorm, DeformConvNorm, MaskMatrixNMS, DropBlock from ppdet.core.workspace import register -from ppdet.utils.check import check_version - from six.moves import zip import numpy as np @@ -71,7 +69,6 @@ class SOLOv2Head(object): kernel='gaussian', sigma=2.0).__dict__, drop_block=False): - check_version('2.0.0-rc0') self.num_classes = num_classes self.seg_num_grids = num_grids self.cate_out_channels = self.num_classes - 1 diff --git a/ppdet/modeling/anchor_heads/ttf_head.py b/ppdet/modeling/anchor_heads/ttf_head.py index 8640b3f48..ba9ec802e 100644 --- a/ppdet/modeling/anchor_heads/ttf_head.py +++ b/ppdet/modeling/anchor_heads/ttf_head.py @@ -348,7 +348,11 @@ class TTFHead(object): return pred, target, weight def get_loss(self, pred_hm, pred_wh, target_hm, box_target, target_weight): - pred_hm = paddle.clip(fluid.layers.sigmoid(pred_hm), 1e-4, 1 - 1e-4) + try: + pred_hm = paddle.clip(fluid.layers.sigmoid(pred_hm), 1e-4, 1 - 1e-4) + except: + pred_hm = paddle.tensor.clamp( + fluid.layers.sigmoid(pred_hm), 1e-4, 1 - 1e-4) hm_loss = self.ct_focal_loss(pred_hm, target_hm) * self.hm_weight shape = fluid.layers.shape(target_hm) shape.stop_gradient = True diff --git a/ppdet/modeling/architectures/cascade_mask_rcnn.py b/ppdet/modeling/architectures/cascade_mask_rcnn.py index 0e2b23556..0fc5bb135 100644 --- a/ppdet/modeling/architectures/cascade_mask_rcnn.py +++ b/ppdet/modeling/architectures/cascade_mask_rcnn.py @@ -23,6 +23,7 @@ import paddle.fluid as fluid from ppdet.experimental import mixed_precision_global_state from ppdet.core.workspace import register +from ppdet.utils.check import check_version from .input_helper import multiscale_def @@ -62,6 +63,7 @@ class CascadeMaskRCNN(object): rpn_only=False, fpn='FPN'): super(CascadeMaskRCNN, self).__init__() + check_version('2.0.0-rc0') assert fpn is not None, "cascade RCNN requires FPN" self.backbone = backbone self.fpn = fpn diff --git a/ppdet/modeling/architectures/cascade_rcnn.py b/ppdet/modeling/architectures/cascade_rcnn.py index ee72eca40..e018caeae 100644 --- a/ppdet/modeling/architectures/cascade_rcnn.py +++ b/ppdet/modeling/architectures/cascade_rcnn.py @@ -23,6 +23,7 @@ import paddle.fluid as fluid from ppdet.experimental import mixed_precision_global_state from ppdet.core.workspace import register +from ppdet.utils.check import check_version from .input_helper import multiscale_def __all__ = ['CascadeRCNN'] @@ -57,6 +58,7 @@ class CascadeRCNN(object): rpn_only=False, fpn='FPN'): super(CascadeRCNN, self).__init__() + check_version('2.0.0-rc0') assert fpn is not None, "cascade RCNN requires FPN" self.backbone = backbone self.fpn = fpn diff --git a/ppdet/modeling/architectures/cascade_rcnn_cls_aware.py b/ppdet/modeling/architectures/cascade_rcnn_cls_aware.py index 5eeb1bffb..837d87e97 100644 --- a/ppdet/modeling/architectures/cascade_rcnn_cls_aware.py +++ b/ppdet/modeling/architectures/cascade_rcnn_cls_aware.py @@ -24,6 +24,7 @@ import copy import paddle.fluid as fluid from ppdet.core.workspace import register +from ppdet.utils.check import check_version from .input_helper import multiscale_def __all__ = ['CascadeRCNNClsAware'] @@ -60,6 +61,7 @@ class CascadeRCNNClsAware(object): bbox_assigner='CascadeBBoxAssigner', fpn='FPN', ): super(CascadeRCNNClsAware, self).__init__() + check_version('2.0.0-rc0') assert fpn is not None, "cascade RCNN requires FPN" self.backbone = backbone self.fpn = fpn diff --git a/ppdet/modeling/architectures/htc.py b/ppdet/modeling/architectures/htc.py index 16c290916..c20822f85 100644 --- a/ppdet/modeling/architectures/htc.py +++ b/ppdet/modeling/architectures/htc.py @@ -26,6 +26,7 @@ from paddle.fluid.initializer import MSRA from paddle.fluid.regularizer import L2Decay from ppdet.experimental import mixed_precision_global_state from ppdet.core.workspace import register +from ppdet.utils.check import check_version from .input_helper import multiscale_def @@ -70,6 +71,7 @@ class HybridTaskCascade(object): rpn_only=False, fpn='FPN'): super(HybridTaskCascade, self).__init__() + check_version('2.0.0-rc0') assert fpn is not None, "HTC requires FPN" self.backbone = backbone self.fpn = fpn diff --git a/ppdet/modeling/architectures/solov2.py b/ppdet/modeling/architectures/solov2.py index 9fc5ef34a..6c590e4a9 100644 --- a/ppdet/modeling/architectures/solov2.py +++ b/ppdet/modeling/architectures/solov2.py @@ -22,6 +22,7 @@ from paddle import fluid from ppdet.experimental import mixed_precision_global_state from ppdet.core.workspace import register +from ppdet.utils.check import check_version __all__ = ['SOLOv2'] @@ -47,6 +48,7 @@ class SOLOv2(object): bbox_head='SOLOv2Head', mask_head='SOLOv2MaskHead'): super(SOLOv2, self).__init__() + check_version('2.0.0-rc0') self.backbone = backbone self.fpn = fpn self.bbox_head = bbox_head -- GitLab