{"record":{"id":"424c78a98184420d","repo":"opendatalab/MinerU","slug":"input-image-w-h-smaller-than-the-target-siz","errorCode":null,"errorMessage":"Input image ({w}, {h}) smaller than the target size ({cw}, {ch}).","messagePattern":"Input image \\((.+?), (.+?)\\) smaller than the target size \\((.+?), (.+?)\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/model/table/cls/paddle_table_cls.py","lineNumber":43,"sourceCode":"        self.mean = [0.485, 0.456, 0.406]\n        self.labels = [AtomicModel.WiredTable, AtomicModel.WirelessTable]\n\n    def preprocess(self, input_img):\n        # 放大图片，使其最短边长为256\n        h, w = input_img.shape[:2]\n        scale = 256 / min(h, w)\n        h_resize = round(h * scale)\n        w_resize = round(w * scale)\n        img = cv2.resize(input_img, (w_resize, h_resize), interpolation=1)\n        # 调整为224*224的正方形\n        h, w = img.shape[:2]\n        cw, ch = 224, 224\n        x1 = max(0, (w - cw) // 2)\n        y1 = max(0, (h - ch) // 2)\n        x2 = min(w, x1 + cw)\n        y2 = min(h, y1 + ch)\n        if w < cw or h < ch:\n            raise ValueError(\n                f\"Input image ({w}, {h}) smaller than the target size ({cw}, {ch}).\"\n            )\n        img = img[y1:y2, x1:x2, ...]\n        # 正则化\n        split_im = list(cv2.split(img))\n        std = [0.229, 0.224, 0.225]\n        scale = 0.00392156862745098\n        mean = [0.485, 0.456, 0.406]\n        alpha = [scale / std[i] for i in range(len(std))]\n        beta = [-mean[i] / std[i] for i in range(len(std))]\n        for c in range(img.shape[2]):\n            split_im[c] = split_im[c].astype(np.float32)\n            split_im[c] *= alpha[c]\n            split_im[c] += beta[c]\n        img = cv2.merge(split_im)\n        # 5. 转换为 CHW 格式\n        img = img.transpose((2, 0, 1))\n        imgs = [img]","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/table/cls/paddle_table_cls.py#L25-L61","documentation":"The table-orientation classifier resizes the short edge to 256 then center-crops 224x224; after that resize both dimensions should be >= 224, so this guard fires only for degenerate inputs (near-zero-size images where scaling cannot produce a valid crop, or rounding on extreme aspect ratios). It protects the downstream slice from producing an empty tensor.","triggerScenarios":"Calling the cls transform with an image whose min(h, w) is 0 or 1 (blank crop, failed region extraction), producing a resized dimension below 224 after integer rounding.","commonSituations":"Empty table-region crops from an upstream layout detector with bad boxes (negative or zero-area), fully transparent/blank page regions rendered at tiny size.","solutions":["Validate the crop size upstream: skip regions with w < 10 or h < 10 before classification.","Check the layout detection boxes for zero/negative area and clamp them.","If tiny tables must be classified, upscale with a stronger interpolation before this transform."],"exampleFix":"# before\ncls_result = table_cls.predict(crop)  # crop may be 5x5\n\n# after\nif min(crop.shape[:2]) < 24:\n    continue  # skip degenerate crop\ncls_result = table_cls.predict(crop)","handlingStrategy":"validation","validationCode":"h, w = crop.shape[:2]\nif min(h, w) < 24:\n    skip = True  # degenerate crop; do not classify","typeGuard":"def is_classifiable_crop(img: np.ndarray) -> bool:\n    return img.ndim >= 2 and min(img.shape[:2]) >= 24","tryCatchPattern":"try:\n    res = table_cls(img)\nexcept ValueError as e:\n    if 'smaller than the target size' in str(e):\n        return default_orientation()  # skip/assume no rotation\n    raise","preventionTips":["Filter zero/negative-area layout boxes before cropping.","Skip or pad crops below ~24px on the short edge.","Log skipped-region stats to detect upstream detector regressions."],"tags":["table-recognition","image-processing","validation"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}