{"record":{"id":"2993e13afdd5e3b9","repo":"roboflow/supervision","slug":"overlap-wh-must-be-an-int-or-a-tuple-of-two-non","errorCode":null,"errorMessage":"`overlap_wh` must be an int or a tuple of two non negative integers (overlap_w, overlap_h). Received: {overlap_wh}","messagePattern":"`overlap_wh` must be an int or a tuple of two non negative integers \\(overlap_w, overlap_h\\)\\. Received: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/tools/inference_slicer.py","lineNumber":687,"sourceCode":"        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:\n            overlap_w, overlap_h = overlap_wh\n            if overlap_w < 0 or overlap_h < 0:\n                raise ValueError(\n                    f\"`overlap_wh` values must be non negative. Received: {overlap_wh}\"\n                )\n            return overlap_w, overlap_h\n\n        raise ValueError(\n            \"`overlap_wh` must be an int or a tuple of two non negative integers \"\n            \"(overlap_w, overlap_h). \"\n            f\"Received: {overlap_wh}\"\n        )\n\n    @staticmethod\n    def _generate_offset(\n        resolution_wh: tuple[int, int],\n        slice_wh: tuple[int, int],\n        overlap_wh: tuple[int, int],\n    ) -> npt.NDArray[Any]:\n        \"\"\"\n        Generate bounding boxes defining the coordinates of image slices with overlap.\n\n        Args:\n            resolution_wh: Image resolution `(width, height)`.\n            slice_wh: Size of each slice `(width, height)`.\n            overlap_wh: Overlap size between slices `(width, height)`.","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/tools/inference_slicer.py#L669-L705","documentation":"Raised by InferenceSlicer's _normalize_overlap_wh when overlap_wh is neither an int nor a 2-tuple of ints. Overlap defines how many pixels adjacent slices share; floats, strings, lists, or tuples of the wrong length cannot describe that and are rejected during construction.","triggerScenarios":"Constructing sv.InferenceSlicer(callback=..., overlap_wh=0.2) (a ratio instead of pixels), overlap_wh=[128], or overlap_wh=\"128\".","commonSituations":"Confusing overlap_wh with a fraction (0.2) the way IoU thresholds work; config files that parse numbers as floats or sequences as lists.","solutions":["Pass an int pixel count (overlap_wh=128) or an int 2-tuple (overlap_wh=(128, 64)); 0 is allowed.","If you think in ratios, convert first: overlap_wh = int(0.25 * slice_w).","Coerce config-sourced values to int/tuple at load time."],"exampleFix":"# before\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=512, overlap_wh=0.25)  # ValueError\n\n# after\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=512, overlap_wh=int(0.25 * 512))","handlingStrategy":"validation","validationCode":"def normalize_overlap_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, overlap_wh=normalize_overlap_wh(cfg['overlap_wh']))","typeGuard":"def is_valid_overlap_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":["overlap_wh is in pixels, not a ratio — convert fractions at the config boundary.","Keep slice/overlap params as ints in config schemas to avoid float leakage."],"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"}