From f841e6c1d19f5010214a444c2877308d21bc64e9 Mon Sep 17 00:00:00 2001 From: Irakli Salia <65120973+Isalia20@users.noreply.github.com> Date: Wed, 28 Aug 2024 19:10:09 +0400 Subject: [PATCH] Inplace draw convex polygon (#3000) * inplace draw convex polygon * 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 abaff6e0a1..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 = (~fill_region[:, None]) * images + fill_region[:, None] * colors[..., None, None] + images.mul_(~fill_region[:, None]).add_(fill_region[:, None] * colors[..., None, None]) return images