Fix UINT8 overflow for >255 segmentation masks (#16690)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Rajesh Timilsina 2024-10-04 19:01:48 -04:00 committed by GitHub
parent 0b861816c7
commit 4073fa0b87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -216,7 +216,7 @@ def polygons2masks_overlap(imgsz, segments, downsample_ratio=1):
ms = []
for si in range(len(segments)):
mask = polygon2mask(imgsz, [segments[si].reshape(-1)], downsample_ratio=downsample_ratio, color=1)
ms.append(mask)
ms.append(mask.astype(masks.dtype))
areas.append(mask.sum())
areas = np.asarray(areas)
index = np.argsort(-areas)