From a42f7eae10fd9bd2847ab02666ed625830e71c3a Mon Sep 17 00:00:00 2001 From: isalia20 Date: Wed, 28 Aug 2024 00:40:56 +0400 Subject: [PATCH 1/2] inplace draw convex polygon --- kornia/utils/draw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kornia/utils/draw.py b/kornia/utils/draw.py index abaff6e0a1..9d7d7c1a74 100644 --- a/kornia/utils/draw.py +++ b/kornia/utils/draw.py @@ -351,5 +351,5 @@ def draw_convex_polygon(images: Tensor, polygons: Union[Tensor, List[Tensor]], c x_left, x_right = _get_convex_edges(polygons, h_i, w_i) ws = torch.arange(w_i, device=device, dtype=dtype_p)[None, None, :] fill_region = (ws >= x_left[..., :, None]) & (ws <= x_right[..., :, None]) - images = (~fill_region[:, None]) * images + fill_region[:, None] * colors[..., None, None] + images.mul_((~fill_region[:, None])).add_(fill_region[:, None] * colors[..., None, None]) return images From 0219d731ff13d4c99c62a7fa330c6aaa8144b597 Mon Sep 17 00:00:00 2001 From: isalia20 Date: Wed, 28 Aug 2024 00:43:33 +0400 Subject: [PATCH 2/2] linter --- kornia/utils/draw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kornia/utils/draw.py b/kornia/utils/draw.py index 9d7d7c1a74..6ad6b06716 100644 --- a/kornia/utils/draw.py +++ b/kornia/utils/draw.py @@ -351,5 +351,5 @@ def draw_convex_polygon(images: Tensor, polygons: Union[Tensor, List[Tensor]], c x_left, x_right = _get_convex_edges(polygons, h_i, w_i) ws = torch.arange(w_i, device=device, dtype=dtype_p)[None, None, :] fill_region = (ws >= x_left[..., :, None]) & (ws <= x_right[..., :, None]) - images.mul_((~fill_region[:, None])).add_(fill_region[:, None] * colors[..., None, None]) + images.mul_(~fill_region[:, None]).add_(fill_region[:, None] * colors[..., None, None]) return images