Skip to content

Commit bc525e3

Browse files
committed
Fix color inconsistency between Labels and Objects
1 parent 5982eae commit bc525e3

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

anylabeling/app_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__appname__ = "AnyLabeling"
22
__appdescription__ = "Effortless data labeling with AI support"
3-
__version__ = "0.4.24"
3+
__version__ = "0.4.25"
44
__preferred_device__ = "CPU" # GPU or CPU

anylabeling/views/labeling/label_widget.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,12 @@ def add_label(self, shape):
16291629
text = f"{shape.label} ({shape.group_id})"
16301630
label_list_item = LabelListWidgetItem(text, shape)
16311631
self.label_list.add_iem(label_list_item)
1632-
if not self.unique_label_list.find_items_by_label(shape.label):
1632+
# Don't add special autolabeling labels to the unique_label_list
1633+
if shape.label not in [
1634+
AutoLabelingMode.OBJECT,
1635+
AutoLabelingMode.ADD,
1636+
AutoLabelingMode.REMOVE,
1637+
] and not self.unique_label_list.find_items_by_label(shape.label):
16331638
item = self.unique_label_list.create_item_from_label(shape.label)
16341639
self.unique_label_list.addItem(item)
16351640
rgb = self._get_rgb_by_label(shape.label)
@@ -1674,6 +1679,19 @@ def _update_shape_color(self, shape):
16741679

16751680
def _get_rgb_by_label(self, label):
16761681
if self._config["shape_color"] == "auto":
1682+
# For special autolabeling labels, use fixed colors
1683+
if label in [
1684+
AutoLabelingMode.OBJECT,
1685+
AutoLabelingMode.ADD,
1686+
AutoLabelingMode.REMOVE,
1687+
]:
1688+
if label == AutoLabelingMode.OBJECT:
1689+
return (0, 255, 255) # Cyan color for object
1690+
elif label == AutoLabelingMode.ADD:
1691+
return (0, 255, 0) # Green color for add
1692+
elif label == AutoLabelingMode.REMOVE:
1693+
return (255, 0, 0) # Red color for remove
1694+
16771695
if not self.unique_label_list.find_items_by_label(label):
16781696
item = self.unique_label_list.create_item_from_label(label)
16791697
self.unique_label_list.addItem(item)

0 commit comments

Comments
 (0)