From 72d86ba18024681d10b63c8bfffc9c4f4e7970ff Mon Sep 17 00:00:00 2001 From: Hardik Dava <39372750+hardikdava@users.noreply.github.com> Date: Wed, 24 May 2023 17:27:35 +0200 Subject: [PATCH] Fixing for uneven image size --- supervision/detection/core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 563abfc2..1221cef4 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -193,6 +193,8 @@ class Detections: inference_shape = tuple(yolov8_results.masks.data.shape[1:]) masks = yolov8_results.masks.data.cpu().numpy() # calculate pad and gain + pad = (0, 0) + gain = 0 if inference_shape != orig_shape: gain = min(inference_shape[0] / orig_shape[0], inference_shape[1] / orig_shape[1]) # gain = old / new pad = (inference_shape[1] - orig_shape[1] * gain) / 2, (inference_shape[0] - orig_shape[0] * gain) / 2