cast masks to bool only when creating a Detection obj

This commit is contained in:
kirilllzaitsev
2023-07-31 13:15:40 +02:00
parent 77c2afe559
commit 9462a3058d
2 changed files with 1 additions and 3 deletions
+1 -2
View File
@@ -242,14 +242,13 @@ def detections_from_xml_obj(
)
if with_masks:
annotation = Detections(xyxy=xyxy, mask=np.array(masks), class_id=class_id)
annotation = Detections(xyxy=xyxy, mask=np.array(masks).astype(bool), class_id=class_id)
else:
annotation = Detections(xyxy=xyxy, class_id=class_id)
return annotation, extended_classes
def parse_polygon_points(polygon: Element) -> List[List[int]]:
# Parses polygon points in format: <polygon><x1>...</x1><y1>...</y1><x2>...</x2><y2>...</y2>...</polygon>
polygon_points = []
coords = polygon.findall(".//*")
for i in range(0, len(coords), 2):
-1
View File
@@ -19,7 +19,6 @@ def polygon_to_mask(polygon: np.ndarray, resolution_wh: Tuple[int, int]) -> np.n
width, height = resolution_wh
mask = np.zeros((height, width))
cv2.fillPoly(mask, [polygon], color=1)
mask = mask.astype(bool)
return mask