From 3b8d760d3bea0769a8d3ebf4e8b231cbd60f7bb4 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Wed, 3 Jun 2020 03:55:42 +0000 Subject: [PATCH] fix upsample --- ppdet/modeling/anchor_heads/yolo_head.py | 2 +- ppdet/modeling/ops.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ppdet/modeling/anchor_heads/yolo_head.py b/ppdet/modeling/anchor_heads/yolo_head.py index 2b1b3da78..54fbb0b7e 100644 --- a/ppdet/modeling/anchor_heads/yolo_head.py +++ b/ppdet/modeling/anchor_heads/yolo_head.py @@ -183,13 +183,13 @@ class YOLOv3Head(object): return route, tip def _upsample(self, input, scale=2, upsample='nearest', name=None): - upsample = upsample.copy() if upsample == 'nearest': out = fluid.layers.resize_nearest( input=input, scale=float(scale), name=name) else: assert isinstance( upsample, dict), "Unknown upsample method: {}".format(upsample) + upsample = upsample.copy() assert upsample['type'] in [ 'carafe' ], 'Unknown upsample type {}'.format(upsample['type']) diff --git a/ppdet/modeling/ops.py b/ppdet/modeling/ops.py index 43ce45dc9..a2cd8aca0 100644 --- a/ppdet/modeling/ops.py +++ b/ppdet/modeling/ops.py @@ -75,7 +75,6 @@ def _conv_bn(input, ch_out, filter_size, stride, padding, act=None, name=None): filter_size=filter_size, stride=stride, padding=padding, - act=None, param_attr=ParamAttr(name=name + ".conv.weights"), bias_attr=False) @@ -1588,6 +1587,8 @@ class CARAFEUpsample(object): w = input_shape[3] out = fluid.layers.reshape( out, [b, int(input.shape[1]), -1, h * self.scale, w * self.scale]) + + weight = fluid.layers.expand_as(weight, out) out = fluid.layers.reduce_sum(weight * out, dim=2) return out -- GitLab