| 17 | """ |
| 18 | |
| 19 | def __init__(self, |
| 20 | inplanes, |
| 21 | planes, |
| 22 | groups=1, |
| 23 | base_width=4, |
| 24 | base_channels=64, |
| 25 | **kwargs): |
| 26 | super(Bottleneck, self).__init__(inplanes, planes, **kwargs) |
| 27 | |
| 28 | if groups == 1: |
| 29 | width = self.planes |
| 30 | else: |
| 31 | width = math.floor(self.planes * |
| 32 | (base_width / base_channels)) * groups |
| 33 | |
| 34 | self.norm1_name, norm1 = build_norm_layer( |
| 35 | self.norm_cfg, width, postfix=1) |
| 36 | self.norm2_name, norm2 = build_norm_layer( |
| 37 | self.norm_cfg, width, postfix=2) |
| 38 | self.norm3_name, norm3 = build_norm_layer( |
| 39 | self.norm_cfg, self.planes * self.expansion, postfix=3) |
| 40 | |
| 41 | self.conv1 = build_conv_layer( |
| 42 | self.conv_cfg, |
| 43 | self.inplanes, |
| 44 | width, |
| 45 | kernel_size=1, |
| 46 | stride=self.conv1_stride, |
| 47 | bias=False) |
| 48 | self.add_module(self.norm1_name, norm1) |
| 49 | fallback_on_stride = False |
| 50 | self.with_modulated_dcn = False |
| 51 | if self.with_dcn: |
| 52 | fallback_on_stride = self.dcn.pop('fallback_on_stride', False) |
| 53 | if not self.with_dcn or fallback_on_stride: |
| 54 | self.conv2 = build_conv_layer( |
| 55 | self.conv_cfg, |
| 56 | width, |
| 57 | width, |
| 58 | kernel_size=3, |
| 59 | stride=self.conv2_stride, |
| 60 | padding=self.dilation, |
| 61 | dilation=self.dilation, |
| 62 | groups=groups, |
| 63 | bias=False) |
| 64 | else: |
| 65 | assert self.conv_cfg is None, 'conv_cfg must be None for DCN' |
| 66 | self.conv2 = build_conv_layer( |
| 67 | self.dcn, |
| 68 | width, |
| 69 | width, |
| 70 | kernel_size=3, |
| 71 | stride=self.conv2_stride, |
| 72 | padding=self.dilation, |
| 73 | dilation=self.dilation, |
| 74 | groups=groups, |
| 75 | bias=False) |
| 76 | |