From e0fb6e15bb8b8b9d3f1420c02069a973e9f59cc4 Mon Sep 17 00:00:00 2001 From: ueta-eisuke Date: Fri, 27 Aug 2021 18:49:54 +0900 Subject: [PATCH] fix hollowed points --- fastlabel/__init__.py | 9 ++++++--- fastlabel/converters.py | 6 +++--- setup.py | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 80e75c7..17cbb57 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -756,11 +756,14 @@ def __export_index_color_image(self, task: list, output_dir: str, pallete: List[ color = index if is_instance_segmentation else classes.index(annotation["value"]) + 1 if annotation["type"] == AnnotationType.segmentation.value: for region in annotation["points"]: + count = 0 for points in region: cv_draw_points = self.__get_cv_draw_points(points) - cv2.fillPoly(image, [cv_draw_points], color, lineType=cv2.LINE_8, shift=0) - # hollowd points are not supported - break + if count == 0: + cv2.fillPoly(image, [cv_draw_points], color, lineType=cv2.LINE_8, shift=0) + else: + cv2.fillPoly(image, [cv_draw_points], 0, lineType=cv2.LINE_8, shift=0) + count += 1 elif annotation["type"] == AnnotationType.polygon.value: cv_draw_points = self.__get_cv_draw_points(annotation["points"]) cv2.fillPoly(image, [cv_draw_points], color, lineType=cv2.LINE_8, shift=0) diff --git a/fastlabel/converters.py b/fastlabel/converters.py index ec07d6d..ed56ae6 100644 --- a/fastlabel/converters.py +++ b/fastlabel/converters.py @@ -304,16 +304,16 @@ def to_pixel_coordinates(tasks: list) -> list: # Remove duplicate points for task in tasks: - for anno in task["annotations"]: + for annotation in task["annotations"]: if annotation["type"] == AnnotationType.segmentation.value: new_regions = [] - for region in anno["points"]: + for region in annotation["points"]: new_region = [] for points in region: new_points = __remove_duplicated_coordinates(points) new_region.append(new_points) new_regions.append(new_region) - anno["points"] = new_regions + annotation["points"] = new_regions elif annotation["type"] == AnnotationType.polygon.value: new_points = __remove_duplicated_coordinates(annotation["points"]) annotation["points"] = new_points diff --git a/setup.py b/setup.py index eb3727d..1beaa53 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="fastlabel", - version="0.11.0", + version="0.11.1", author="eisuke-ueta", author_email="eisuke.ueta@fastlabel.ai", description="The official Python SDK for FastLabel API, the Data Platform for AI",