{"record":{"id":"283439aa7239e40e","repo":"roboflow/supervision","slug":"overlap-wh-must-be-smaller-than-slice-wh-in-bo","errorCode":null,"errorMessage":"`overlap_wh` must be smaller than `slice_wh` in both dimensions to keep a positive stride. Received overlap_wh={overlap_wh}, slice_wh={slice_wh}.","messagePattern":"`overlap_wh` must be smaller than `slice_wh` in both dimensions to keep a positive stride\\. Received overlap_wh=(.+?), slice_wh=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/tools/inference_slicer.py","lineNumber":772,"sourceCode":"\n        return offsets\n\n    @staticmethod\n    def _validate_overlap(\n        slice_wh: tuple[int, int],\n        overlap_wh: tuple[int, int],\n    ) -> None:\n        overlap_w, overlap_h = overlap_wh\n        slice_w, slice_h = slice_wh\n\n        if overlap_w < 0 or overlap_h < 0:\n            raise ValueError(\n                \"Overlap values must be greater than or equal to 0. \"\n                f\"Received: {overlap_wh}\"\n            )\n\n        if overlap_w >= slice_w or overlap_h >= slice_h:\n            raise ValueError(\n                \"`overlap_wh` must be smaller than `slice_wh` in both dimensions \"\n                f\"to keep a positive stride. Received overlap_wh={overlap_wh}, \"\n                f\"slice_wh={slice_wh}.\"\n            )\n","sourceCodeStart":754,"sourceCodeEnd":777,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/tools/inference_slicer.py#L754-L777","documentation":"Raised by InferenceSlicer._validate_overlap when overlap_wh is greater than or equal to slice_wh in either dimension. Slice offsets advance by (slice_wh - overlap_wh) per tile; if overlap meets or exceeds the slice size the stride is zero or negative, which would produce an infinite or degenerate tiling, so it is rejected.","triggerScenarios":"Passing overlap_wh=(640, 640) with slice_wh=(640, 640); any configuration where overlap_w >= slice_w or overlap_h >= slice_h, e.g. copying the slice size into the overlap parameter or a ratio/target-size mix-up.","commonSituations":"Setting overlap equal to slice size expecting 'maximum coverage'; config templates where the same number is pasted into both fields; computing overlap as a percentage of the image but sized in slice pixels.","solutions":["Choose overlap strictly smaller than the slice in both dimensions, e.g. slice_wh=(512, 512), overlap_wh=(128, 128) — 20-25% of the slice is a common starting point.","If you intended full-image inference without tiling, do not use InferenceSlicer — call the callback on the whole image.","Add a config assertion: assert 0 <= overlap_w < slice_w and 0 <= overlap_h < slice_h."],"exampleFix":"# before\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=640, overlap_wh=640)  # ValueError\n\n# after\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=640, overlap_wh=128)","handlingStrategy":"validation","validationCode":"assert 0 <= overlap_w < slice_w and 0 <= overlap_h < slice_h, 'overlap must be < slice in both axes'\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=(slice_w, slice_h), overlap_wh=(overlap_w, overlap_h))","typeGuard":"def is_valid_overlap_vs_slice(slice_wh, overlap_wh) -> bool:\n    (sw, sh), (ow, oh) = slice_wh, overlap_wh\n    return 0 <= ow < sw and 0 <= oh < sh","tryCatchPattern":null,"preventionTips":["Start from overlap = ~20-25% of the slice size and adjust.","Add a config-time assertion that overlap is strictly below slice size in both dimensions."],"tags":["inference-slicer","overlap","tiling","validation","valueerror"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}