{"record":{"id":"e58854e44a20f7c9","repo":"opendatalab/MinerU","slug":"backend-backend-is-not-supported-for-resize-sup","errorCode":null,"errorMessage":"backend: {backend} is not supported for resize.Supported backends are 'cv2', 'pillow'","messagePattern":"backend: (.+?) is not supported for resize\\.Supported backends are 'cv2', 'pillow'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/model/table/rec/unet_table/utils.py","lineNumber":277,"sourceCode":"        size (tuple[int]): Target size (w, h).\n        return_scale (bool): Whether to return `w_scale` and `h_scale`.\n        interpolation (str): Interpolation method, accepted values are\n            \"nearest\", \"bilinear\", \"bicubic\", \"area\", \"lanczos\" for 'cv2'\n            backend, \"nearest\", \"bilinear\" for 'pillow' backend.\n        out (ndarray): The output destination.\n        backend (str | None): The image resize backend type. Options are `cv2`,\n            `pillow`, `None`. If backend is None, the global imread_backend\n            specified by ``mmcv.use_backend()`` will be used. Default: None.\n\n    Returns:\n        tuple | ndarray: (`resized_img`, `w_scale`, `h_scale`) or\n        `resized_img`.\n    \"\"\"\n    h, w = img.shape[:2]\n    if backend is None:\n        backend = \"cv2\"\n    if backend not in [\"cv2\", \"pillow\"]:\n        raise ValueError(\n            f\"backend: {backend} is not supported for resize.\"\n            f\"Supported backends are 'cv2', 'pillow'\"\n        )\n\n    if backend == \"pillow\":\n        assert img.dtype == np.uint8, \"Pillow backend only support uint8 type\"\n        pil_image = Image.fromarray(img)\n        pil_image = pil_image.resize(size, pillow_interp_codes[interpolation])\n        resized_img = np.array(pil_image)\n    else:\n        resized_img = cv2.resize(\n            img, size, dst=out, interpolation=cv2_interp_codes[interpolation]\n        )\n    if not return_scale:\n        return resized_img\n    else:\n        w_scale = size[0] / w\n        h_scale = size[1] / h","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/table/rec/unet_table/utils.py#L259-L295","documentation":"The mmcv-style imresize helper supports exactly two backends: 'cv2' and 'pillow'. Any other string (or a typo, or an unset global read as something else) raises ValueError listing the supported set. backend=None defaults to 'cv2'.","triggerScenarios":"Calling imresize-like resize utilities in unet_table with backend='PIL' (wrong case), backend='torch', or passing the interpolation string in the backend slot by argument mix-up.","commonSituations":"Porting mmcv code that used custom backends, case-sensitive config values from YAML, or positional-argument order mistakes.","solutions":["Use exactly 'cv2' or 'pillow' (lowercase), or pass None for the cv2 default.","Check the call signature to ensure backend is not receiving the interpolation argument.","For torch-based resizing, do it before calling this helper."],"exampleFix":"# before\nout = resize_img(img, (w, h), backend='Pillow')\n\n# after\nout = resize_img(img, (w, h), backend='pillow')","handlingStrategy":"validation","validationCode":"backend = (backend or 'cv2').lower()\nassert backend in ('cv2', 'pillow'), f'bad backend {backend!r}'","typeGuard":"def is_supported_backend(b) -> bool:\n    return b is None or (isinstance(b, str) and b.lower() in ('cv2', 'pillow'))","tryCatchPattern":null,"preventionTips":["Lowercase and validate backend strings from config at load time.","Use keyword arguments (backend=..., interpolation=...) to avoid positional mix-ups.","Document the two valid values next to the config field."],"tags":["image-processing","configuration","table-recognition","validation"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}