{"record":{"id":"bfe04aeb08510db2","repo":"open-mmlab/mmdetection","slug":"pretrained-must-be-a-str-or-none-bfe04a","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/ssd_vgg.py","lineNumber":97,"sourceCode":"        self.out_feature_indices = out_feature_indices\n\n        assert not (init_cfg and pretrained), \\\n            'init_cfg and pretrained cannot be specified at the same time'\n\n        if init_cfg is not None:\n            self.init_cfg = init_cfg\n        elif 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            self.init_cfg = [\n                dict(type='Kaiming', layer='Conv2d'),\n                dict(type='Constant', val=1, layer='BatchNorm2d'),\n                dict(type='Normal', std=0.01, layer='Linear'),\n            ]\n        else:\n            raise TypeError('pretrained must be a str or None')\n\n        if input_size is not None:\n            warnings.warn('DeprecationWarning: input_size is deprecated')\n        if l2_norm_scale is not None:\n            warnings.warn('DeprecationWarning: l2_norm_scale in VGG is '\n                          'deprecated, it has been moved to SSDNeck.')\n\n    def init_weights(self, pretrained=None):\n        super(VGG, self).init_weights()\n\n    def forward(self, x):\n        \"\"\"Forward function.\"\"\"\n        outs = []\n        for i, layer in enumerate(self.features):\n            x = layer(x)\n            if i in self.out_feature_indices:\n                outs.append(x)\n","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/backbones/ssd_vgg.py#L79-L115","documentation":"SSDVGG.__init__ raises TypeError when the deprecated `pretrained` is neither a str nor None. Like other mmdet backbones, str is converted to init_cfg and new code should use init_cfg directly.","triggerScenarios":"SSDVGG(pretrained=dict(checkpoint=...)) or pretrained=Path; also triggered by passing pretrained alongside init_cfg in older code paths.","commonSituations":"Old SSD configs (v1-era) using pretrained='open-mmlab://vgg16_caffe'; migrating SSD pipelines to the init_cfg API.","solutions":["Use init_cfg=dict(type='Pretrained', checkpoint='vgg16_caffe-...pth')","Or pass pretrained as a checkpoint path string only"],"exampleFix":"// before\nbackbone=dict(type='SSDVGG', depth=16, pretrained='open-mmlab://vgg16_caffe')\n// after\nbackbone=dict(type='SSDVGG', depth=16, with_last_pool=False, init_cfg=dict(type='Pretrained', checkpoint='vgg16_caffe-...pth'))","handlingStrategy":"validation","validationCode":"assert pretrained is None or isinstance(pretrained, str)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use init_cfg for checkpoint loading","Keep deprecated pretrained only as a str path"],"tags":["mmdet","ssd-vgg","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"}