diff --git a/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py b/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py index c902b8acd2ee8d4729066add4d0ab88e3d0b25b2..7d879ba7521370fa3ae2eda759da1efe850b713d 100644 --- a/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py +++ b/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py @@ -152,8 +152,7 @@ class ResNet(object): ch_in = input.shape[1] # the naming rule is same as pretrained weight name = self.na.fix_shortcut_name(name) - - if ch_in != ch_out or stride != 1: + if ch_in != ch_out or stride != 1 or (self.depth < 50 and is_first): if max_pooling_in_short_cut and not is_first: input = fluid.layers.pool2d( input=input, @@ -252,6 +251,8 @@ class ResNet(object): conv = input for i in range(count): conv_name = self.na.fix_layer_warp_name(stage_num, count, i) + if self.depth < 50: + is_first = True if i == 0 and stage_num == 2 else False conv = block_func( input=conv, num_filters=ch_out,