{"record":{"id":"e59a4e917ef30e08","repo":"PaddlePaddle/PaddleOCR","slug":"unsupported-interpolation-type","errorCode":null,"errorMessage":"Unsupported interpolation type !!!","messagePattern":"Unsupported interpolation type !!!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ppocr/data/imaug/rec_img_aug.py","lineNumber":364,"sourceCode":"        return data\n\n\nclass RFLRecResizeImg(object):\n    def __init__(self, image_shape, padding=True, interpolation=1, **kwargs):\n        self.image_shape = image_shape\n        self.padding = padding\n\n        self.interpolation = interpolation\n        if self.interpolation == 0:\n            self.interpolation = cv2.INTER_NEAREST\n        elif self.interpolation == 1:\n            self.interpolation = cv2.INTER_LINEAR\n        elif self.interpolation == 2:\n            self.interpolation = cv2.INTER_CUBIC\n        elif self.interpolation == 3:\n            self.interpolation = cv2.INTER_AREA\n        else:\n            raise Exception(\"Unsupported interpolation type !!!\")\n\n    def __call__(self, data):\n        img = data[\"image\"]\n        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n        norm_img, valid_ratio = resize_norm_img(\n            img, self.image_shape, self.padding, self.interpolation\n        )\n        data[\"image\"] = norm_img\n        data[\"valid_ratio\"] = valid_ratio\n        if \"iluvatar_gpu\" in get_device():\n            data[\"valid_ratio\"] = np.float32(valid_ratio)\n        return data\n\n\nclass SRNRecResizeImg(object):\n    def __init__(self, image_shape, num_heads, max_text_length, **kwargs):\n        self.image_shape = image_shape\n        self.num_heads = num_heads","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/data/imaug/rec_img_aug.py#L346-L382","documentation":"This grayscale-recognition image-normalization class accepts only OpenCV interpolation codes 0 (NEAREST), 1 (LINEAR), 2 (CUBIC), and 3 (AREA) passed as plain ints. Any other value raises 'Unsupported interpolation type !!!' at pipeline construction time.","triggerScenarios":"Setting interpolation: 4 (or any int outside 0-3), a string like 'linear', or a cv2 enum constant (cv2.INTER_LANCZOS4 = 4) in the rec preprocessing config for this op.","commonSituations":"Using Lanczos4 (4) or other OpenCV flags unsupported by this mapper; passing a cv2 constant object instead of its int value; configs ported from torch/torchvision where strings like 'bilinear' are the convention.","solutions":["Set interpolation to one of 0/1/2/3 in the yml (e.g. interpolation: 1 for LINEAR)","If you have a cv2 constant in Python, pass int(cv2.INTER_LINEAR) not the flag name string","For Lanczos-style quality use 2 (CUBIC) as the closest supported option","Add a startup assertion in custom code: assert op.interpolation in (0, 1, 2, 3)"],"exampleFix":"# before\ninterpolation: 4\n# after\ninterpolation: 2","handlingStrategy":"validation","validationCode":"iv = op_cfg.get('interpolation', 1)\nif iv not in (0, 1, 2, 3):\n    raise SystemExit(f'interpolation must be 0|1|2|3, got {iv!r}')","typeGuard":"def is_valid_interp(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and 0 <= v <= 3","tryCatchPattern":"try:\n    op = RecResizeNorm(**op_cfg)\nexcept Exception as e:\n    if 'Unsupported interpolation' in str(e):\n        raise ValueError(f\"Use interpolation 0-3 (NEAREST/LINEAR/CUBIC/AREA), got {op_cfg.get('interpolation')}\") from e\n    raise","preventionTips":["Use raw ints 0-3 in ymls, never cv2 flag objects or strings","Document the mapping (0 NEAREST, 1 LINEAR, 2 CUBIC, 3 AREA) next to your config","Validate all preprocess op params in one lint function at startup"],"tags":["config","recognition","interpolation","preprocessing"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}