{"record":{"id":"a3610c54536b0e0d","repo":"PaddlePaddle/PaddleOCR","slug":"mode-can-only-be-one-of-lite-large-but-rec","errorCode":null,"errorMessage":"mode can only be one of ['lite', 'large'], but received {}","messagePattern":"mode can only be one of \\['lite', 'large'\\], but received (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ppocr/modeling/necks/db_fpn.py","lineNumber":449,"sourceCode":"\nclass LKPAN(nn.Layer):\n    def __init__(self, in_channels, out_channels, mode=\"large\", **kwargs):\n        super(LKPAN, self).__init__()\n        self.out_channels = out_channels\n        weight_attr = paddle.nn.initializer.KaimingUniform()\n\n        self.ins_conv = nn.LayerList()\n        self.inp_conv = nn.LayerList()\n        # pan head\n        self.pan_head_conv = nn.LayerList()\n        self.pan_lat_conv = nn.LayerList()\n\n        if mode.lower() == \"lite\":\n            p_layer = DSConv\n        elif mode.lower() == \"large\":\n            p_layer = nn.Conv2D\n        else:\n            raise ValueError(\n                \"mode can only be one of ['lite', 'large'], but received {}\".format(\n                    mode\n                )\n            )\n\n        for i in range(len(in_channels)):\n            self.ins_conv.append(\n                nn.Conv2D(\n                    in_channels=in_channels[i],\n                    out_channels=self.out_channels,\n                    kernel_size=1,\n                    weight_attr=ParamAttr(initializer=weight_attr),\n                    bias_attr=False,\n                )\n            )\n\n            self.inp_conv.append(\n                p_layer(","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/modeling/necks/db_fpn.py#L431-L467","documentation":"RSEFPN (the DB-detection FPN in db_fpn.py) selects its pan-head convolution type from mode: 'lite' uses depthwise-separable DSConv, 'large' uses full nn.Conv2D. Any other string fails the elif chain and raises this ValueError at construction time.","triggerScenarios":"Building a DB/RSE detection model whose Neck config has Mode set to something other than 'lite' or 'large' (case-insensitive), e.g. 'small', 'base', or a typo like 'Lite ' (note: 'LITE'.lower()=='lite' so only exact-after-lower strings pass).","commonSituations":"Copying a detection yaml and changing Mode to match a backbone scale naming ('tiny'/'base'); older configs that used different mode names; typos in hand-written Neck sections.","solutions":["Set Neck.Mode to \"lite\" (DSConv, faster/smaller) or \"large\" (Conv2D, heavier) in the detection config","Check for stray whitespace/case in the Mode string (' lite'.lower() != 'lite' only if leading space — trim it)"],"exampleFix":"# before (config yaml)\nNeck:\n  name: RSEFPN\n  Mode: 'small'\n# after\nNeck:\n  name: RSEFPN\n  Mode: 'lite'","handlingStrategy":"validation","validationCode":"mode = str(neck_cfg['Mode']).strip().lower()\nassert mode in ('lite', 'large'), f\"Mode must be 'lite' or 'large', got {neck_cfg['Mode']!r}\"","typeGuard":"def valid_fpn_mode(mode) -> bool:\n    return isinstance(mode, str) and mode.strip().lower() in ('lite', 'large')","tryCatchPattern":null,"preventionTips":["Validate config against the allowed mode set before build_model","Copy mode values from official RSEFPN yamls instead of typing them"],"tags":["paddle","db-fpn","config","constructor-validation"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}