{"record":{"id":"2981b4eae86eff16","repo":"open-mmlab/mmdetection","slug":"out-indices-must-be-a-subset-of-range-0-8-but-r","errorCode":null,"errorMessage":"out_indices must be a subset of range(0, 8). But received {out_indices}","messagePattern":"out_indices must be a subset of range\\(0, 8\\)\\. But received (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mmdet/models/backbones/mobilenet_v2.py","lineNumber":82,"sourceCode":"            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        else:\n            raise TypeError('pretrained must be a str or None')\n\n        self.widen_factor = widen_factor\n        self.out_indices = out_indices\n        if not set(out_indices).issubset(set(range(0, 8))):\n            raise ValueError('out_indices must be a subset of range'\n                             f'(0, 8). But received {out_indices}')\n\n        if frozen_stages not in range(-1, 8):\n            raise ValueError('frozen_stages must be in range(-1, 8). '\n                             f'But received {frozen_stages}')\n        self.out_indices = out_indices\n        self.frozen_stages = frozen_stages\n        self.conv_cfg = conv_cfg\n        self.norm_cfg = norm_cfg\n        self.act_cfg = act_cfg\n        self.norm_eval = norm_eval\n        self.with_cp = with_cp\n\n        self.in_channels = make_divisible(32 * widen_factor, 8)\n\n        self.conv1 = ConvModule(\n            in_channels=3,\n            out_channels=self.in_channels,","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/backbones/mobilenet_v2.py#L64-L100","documentation":"MobileNetV2.__init__ validates out_indices: every element must be an integer in 0..7 (the backbone has 8 stages of inverted residual blocks). Passing indices outside that set raises ValueError because no feature map exists for them.","triggerScenarios":"MobileNetV2(out_indices=(8,)) or out_indices=[-1, 4] or out_indices=(0, 1, 2, 3, 4, 5, 6, 7, 8); any subset not within set(range(0, 8)).","commonSituations":"Configuring FPN/neck outputs to take extra feature levels; copying out_indices from another backbone (e.g. ResNet depth-50 with 4 stages) into MobileNetV2; off-by-one when listing stages.","solutions":["Restrict out_indices to values within range(0, 8), e.g. (1, 2, 4, 7)","Count the MobileNetV2 stages for your widen_factor config and pick valid exit points","Match the number of out_indices to what the downstream neck (FPN) expects"],"exampleFix":"// before\nbackbone=dict(type='MobileNetV2', out_indices=(0, 1, 2, 3, 4, 5, 6, 7, 8))\n// after\nbackbone=dict(type='MobileNetV2', out_indices=(1, 2, 4, 7))","handlingStrategy":"validation","validationCode":"assert set(out_indices).issubset(set(range(0, 8))), 'out_indices must be within 0..7'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check backbone stage count before setting out_indices","Keep out_indices consistent with the neck's in_channels list"],"tags":["mmdet","mobilenetv2","out-indices","validation","config"],"backgroundTag":"index-out-of-range","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}