Skip to content

Commit

Permalink
Segmentation polygons2masks_overlap() in np.int32 (#9493)
Browse files Browse the repository at this point in the history
* Segmentation `polygons2masks_overlap()` in `np.int32`

May resolve #9461

WARNING: Masks should be uint8 for fastest speed, change needs profiling results to determine impact.

@AyushExel @Laughing-q 

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update dataloaders.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
glenn-jocher and pre-commit-ci[bot] committed Sep 20, 2022
1 parent 63368e7 commit 095f601
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/segment/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ def polygons2masks(img_size, polygons, color, downsample_ratio=1):

def polygons2masks_overlap(img_size, segments, downsample_ratio=1):
"""Return a (640, 640) overlap mask."""
masks = np.zeros((img_size[0] // downsample_ratio, img_size[1] // downsample_ratio), dtype=np.uint8)
masks = np.zeros((img_size[0] // downsample_ratio, img_size[1] // downsample_ratio),
dtype=np.int32 if len(segments) > 255 else np.uint8)
areas = []
ms = []
for si in range(len(segments)):
Expand Down

0 comments on commit 095f601

Please sign in to comment.