Feature fusion module. Args: higher_in_channels (int): Number of input channels of the higher-resolution branch. lower_in_channels (int): Number of input channels of the lower-resolution branch. out_channels (int): Number of output channels.
| 193 | |
| 194 | |
| 195 | class FeatureFusionModule(nn.Module): |
| 196 | """Feature fusion module. |
| 197 | |
| 198 | Args: |
| 199 | higher_in_channels (int): Number of input channels of the |
| 200 | higher-resolution branch. |
| 201 | lower_in_channels (int): Number of input channels of the |
| 202 | lower-resolution branch. |
| 203 | out_channels (int): Number of output channels. |
| 204 | conv_cfg (dict | None): Config of conv layers. Default: None |
| 205 | norm_cfg (dict | None): Config of norm layers. Default: |
| 206 | dict(type='BN') |
| 207 | dwconv_act_cfg (dict): Config of activation layers in 3x3 conv. |
| 208 | Default: dict(type='ReLU'). |
| 209 | conv_act_cfg (dict): Config of activation layers in the two 1x1 conv. |
| 210 | Default: None. |
| 211 | align_corners (bool): align_corners argument of F.interpolate. |
| 212 | Default: False. |
| 213 | """ |
| 214 | |
| 215 | def __init__(self, |
| 216 | higher_in_channels, |
| 217 | lower_in_channels, |
| 218 | out_channels, |
| 219 | conv_cfg=None, |
| 220 | norm_cfg=dict(type='BN'), |
| 221 | dwconv_act_cfg=dict(type='ReLU'), |
| 222 | conv_act_cfg=None, |
| 223 | align_corners=False): |
| 224 | super(FeatureFusionModule, self).__init__() |
| 225 | self.conv_cfg = conv_cfg |
| 226 | self.norm_cfg = norm_cfg |
| 227 | self.dwconv_act_cfg = dwconv_act_cfg |
| 228 | self.conv_act_cfg = conv_act_cfg |
| 229 | self.align_corners = align_corners |
| 230 | self.dwconv = ConvModule( |
| 231 | lower_in_channels, |
| 232 | out_channels, |
| 233 | 3, |
| 234 | padding=1, |
| 235 | groups=out_channels, |
| 236 | conv_cfg=self.conv_cfg, |
| 237 | norm_cfg=self.norm_cfg, |
| 238 | act_cfg=self.dwconv_act_cfg) |
| 239 | self.conv_lower_res = ConvModule( |
| 240 | out_channels, |
| 241 | out_channels, |
| 242 | 1, |
| 243 | conv_cfg=self.conv_cfg, |
| 244 | norm_cfg=self.norm_cfg, |
| 245 | act_cfg=self.conv_act_cfg) |
| 246 | |
| 247 | self.conv_higher_res = ConvModule( |
| 248 | higher_in_channels, |
| 249 | out_channels, |
| 250 | 1, |
| 251 | conv_cfg=self.conv_cfg, |
| 252 | norm_cfg=self.norm_cfg, |