Skip to content

Commit 9243e28

Browse files
Merge pull request #149 from fastlabel/export_semantic_fix_classes
セグメンテーション画像出力のclassesデフォルト引数に追加しないように修正
2 parents 68846b8 + d820dc1 commit 9243e28

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

fastlabel/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,12 +2517,16 @@ def export_semantic_segmentation(
25172517
When start_index is 0, all pixels are assumed to have annotations
25182518
because they become the same color as the background(Optional).
25192519
"""
2520-
if len(classes) == 0:
2520+
2521+
# Copy classes to target_classes
2522+
# so that it is not added as a default argument.
2523+
target_classes = classes.copy()
2524+
if len(target_classes) == 0:
25212525
for task in tasks:
25222526
for annotation in task["annotations"]:
2523-
classes.append(annotation["value"])
2524-
classes = list(set(classes))
2525-
classes.sort()
2527+
target_classes.append(annotation["value"])
2528+
target_classes = list(set(target_classes))
2529+
target_classes.sort()
25262530

25272531
tasks = converters.to_pixel_coordinates(tasks)
25282532
for task in tasks:
@@ -2531,7 +2535,7 @@ def export_semantic_segmentation(
25312535
output_dir=output_dir,
25322536
pallete=pallete,
25332537
is_instance_segmentation=False,
2534-
classes=classes,
2538+
classes=target_classes,
25352539
start_index=start_index,
25362540
)
25372541

0 commit comments

Comments
 (0)