{"record":{"id":"2d9cc946a3649f31","repo":"open-mmlab/mmdetection","slug":"the-in-channels-of-solov2maskfeathead-and-solov2","errorCode":null,"errorMessage":"The `in_channels` of SOLOv2MaskFeatHead and SOLOv2Head should be same, changing mask_feature_head.in_channels to {self.in_channels}","messagePattern":"The `in_channels` of SOLOv2MaskFeatHead and SOLOv2Head should be same, changing mask_feature_head\\.in_channels to (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mmdet/models/dense_heads/solov2_head.py","lineNumber":214,"sourceCode":"                         bias_prob=0.01,\n                         override=dict(name='conv_cls'))\n                 ],\n                 **kwargs) -> None:\n        assert dcn_cfg is None or isinstance(dcn_cfg, dict)\n        self.dcn_cfg = dcn_cfg\n        self.with_dcn = dcn_cfg is not None\n        self.dcn_apply_to_all_conv = dcn_apply_to_all_conv\n        self.dynamic_conv_size = dynamic_conv_size\n        mask_out_channels = mask_feature_head.get('out_channels')\n        self.kernel_out_channels = \\\n            mask_out_channels * self.dynamic_conv_size * self.dynamic_conv_size\n\n        super().__init__(*args, init_cfg=init_cfg, **kwargs)\n\n        # update the in_channels of mask_feature_head\n        if mask_feature_head.get('in_channels', None) is not None:\n            if mask_feature_head.in_channels != self.in_channels:\n                warnings.warn('The `in_channels` of SOLOv2MaskFeatHead and '\n                              'SOLOv2Head should be same, changing '\n                              'mask_feature_head.in_channels to '\n                              f'{self.in_channels}')\n                mask_feature_head.update(in_channels=self.in_channels)\n        else:\n            mask_feature_head.update(in_channels=self.in_channels)\n\n        self.mask_feature_head = MaskFeatModule(**mask_feature_head)\n        self.mask_stride = self.mask_feature_head.mask_stride\n        self.fp16_enabled = False\n\n    def _init_layers(self) -> None:\n        \"\"\"Initialize layers of the head.\"\"\"\n        self.cls_convs = nn.ModuleList()\n        self.kernel_convs = nn.ModuleList()\n        conv_cfg = None\n        for i in range(self.stacked_convs):\n            if self.with_dcn:","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/dense_heads/solov2_head.py#L196-L232","documentation":"SOLOv2Head warns that the in_channels of its mask_feature_head differs from the head's own in_channels, and force-overwrites mask_feature_head.in_channels to match. SOLOv2 requires both to agree so the mask feature branch aligns with the kernel prediction branch.","triggerScenarios":"Configuring SOLOv2 with mask_feat_head=dict(in_channels=X, ...) where X != the head's in_channels=Y.","commonSituations":"Copying a SOLOv2 config and changing one in_channels (e.g. backbone output channels) but not the mask_feature_head's; custom backbone necks producing different channel counts.","solutions":["Set mask_feature_head.in_channels equal to the head's in_channels in the config","Verify the neck's out_channels matches both values"],"exampleFix":"# before\nmask_head=dict(type='SOLOv2Head', in_channels=256, mask_feature_head=dict(in_channels=128, ...))\n# after\nmask_head=dict(type='SOLOv2Head', in_channels=256, mask_feature_head=dict(in_channels=256, ...))","handlingStrategy":"validation","validationCode":"head_cfg = cfg['model']['roi_head']['bbox_head']\nmfh = head_cfg.get('mask_feature_head', {})\nif mfh.get('in_channels') is not None:\n    assert mfh['in_channels'] == head_cfg['in_channels'], 'SOLOv2 in_channels mismatch'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep SOLOv2 in_channels and mask_feature_head.in_channels identical in configs","Validate configs against base config invariants before training"],"tags":["mmdet","solov2","config","instance-segmentation"],"backgroundTag":"config-mismatch","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}