From 7bf9dea66206208e6cb8c4fa6d04a54f42c379c6 Mon Sep 17 00:00:00 2001 From: Grzegorz Klimaszewski <166530809+grzegorz-roboflow@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:49:41 +0100 Subject: [PATCH 1/2] When running bounding_rect update mask and xyxy of source sv.Detections so results can be visualized --- .../core_steps/transformations/bounding_rect/v1.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inference/core/workflows/core_steps/transformations/bounding_rect/v1.py b/inference/core/workflows/core_steps/transformations/bounding_rect/v1.py index a75b5d700..2be90bdf6 100644 --- a/inference/core/workflows/core_steps/transformations/bounding_rect/v1.py +++ b/inference/core/workflows/core_steps/transformations/bounding_rect/v1.py @@ -111,6 +111,18 @@ def run( det.mask[0] ) + det.mask = np.array( + [ + sv.polygon_to_mask( + polygon=np.around(rect).astype(np.int32), + resolution_wh=det.mask[0].shape, + ).astype(bool) + ] + ) + det.xyxy = np.array( + [sv.polygon_to_xyxy(polygon=np.around(rect).astype(np.int32))] + ) + det[BOUNDING_RECT_RECT_KEY_IN_SV_DETECTIONS] = np.array( [rect], dtype=np.float16 ) From 5dca01c4bfc9a4c36515d5762e587f3992a96eb5 Mon Sep 17 00:00:00 2001 From: Grzegorz Klimaszewski <166530809+grzegorz-roboflow@users.noreply.github.com> Date: Wed, 29 Jan 2025 11:36:48 +0100 Subject: [PATCH 2/2] Fix test --- .../workflows/core_steps/transformations/bounding_rect/v1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference/core/workflows/core_steps/transformations/bounding_rect/v1.py b/inference/core/workflows/core_steps/transformations/bounding_rect/v1.py index 2be90bdf6..8c0b56b61 100644 --- a/inference/core/workflows/core_steps/transformations/bounding_rect/v1.py +++ b/inference/core/workflows/core_steps/transformations/bounding_rect/v1.py @@ -115,7 +115,7 @@ def run( [ sv.polygon_to_mask( polygon=np.around(rect).astype(np.int32), - resolution_wh=det.mask[0].shape, + resolution_wh=(det.mask[0].shape[1], det.mask[0].shape[0]), ).astype(bool) ] )