{"record":{"id":"ebb819808ada8cbc","repo":"roboflow/supervision","slug":"slice-wh-must-be-a-positive-integer-received","errorCode":null,"errorMessage":"`slice_wh` must be a positive integer. Received: {slice_wh}","messagePattern":"`slice_wh` must be a positive integer\\. Received: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/tools/inference_slicer.py","lineNumber":648,"sourceCode":"                                \"full-resolution image.\",\n                                category=SupervisionWarnings,\n                                stacklevel=2,\n                            )\n\n        return [\n            move_detections(\n                detections=det, offset=offset[:2], resolution_wh=resolution_wh\n            )\n            for det, offset in zip(detections_in_slices, offsets)\n        ]\n\n    @staticmethod\n    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","sourceCodeStart":630,"sourceCodeEnd":666,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/tools/inference_slicer.py#L630-L666","documentation":"Raised by InferenceSlicer._normalize_slice_wh when slice_wh is an int that is zero or negative. The int form means 'square slices of this pixel size'; a non-positive size cannot tile any image, so construction fails.","triggerScenarios":"Passing slice_wh=0 or a negative int, typically from a computed value (e.g. target_size // scale that floors to 0) or an unset config default of 0.","commonSituations":"Downscaling math that produces 0 for very large divisors; config schemas where 0 is the 'unset' sentinel; CLI defaults leaking through.","solutions":["Pass a positive pixel size, e.g. slice_wh=512.","Guard computed sizes: slice_wh = max(1, computed) — though realistically pick a real tile size like 320-1024.","Validate required config fields at load time instead of relying on constructor failure."],"exampleFix":"# before\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=cfg.get('slice', 0))\n\n# after\nslice_size = cfg.get('slice') or 512\nslicer = sv.InferenceSlicer(callback=cb, slice_size if isinstance(slice_size, tuple) else int(slice_size))","handlingStrategy":"validation","validationCode":"slice_wh = int(cfg.get('slice_wh') or 512)\nassert slice_wh > 0, 'slice_wh must be a positive pixel size'\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=slice_wh)","typeGuard":"def is_positive_int(v) -> bool:\n    return isinstance(v, int) and v > 0","tryCatchPattern":null,"preventionTips":["Do not use 0 as an 'unset' sentinel for tile size — validate required config at load time.","Pick tile sizes from the standard range (320, 512, 640, 1024) matching your model input."],"tags":["inference-slicer","configuration","validation","valueerror"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}