(self, cfg, pretrained=None)
| 198 | self.init_weights(cfg, pretrained=cfg.pretrained_model) |
| 199 | |
| 200 | def init_weights(self, cfg, pretrained=None): |
| 201 | if pretrained: |
| 202 | logger.info("Loading pretrained model: {}".format(pretrained)) |
| 203 | self.backbone.init_weights(pretrained=pretrained) |
| 204 | logger.info("Initing weights ...") |
| 205 | init_weight( |
| 206 | self.decode_head, |
| 207 | nn.init.kaiming_normal_, |
| 208 | self.norm_layer, |
| 209 | cfg.bn_eps, |
| 210 | cfg.bn_momentum, |
| 211 | mode="fan_in", |
| 212 | nonlinearity="relu", |
| 213 | ) |
| 214 | if self.aux_head: |
| 215 | init_weight( |
| 216 | self.aux_head, |
| 217 | nn.init.kaiming_normal_, |
| 218 | self.norm_layer, |
| 219 | cfg.bn_eps, |
| 220 | cfg.bn_momentum, |
| 221 | mode="fan_in", |
| 222 | nonlinearity="relu", |
| 223 | ) |
| 224 | |
| 225 | def encode_decode(self, rgb, modal_x): |
| 226 | """Encode images with backbone and decode into a semantic segmentation |
no test coverage detected