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

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/16696/head^2
Rajesh Timilsina 2 months ago committed by GitHub
parent 0b861816c7
commit 4073fa0b87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ultralytics/data/utils.py

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

Loading…
Cancel
Save