{"record":{"id":"caaeacc8629e1d9b","repo":"lllyasviel/ControlNet","slug":"inverted-residual-setting-should-be-non-empty-or-a","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_large.py","lineNumber":186,"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\n        self.features = nn.Sequential(*features)\n        self.fpn_selected = [1, 3, 6, 10, 13]\n        # weight initialization\n        for m in self.modules():","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/mlsd/models/mbv2_mlsd_large.py#L168-L204","documentation":"MobileNetV2-based MLSd large model constructor validates inverted_residual_setting: it must be a non-empty list whose (first) entries are 4-element tuples (t, c, n, s) describing each inverted residual block. Empty lists or wrong-length tuples raise this ValueError.","triggerScenarios":"Constructing the MLSd large network with an overridden inverted_residual_setting that is [] or whose first element has more/fewer than 4 values (e.g. commented-out rows left in a modified copy of the default settings list).","commonSituations":"Editing the default layer table to trim layers and accidentally removing all entries; passing a config dict value that deserializes to an empty list.","solutions":["Keep at least one full [t, c, n, s] entry in inverted_residual_setting","Revert to the file's default inverted_residual_setting if you modified it","Validate the setting length programmatically before constructing the model"],"exampleFix":"# before\nsetting = []  # all rows commented out\n# after\nsetting = [[1, 16, 1, 1], [6, 24, 2, 2]]  # proper [t,c,n,s] rows","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":["Keep a unit test asserting the default setting parses","Diff config tables before/after pruning experiments"],"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"}