CGNet backbone. This backbone is the implementation of `A Light-weight Context Guided Network for Semantic Segmentation `_. Args: in_channels (int): Number of input image channels. Normally 3. num_channels (tuple[int]): Numbers of featu
| 185 | |
| 186 | @BACKBONES.register_module() |
| 187 | class CGNet(BaseModule): |
| 188 | """CGNet backbone. |
| 189 | |
| 190 | This backbone is the implementation of `A Light-weight Context Guided |
| 191 | Network for Semantic Segmentation <https://arxiv.org/abs/1811.08201>`_. |
| 192 | |
| 193 | Args: |
| 194 | in_channels (int): Number of input image channels. Normally 3. |
| 195 | num_channels (tuple[int]): Numbers of feature channels at each stages. |
| 196 | Default: (32, 64, 128). |
| 197 | num_blocks (tuple[int]): Numbers of CG blocks at stage 1 and stage 2. |
| 198 | Default: (3, 21). |
| 199 | dilations (tuple[int]): Dilation rate for surrounding context |
| 200 | extractors at stage 1 and stage 2. Default: (2, 4). |
| 201 | reductions (tuple[int]): Reductions for global context extractors at |
| 202 | stage 1 and stage 2. Default: (8, 16). |
| 203 | conv_cfg (dict): Config dict for convolution layer. |
| 204 | Default: None, which means using conv2d. |
| 205 | norm_cfg (dict): Config dict for normalization layer. |
| 206 | Default: dict(type='BN', requires_grad=True). |
| 207 | act_cfg (dict): Config dict for activation layer. |
| 208 | Default: dict(type='PReLU'). |
| 209 | norm_eval (bool): Whether to set norm layers to eval mode, namely, |
| 210 | freeze running stats (mean and var). Note: Effect on Batch Norm |
| 211 | and its variants only. Default: False. |
| 212 | with_cp (bool): Use checkpoint or not. Using checkpoint will save some |
| 213 | memory while slowing down the training speed. Default: False. |
| 214 | pretrained (str, optional): model pretrained path. Default: None |
| 215 | init_cfg (dict or list[dict], optional): Initialization config dict. |
| 216 | Default: None |
| 217 | """ |
| 218 | |
| 219 | def __init__(self, |
| 220 | in_channels=3, |
| 221 | num_channels=(32, 64, 128), |
| 222 | num_blocks=(3, 21), |
| 223 | dilations=(2, 4), |
| 224 | reductions=(8, 16), |
| 225 | conv_cfg=None, |
| 226 | norm_cfg=dict(type='BN', requires_grad=True), |
| 227 | act_cfg=dict(type='PReLU'), |
| 228 | norm_eval=False, |
| 229 | with_cp=False, |
| 230 | pretrained=None, |
| 231 | init_cfg=None): |
| 232 | |
| 233 | super(CGNet, self).__init__(init_cfg) |
| 234 | |
| 235 | assert not (init_cfg and pretrained), \ |
| 236 | 'init_cfg and pretrained cannot be setting at the same time' |
| 237 | if isinstance(pretrained, str): |
| 238 | warnings.warn('DeprecationWarning: pretrained is a deprecated, ' |
| 239 | 'please use "init_cfg" instead') |
| 240 | self.init_cfg = dict(type='Pretrained', checkpoint=pretrained) |
| 241 | elif pretrained is None: |
| 242 | if init_cfg is None: |
| 243 | self.init_cfg = [ |
| 244 | dict(type='Kaiming', layer=['Conv2d', 'Linear']), |
nothing calls this directly
no outgoing calls
no test coverage detected