{"record":{"id":"ad07fed2c636c05c","repo":"PaddlePaddle/PaddleOCR","slug":"radius-must-be-number-or-list-with-length-2","errorCode":null,"errorMessage":"radius must be number or list with length 2","messagePattern":"radius must be number or list with length 2","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ppocr/data/imaug/abinet_aug.py","lineNumber":339,"sourceCode":"            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):\n        fil = cv2.getGaussianKernel(ksize=self.radius, sigma=1, ktype=cv2.CV_32F)\n        img = cv2.sepFilter2D(img, -1, fil, fil)\n        return img\n\n\nclass CVMotionBlur(object):\n    def __init__(self, degrees=12, angle=90):\n        if isinstance(degrees, numbers.Number):\n            self.degree = max(int(sample_asym(degrees)), 1)\n        elif isinstance(degrees, (tuple, list)) and len(degrees) == 2:\n            self.degree = int(sample_uniform(degrees[0], degrees[1]))\n        else:\n            raise Exception(\"degree must be number or list with length 2\")\n        self.angle = sample_uniform(-angle, angle)\n\n    def __call__(self, img):","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/data/imaug/abinet_aug.py#L321-L357","documentation":"CVGaussionBlur is the Gaussian-blur augmentation used by ABINet text recognition training in PaddleOCR. Its constructor requires the 'radius' argument to be either a single number (maximum radius, sampled asymmetrically) or a tuple/list of exactly two numbers (a min/max range sampled uniformly). Any other type or length raises this exception before any image is processed.","triggerScenarios":"Instantiating CVGaussionBlur from an ABINet yml config (Train.dataset.transforms -> tia or aug entries) with radius given as a string (e.g. '2'), a list of length other than 2 (e.g. [1, 2, 3]), a dict, or None.","commonSituations":"Editing configs/rec/abinet/abinet_rec.yml or a distilled copy and changing the blur radius to an invalid form; hand-writing an augmenter pipeline in a custom training script; copy-pasting an imgaug-style parameter (which sometimes uses 3-element lists) into this class.","solutions":["Set radius to a single number, e.g. radius: 2 in the config","Or set radius to a two-element range, e.g. radius: [1, 3]","Check for YAML type traps: an unquoted value like radius: 2, 3 parses incorrectly; keep the list bracketed","If building the pipeline in Python, verify with isinstance(radius, (int, float)) or (isinstance(radius, (list, tuple)) and len(radius) == 2) before constructing"],"exampleFix":"# before (config)\naug: CVGaussionBlur:\n  radius: [1, 2, 3]\n# after\naug: CVGaussionBlur:\n  radius: [1, 3]","handlingStrategy":"type-guard","validationCode":"import numbers\nr = cfg['radius']\nok = isinstance(r, numbers.Number) or (isinstance(r, (list, tuple)) and len(r) == 2 and all(isinstance(x, numbers.Number) for x in r))\nif not ok:\n    raise SystemExit('CVGaussionBlur radius must be a number or [min, max]')","typeGuard":"def is_valid_blur_radius(r):\n    import numbers\n    return isinstance(r, numbers.Number) or (\n        isinstance(r, (list, tuple)) and len(r) == 2\n        and all(isinstance(x, numbers.Number) for x in r)\n    )","tryCatchPattern":"try:\n    aug = CVGaussionBlur(radius=cfg['radius'])\nexcept Exception as e:\n    raise ValueError(f'Bad blur config: {cfg}; cause: {e}') from e","preventionTips":["Validate augmentation configs with a schema check before launching training","Prefer the two-element range form [min, max] consistently across blur ops","Load and print the parsed YAML once to confirm types (int/list, not str)"],"tags":["config","data-augmentation","type-validation","abinet"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}