From 44e4eeaa69ad9524826187850ae2d508e537f3dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 22:33:32 +0000 Subject: [PATCH] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20form?= =?UTF-8?q?at=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/__init__.py | 2 +- supervision/annotators/core.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/supervision/__init__.py b/supervision/__init__.py index 4c2d3dd1..075c7e97 100644 --- a/supervision/__init__.py +++ b/supervision/__init__.py @@ -12,10 +12,10 @@ from supervision.annotators.core import ( BoxCornerAnnotator, CircleAnnotator, EllipseAnnotator, + HaloAnnotator, LabelAnnotator, MaskAnnotator, TraceAnnotator, - HaloAnnotator, ) from supervision.classification.core import Classifications from supervision.dataset.core import ( diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 815b52c6..a0e2da26 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -157,6 +157,7 @@ class MaskAnnotator(BaseAnnotator): ) return scene + class HaloAnnotator(BaseAnnotator): """ A class for drawing Halos on an image using provided detections. @@ -165,7 +166,7 @@ class HaloAnnotator(BaseAnnotator): def __init__( self, color: Union[Color, ColorPalette] = ColorPalette.default(), - opacity: float = .8, + opacity: float = 0.8, color_map: str = "class", ): """ @@ -211,10 +212,9 @@ class HaloAnnotator(BaseAnnotator): if detections.mask is None: return scene colored_mask = np.zeros_like(scene, dtype=np.uint8) - fmask = np.array( - [False]*scene.shape[0]*scene.shape[1] - ).reshape(scene.shape[0],scene.shape[1]) - + fmask = np.array([False] * scene.shape[0] * scene.shape[1]).reshape( + scene.shape[0], scene.shape[1] + ) for detection_idx in np.flip(np.argsort(detections.area)): idx = resolve_color_idx( @@ -224,19 +224,19 @@ class HaloAnnotator(BaseAnnotator): ) color = resolve_color(color=self.color, idx=idx) mask = detections.mask[detection_idx] - fmask = np.logical_or(fmask,mask) + fmask = np.logical_or(fmask, mask) color_bgr = color.as_bgr() colored_mask[mask] = color_bgr - colored_mask = cv2.blur(colored_mask,(20,20)) - colored_mask[fmask] = [0,0,0] + colored_mask = cv2.blur(colored_mask, (20, 20)) + colored_mask[fmask] = [0, 0, 0] gray = cv2.cvtColor(colored_mask, cv2.COLOR_BGR2GRAY) _, tresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY) - mask = tresh>0 + mask = tresh > 0 scene[mask] = cv2.addWeighted(colored_mask, self.opacity, scene, 1, 0)[mask] - return scene + class EllipseAnnotator(BaseAnnotator): """ A class for drawing ellipses on an image using provided detections.