{"record":{"id":"613bbb420e839430","repo":"lllyasviel/ControlNet","slug":"inverted-residual-setting-should-be-non-empty-or-a-613bbb","errorCode":null,"errorMessage":"inverted_residual_setting should be non-empty or a 4-element list, got {}","messagePattern":"inverted_residual_setting should be non-empty or a 4-element list, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"annotator/mlsd/models/mbv2_mlsd_tiny.py","lineNumber":185,"sourceCode":"        input_channel = 32\n        last_channel = 1280\n        width_mult = 1.0\n        round_nearest = 8\n\n        inverted_residual_setting = [\n            # t, c, n, s\n            [1, 16, 1, 1],\n            [6, 24, 2, 2],\n            [6, 32, 3, 2],\n            [6, 64, 4, 2],\n            #[6, 96, 3, 1],\n            #[6, 160, 3, 2],\n            #[6, 320, 1, 1],\n        ]\n\n        # only check the first element, assuming user knows t,c,n,s are required\n        if len(inverted_residual_setting) == 0 or len(inverted_residual_setting[0]) != 4:\n            raise ValueError(\"inverted_residual_setting should be non-empty \"\n                             \"or a 4-element list, got {}\".format(inverted_residual_setting))\n\n        # building first layer\n        input_channel = _make_divisible(input_channel * width_mult, round_nearest)\n        self.last_channel = _make_divisible(last_channel * max(1.0, width_mult), round_nearest)\n        features = [ConvBNReLU(4, input_channel, stride=2)]\n        # building inverted residual blocks\n        for t, c, n, s in inverted_residual_setting:\n            output_channel = _make_divisible(c * width_mult, round_nearest)\n            for i in range(n):\n                stride = s if i == 0 else 1\n                features.append(block(input_channel, output_channel, stride, expand_ratio=t))\n                input_channel = output_channel\n        self.features = nn.Sequential(*features)\n\n        self.fpn_selected = [3, 6, 10]\n        # weight initialization\n        for m in self.modules():","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/mlsd/models/mbv2_mlsd_tiny.py#L167-L203","documentation":"Identical validation in the MLSd tiny variant: the constructor requires inverted_residual_setting to be a non-empty list of 4-element (t, c, n, s) tuples. An empty list or malformed first row triggers the error.","triggerScenarios":"Building mbv2_mlsd_tiny with a custom inverted_residual_setting that is empty or has a first element whose length != 4.","commonSituations":"Porting layer configs between tiny/large variants; YAML overrides that drop the list; experimental pruning scripts emptying the setting.","solutions":["Supply a valid non-empty list of [t, c, n, s] rows","Diff your config against the default in mbv2_mlsd_tiny.py","Guard with an assertion before model construction"],"exampleFix":"# before\nmodel = MobileNetV2([[6, 24, 2]])  # 3-element row\n# after\nmodel = MobileNetV2([[6, 24, 2, 2]])  # [t,c,n,s]","handlingStrategy":"validation","validationCode":"assert len(inverted_residual_setting) > 0 and all(len(r) == 4 for r in inverted_residual_setting), 'need non-empty list of [t,c,n,s] rows'","typeGuard":"def is_valid_setting(s) -> bool:\n    return isinstance(s, (list, tuple)) and len(s) > 0 and all(len(r) == 4 for r in s)","tryCatchPattern":null,"preventionTips":["Reuse the model file's default settings when unsure","Validate config-derived lists before model construction"],"tags":["mlsd","mobilenet","model-config","value-error"],"backgroundTag":"invalid-model-config","analyzedSha":"ed85cd1e25a5ed592f7d8178495b4483de0331bf","analyzedAt":"2026-08-27T12:58:54.167Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}