{"record":{"id":"bf624c78da7d80ce","repo":"roboflow/supervision","slug":"slice-wh-must-be-an-int-or-a-tuple-of-two-positi","errorCode":null,"errorMessage":"`slice_wh` must be an int or a tuple of two positive integers (slice_w, slice_h). Received: {slice_wh}","messagePattern":"`slice_wh` must be an int or a tuple of two positive integers \\(slice_w, slice_h\\)\\. Received: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/tools/inference_slicer.py","lineNumber":661,"sourceCode":"    def _normalize_slice_wh(\n        slice_wh: int | tuple[int, int],\n    ) -> tuple[int, int]:\n        if isinstance(slice_wh, int):\n            if slice_wh <= 0:\n                raise ValueError(\n                    f\"`slice_wh` must be a positive integer. Received: {slice_wh}\"\n                )\n            return slice_wh, slice_wh\n\n        if isinstance(slice_wh, tuple) and len(slice_wh) == 2:\n            width, height = slice_wh\n            if width <= 0 or height <= 0:\n                raise ValueError(\n                    f\"`slice_wh` values must be positive. Received: {slice_wh}\"\n                )\n            return width, height\n\n        raise ValueError(\n            \"`slice_wh` must be an int or a tuple of two positive integers \"\n            \"(slice_w, slice_h). \"\n            f\"Received: {slice_wh}\"\n        )\n\n    @staticmethod\n    def _normalize_overlap_wh(\n        overlap_wh: int | tuple[int, int],\n    ) -> tuple[int, int]:\n        if isinstance(overlap_wh, int):\n            if overlap_wh < 0:\n                raise ValueError(\n                    \"`overlap_wh` must be a non negative integer. \"\n                    f\"Received: {overlap_wh}\"\n                )\n            return overlap_wh, overlap_wh\n\n        if isinstance(overlap_wh, tuple) and len(overlap_wh) == 2:","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/tools/inference_slicer.py#L643-L679","documentation":"Raised by InferenceSlicer's _normalize_slice_wh when slice_wh is neither an int nor a 2-tuple of ints. The slicer tiles the image into cells of (slice_w, slice_h); any other type (float, string, list, 1- or 3-tuple) has no defined meaning, so it is rejected during construction.","triggerScenarios":"Constructing sv.InferenceSlicer(callback=..., slice_wh=512.0), slice_wh=\"512\", slice_wh=[512, 512], or slice_wh=(512, 512, 3).","commonSituations":"slice_wh read from JSON/YAML config arrives as float or list; CLI argument parsing yields a string; accidentally passing image resolution or a channel-count tuple.","solutions":["Pass an int (slice_wh=512) or an int 2-tuple (slice_wh=(512, 384)).","Coerce config values at load time: tuple(int(v) for v in cfg['slice_wh']) if it is a sequence, else int(cfg['slice_wh']).","Validate config schema before constructing the slicer."],"exampleFix":"# before\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=[512, 512])  # ValueError\n\n# after\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=(512, 512))","handlingStrategy":"validation","validationCode":"def normalize_slice_wh(v):\n    if isinstance(v, (list, tuple)):\n        v = tuple(int(x) for x in v)\n    else:\n        v = int(v)\n    return v\n\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=normalize_slice_wh(cfg['slice_wh']))","typeGuard":"def is_valid_slice_wh(v) -> bool:\n    if isinstance(v, int):\n        return v > 0\n    return isinstance(v, tuple) and len(v) == 2 and all(isinstance(x, int) and x > 0 for x in v)","tryCatchPattern":null,"preventionTips":["Coerce config-sourced numeric params to int at load time.","Schema-validate config files (type, range) before constructing InferenceSlicer."],"tags":["inference-slicer","configuration","validation","valueerror"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}