{"record":{"id":"6d78dcb274b90f87","repo":"roboflow/supervision","slug":"slice-wh-values-must-be-positive-received-sli","errorCode":null,"errorMessage":"`slice_wh` values must be positive. Received: {slice_wh}","messagePattern":"`slice_wh` values must be positive\\. Received: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/tools/inference_slicer.py","lineNumber":656,"sourceCode":"            )\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\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. \"","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/tools/inference_slicer.py#L638-L674","documentation":"Raised by InferenceSlicer._normalize_slice_wh when slice_wh is a 2-tuple but one of its components (slice_w or slice_h) is zero or negative. Each component is a pixel size for tiling in its dimension and must be positive.","triggerScenarios":"Passing slice_wh=(512, 0), (0, 0), or negative components; per-axis sizes computed from image dimensions where one axis divides down to 0.","commonSituations":"Aspect-ratio math that produces 0 for one axis (e.g. 2 * h - 2 * h_edge on thin strips); tuple built from two config keys where one is missing and defaults to 0.","solutions":["Make both components positive ints, e.g. slice_wh=(512, 384).","Clamp per-axis computed sizes: (max(1, w), max(1, h)).","Validate config keys individually before building the tuple."],"exampleFix":"# before\nslice_wh = (cfg['slice_w'], cfg.get('slice_h', 0))  # ValueError when slice_h missing\n\n# after\nslice_wh = (int(cfg['slice_w']), int(cfg['slice_h']))","handlingStrategy":"validation","validationCode":"slice_wh = (int(cfg['slice_w']), int(cfg['slice_h']))\nassert slice_wh[0] > 0 and slice_wh[1] > 0, 'both slice components must be positive'\nslicer = sv.InferenceSlicer(callback=cb, slice_wh=slice_wh)","typeGuard":"def is_valid_slice_wh_tuple(v) -> bool:\n    return isinstance(v, tuple) and len(v) == 2 and all(isinstance(x, int) and x > 0 for x in v)","tryCatchPattern":null,"preventionTips":["Make both slice config keys required rather than defaulting to 0.","Clamp per-axis computed sizes with max(1, v)."],"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"}