From ee5391158a448e206f5d94d198afa3fe1cbf8aed Mon Sep 17 00:00:00 2001 From: Akkiy3314 Date: Thu, 20 Apr 2023 12:54:55 +0900 Subject: [PATCH 1/4] fix not add default classes --- fastlabel/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index c10aaf6..ee7850e 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -2517,12 +2517,15 @@ def export_semantic_segmentation( When start_index is 0, all pixels are assumed to have annotations because they become the same color as the background(Optional). """ + + # Create target_classes they are not added to the default arguments. + target_classes = classes if len(classes) == 0: for task in tasks: for annotation in task["annotations"]: - classes.append(annotation["value"]) - classes = list(set(classes)) - classes.sort() + target_classes.append(annotation["value"]) + target_classes = list(set(target_classes)) + target_classes.sort() tasks = converters.to_pixel_coordinates(tasks) for task in tasks: @@ -2531,7 +2534,7 @@ def export_semantic_segmentation( output_dir=output_dir, pallete=pallete, is_instance_segmentation=False, - classes=classes, + classes=target_classes, start_index=start_index, ) From ed5fc4e7f2c120bf929824e32c1289b650a8ed33 Mon Sep 17 00:00:00 2001 From: Akkiy3314 Date: Thu, 20 Apr 2023 13:00:05 +0900 Subject: [PATCH 2/4] fix length value --- fastlabel/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index ee7850e..7a061f6 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -2520,7 +2520,7 @@ def export_semantic_segmentation( # Create target_classes they are not added to the default arguments. target_classes = classes - if len(classes) == 0: + if len(target_classes) == 0: for task in tasks: for annotation in task["annotations"]: target_classes.append(annotation["value"]) From 948cda6a9f213aae9c47d568435d91ff8634fe22 Mon Sep 17 00:00:00 2001 From: Akkiy3314 Date: Thu, 20 Apr 2023 13:20:36 +0900 Subject: [PATCH 3/4] fix pointer list --- fastlabel/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 7a061f6..25764eb 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -2519,13 +2519,15 @@ def export_semantic_segmentation( """ # Create target_classes they are not added to the default arguments. - target_classes = classes - if len(target_classes) == 0: + target_classes = [] + if len(classes) == 0: for task in tasks: for annotation in task["annotations"]: target_classes.append(annotation["value"]) target_classes = list(set(target_classes)) target_classes.sort() + else: + target_classes.extend(classes) tasks = converters.to_pixel_coordinates(tasks) for task in tasks: From d820dc1f3f2bdbb154af88f8e3c9f29870a77df9 Mon Sep 17 00:00:00 2001 From: Akkiy3314 Date: Thu, 20 Apr 2023 13:51:09 +0900 Subject: [PATCH 4/4] fix classes copy --- fastlabel/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 25764eb..8f2e4cc 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -2518,16 +2518,15 @@ def export_semantic_segmentation( because they become the same color as the background(Optional). """ - # Create target_classes they are not added to the default arguments. - target_classes = [] - if len(classes) == 0: + # Copy classes to target_classes + # so that it is not added as a default argument. + target_classes = classes.copy() + if len(target_classes) == 0: for task in tasks: for annotation in task["annotations"]: target_classes.append(annotation["value"]) target_classes = list(set(target_classes)) target_classes.sort() - else: - target_classes.extend(classes) tasks = converters.to_pixel_coordinates(tasks) for task in tasks: