{"record":{"id":"634f788fc52d94f0","repo":"open-mmlab/mmdetection","slug":"pretrained-must-be-a-str-or-none-634f78","errorCode":null,"errorMessage":"pretrained must be a str or None","messagePattern":"pretrained must be a str or None","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"mmdet/models/backbones/regnet.py","lineNumber":193,"sourceCode":"            'init_cfg and pretrained cannot be specified at the same time'\n        if isinstance(pretrained, str):\n            warnings.warn('DeprecationWarning: pretrained is deprecated, '\n                          'please use \"init_cfg\" instead')\n            self.init_cfg = dict(type='Pretrained', checkpoint=pretrained)\n        elif pretrained is None:\n            if init_cfg is None:\n                self.init_cfg = [\n                    dict(type='Kaiming', layer='Conv2d'),\n                    dict(\n                        type='Constant',\n                        val=1,\n                        layer=['_BatchNorm', 'GroupNorm'])\n                ]\n                if self.zero_init_residual:\n                    block_init_cfg = dict(\n                        type='Constant', val=0, override=dict(name='norm3'))\n        else:\n            raise TypeError('pretrained must be a str or None')\n\n        self.inplanes = stem_channels\n        self.res_layers = []\n        for i, num_blocks in enumerate(self.stage_blocks):\n            stride = self.strides[i]\n            dilation = self.dilations[i]\n            group_width = self.group_widths[i]\n            width = int(round(self.stage_widths[i] * self.bottleneck_ratio[i]))\n            stage_groups = width // group_width\n\n            dcn = self.dcn if self.stage_with_dcn[i] else None\n            if self.plugins is not None:\n                stage_plugins = self.make_stage_plugins(self.plugins, i)\n            else:\n                stage_plugins = None\n\n            res_layer = self.make_res_layer(\n                block=self.block,","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/backbones/regnet.py#L175-L211","documentation":"RegNet (inherits ResNet-style init) raises TypeError when the deprecated `pretrained` argument is not a str or None. Only a checkpoint path string or None is accepted; use init_cfg for new code.","triggerScenarios":"RegNet(pretrained=dict(...)) or pretrained=Path(...); mixing pretrained and init_cfg (which trips a separate assert).","commonSituations":"Porting old mmdet configs using pretrained='open-mmlab://detectron2/resnet50_caffe' style entries to RegNet; passing the whole init_cfg dict into the pretrained slot by mistake.","solutions":["Pass pretrained as a str checkpoint path or None","Better: use init_cfg=dict(type='Pretrained', checkpoint='regnetx_400mf.pth') and drop pretrained"],"exampleFix":"// before\nbackbone=dict(type='RegNet', arch='regnetx_400mf', pretrained='open-mmlab://regnetx_400mf')\n// after\nbackbone=dict(type='RegNet', arch='regnetx_400mf', init_cfg=dict(type='Pretrained', checkpoint='regnetx_400mf_8xb128-...pth'))","handlingStrategy":"validation","validationCode":"assert pretrained is None or isinstance(pretrained, str)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on init_cfg in all configs","Assert type of pretrained when loading legacy configs"],"tags":["mmdet","regnet","pretrained","init-cfg"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}