{"record":{"id":"05e531426e585403","repo":"PaddlePaddle/PaddleOCR","slug":"lam-must-be-number-or-list-with-length-2","errorCode":null,"errorMessage":"lam must be number or list with length 2","messagePattern":"lam must be number or list with length 2","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ppocr/data/imaug/abinet_aug.py","lineNumber":323,"sourceCode":"            self.var = int(sample_uniform(var[0], var[1]))\n        else:\n            raise Exception(\"degree must be number or list with length 2\")\n\n    def __call__(self, img):\n        noise = np.random.normal(self.mean, self.var**0.5, img.shape)\n        img = np.clip(img + noise, 0, 255).astype(np.uint8)\n        return img\n\n\nclass CVPossionNoise(object):\n    def __init__(self, lam=20):\n        self.lam = lam\n        if isinstance(lam, numbers.Number):\n            self.lam = max(int(sample_asym(lam)), 1)\n        elif isinstance(lam, (tuple, list)) and len(lam) == 2:\n            self.lam = int(sample_uniform(lam[0], lam[1]))\n        else:\n            raise Exception(\"lam must be number or list with length 2\")\n\n    def __call__(self, img):\n        noise = np.random.poisson(lam=self.lam, size=img.shape)\n        img = np.clip(img + noise, 0, 255).astype(np.uint8)\n        return img\n\n\nclass CVGaussionBlur(object):\n    def __init__(self, radius):\n        self.radius = radius\n        if isinstance(radius, numbers.Number):\n            self.radius = max(int(sample_asym(radius)), 1)\n        elif isinstance(radius, (tuple, list)) and len(radius) == 2:\n            self.radius = int(sample_uniform(radius[0], radius[1]))\n        else:\n            raise Exception(\"radius must be number or list with length 2\")\n\n    def __call__(self, img):","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/data/imaug/abinet_aug.py#L305-L341","documentation":"CVPossionNoise's constructor validates lam (Poisson lambda): a number is sampled via sample_asym, a 2-element tuple/list via sample_uniform, and anything else raises Exception('lam must be number or list with length 2'). The misspelled class name (Possion) and the parameter name lam both appear verbatim in configs, so the message text is accurate here.","triggerScenarios":"CVPossionNoise(lam=[5, 10, 20]) (length 3), lam='20' (string), lam=None or a dict from config.","commonSituations":"YAML/JSON numeric values loading as strings; range specs with more than two bounds; copying configs between noise transforms with different parameter shapes.","solutions":["Pass lam as a number (e.g. lam=20) or a 2-element tuple like lam=(5, 30).","Cast scalars from config: lam=float(cfg['lam']).","Keep range specs to exactly (low, high)."],"exampleFix":"# before\nCVPossionNoise(lam=cfg['lam'])  # cfg['lam'] == '20' -> Exception\n# after\nlam = cfg['lam']\nCVPossionNoise(lam=float(lam) if isinstance(lam, (int, float)) else (lam[0], lam[1]))","handlingStrategy":"validation","validationCode":"import numbers\n\ndef valid_lam(v) -> bool:\n    return (isinstance(v, numbers.Number)\n            or (isinstance(v, (tuple, list)) and len(v) == 2))","typeGuard":"import numbers\n\ndef is_valid_lam(v) -> bool:\n    return isinstance(v, numbers.Number) or (isinstance(v, (tuple, list)) and len(v) == 2)","tryCatchPattern":null,"preventionTips":["Pass lam as a number or (low, high) tuple only","Cast YAML/JSON scalars to float before constructing the transform","Validate all noise-transform params in one config-check step before training"],"tags":["data-augmentation","abinet","noise","poisson","config","exception"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}