From 07c730935c74f56abbe211290a958595526f8b02 Mon Sep 17 00:00:00 2001 From: michaelowenliu Date: Tue, 22 Sep 2020 16:50:41 +0800 Subject: [PATCH] fix an error in F.pad --- dygraph/paddleseg/models/backbones/resnet_vd.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dygraph/paddleseg/models/backbones/resnet_vd.py b/dygraph/paddleseg/models/backbones/resnet_vd.py index b9cae17e..e4f6ec45 100644 --- a/dygraph/paddleseg/models/backbones/resnet_vd.py +++ b/dygraph/paddleseg/models/backbones/resnet_vd.py @@ -133,8 +133,9 @@ class BottleneckBlock(nn.Layer): # If given dilation rate > 1, using corresponding padding if self.dilation > 1: padding = self.dilation - y = F.pad(y, [0, 0, 0, 0, padding, padding, padding, padding]) + y = F.pad(y, [padding, padding, padding, padding]) ##################################################################### + conv1 = self.conv1(y) conv2 = self.conv2(conv1) @@ -197,11 +198,10 @@ class BasicBlock(nn.Layer): class ResNet_vd(nn.Layer): def __init__(self, - backbone_pretrained=None, layers=50, - class_dim=1000, output_stride=None, - multi_grid=(1, 1, 1)): + multi_grid=(1, 1, 1), + pretrained=None): super(ResNet_vd, self).__init__() self.layers = layers @@ -224,6 +224,10 @@ class ResNet_vd(nn.Layer): ] if layers >= 50 else [64, 64, 128, 256] num_filters = [64, 128, 256, 512] + # for channels of returned stage + self.backbone_channels = [c * 4 for c in num_filters + ] if layers >= 50 else num_filters + dilation_dict = None if output_stride == 8: dilation_dict = {2: 2, 3: 4} @@ -315,6 +319,8 @@ class ResNet_vd(nn.Layer): block_list.append(basic_block) shortcut = True self.stage_list.append(block_list) + + utils.load_pretrained_model(self, pretrained) def forward(self, inputs): y = self.conv1_1(inputs) @@ -330,6 +336,8 @@ class ResNet_vd(nn.Layer): feat_list.append(y) return feat_list + + @manager.BACKBONES.add_component -- GitLab