Skip to content

Commit

Permalink
[Bug fixed] Retain labels during switch model instances (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
CVHub520 committed Aug 21, 2024
1 parent 35f6fde commit 90217a9
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 13 deletions.
6 changes: 4 additions & 2 deletions anylabeling/services/auto_labeling/__base__/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ def __init__(self, model_config, on_message) -> None:

def set_auto_labeling_conf(self, value):
"""set auto labeling confidence threshold"""
self.conf_thres = value
if value > 0:
self.conf_thres = value

def set_auto_labeling_iou(self, value):
"""set auto labeling iou threshold"""
self.iou_thres = value
if value > 0:
self.iou_thres = value

def set_auto_labeling_preserve_existing_annotations_state(self, state):
"""Toggle the preservation of existing annotations based on the checkbox state."""
Expand Down
6 changes: 4 additions & 2 deletions anylabeling/services/auto_labeling/damo_yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ def __init__(self, model_config, on_message) -> None:

def set_auto_labeling_conf(self, value):
"""set auto labeling confidence threshold"""
self.conf_thres = value
if value > 0:
self.conf_thres = value

def set_auto_labeling_iou(self, value):
"""set auto labeling iou threshold"""
self.nms_thres = value
if value > 0:
self.nms_thres = value

def set_auto_labeling_preserve_existing_annotations_state(self, state):
"""Toggle the preservation of existing annotations based on the checkbox state."""
Expand Down
3 changes: 2 additions & 1 deletion anylabeling/services/auto_labeling/grounding_dino.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def __init__(self, model_config, on_message) -> None:

def set_auto_labeling_conf(self, value):
"""set auto labeling box threshold"""
self.box_threshold = value
if value > 0:
self.box_threshold = value

def set_auto_labeling_preserve_existing_annotations_state(self, state):
"""Toggle the preservation of existing annotations based on the checkbox state."""
Expand Down
3 changes: 2 additions & 1 deletion anylabeling/services/auto_labeling/rtdetr.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def __init__(self, model_config, on_message) -> None:

def set_auto_labeling_conf(self, value):
"""set auto labeling confidence threshold"""
self.conf_thres = value
if value > 0:
self.conf_thres = value

def set_auto_labeling_preserve_existing_annotations_state(self, state):
"""Toggle the preservation of existing annotations based on the checkbox state."""
Expand Down
3 changes: 2 additions & 1 deletion anylabeling/services/auto_labeling/rtdetrv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def __init__(self, model_config, on_message) -> None:

def set_auto_labeling_conf(self, value):
"""set auto labeling confidence threshold"""
self.conf_thres = value
if value > 0:
self.conf_thres = value

def set_auto_labeling_preserve_existing_annotations_state(self, state):
"""Toggle the preservation of existing annotations based on the checkbox state."""
Expand Down
6 changes: 4 additions & 2 deletions anylabeling/services/auto_labeling/yolo_nas.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,13 @@ def __init__(self, model_config, on_message) -> None:

def set_auto_labeling_conf(self, value):
"""set auto labeling confidence threshold"""
self.conf_thres = value
if value > 0:
self.conf_thres = value

def set_auto_labeling_iou(self, value):
"""set auto labeling iou threshold"""
self.nms_thres = value
if value > 0:
self.nms_thres = value

def set_auto_labeling_preserve_existing_annotations_state(self, state):
"""Toggle the preservation of existing annotations based on the checkbox state."""
Expand Down
6 changes: 4 additions & 2 deletions anylabeling/services/auto_labeling/yolov5_obb.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ def __init__(self, model_config, on_message) -> None:

def set_auto_labeling_conf(self, value):
"""set auto labeling confidence threshold"""
self.conf_thres = value
if value > 0:
self.conf_thres = value

def set_auto_labeling_iou(self, value):
"""set auto labeling iou threshold"""
self.nms_thres = value
if value > 0:
self.nms_thres = value

def set_auto_labeling_preserve_existing_annotations_state(self, state):
"""Toggle the preservation of existing annotations based on the checkbox state."""
Expand Down
6 changes: 4 additions & 2 deletions anylabeling/services/auto_labeling/yolox.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def __init__(self, model_config, on_message) -> None:

def set_auto_labeling_conf(self, value):
"""set auto labeling confidence threshold"""
self.conf_thres = value
if value > 0:
self.conf_thres = value

def set_auto_labeling_iou(self, value):
"""set auto labeling iou threshold"""
self.nms_thres = value
if value > 0:
self.nms_thres = value

def set_auto_labeling_preserve_existing_annotations_state(self, state):
"""Toggle the preservation of existing annotations based on the checkbox state."""
Expand Down
14 changes: 14 additions & 0 deletions anylabeling/views/labeling/widgets/auto_labeling/auto_labeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ def set_enable_tools(enable):
lambda: set_enable_tools(True)
)

# Init value
self.initial_conf_value = 0
self.initial_iou_value = 0
self.initial_preserve_annotations_state = False

# Auto labeling buttons
self.button_run.setShortcut("I")
self.button_run.clicked.connect(self.run_prediction)
Expand Down Expand Up @@ -226,6 +231,12 @@ def on_new_model_loaded(self, model_config):
)
self.model_select_combobox.setEnabled(True)

# Reset controls to initial values when the model changes
self.on_conf_value_changed(self.initial_conf_value)
self.on_iou_value_changed(self.initial_iou_value)
self.on_preserve_existing_annotations_state_changed(self.initial_preserve_annotations_state)
self.on_reset_tracker()

def on_output_modes_changed(self, output_modes, default_output_mode):
"""Handle output modes changed"""
# Disconnect onIndexChanged signal to prevent triggering
Expand Down Expand Up @@ -322,12 +333,15 @@ def on_close(self):
return True

def on_conf_value_changed(self, value):
self.initial_conf_value = value
self.model_manager.set_auto_labeling_conf(value)

def on_iou_value_changed(self, value):
self.initial_iou_value = value
self.model_manager.set_auto_labeling_iou(value)

def on_preserve_existing_annotations_state_changed(self, state):
self.initial_preserve_annotations_state = state
self.model_manager.set_auto_labeling_preserve_existing_annotations_state(
state
)
Expand Down

0 comments on commit 90217a9

Please sign in to comment.