Skip to content

Commit

Permalink
Add catch for no label image present (Closes #52)
Browse files Browse the repository at this point in the history
  • Loading branch information
jluethi committed Sep 16, 2024
1 parent cd7e017 commit 6981f2b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/napari_feature_classifier/classifier_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def __init__(
self._last_selected_label_layer = get_selected_or_valid_label_layer(
viewer=self._viewer
)

# Initialize the classifier
if classifier:
self._classifier = classifier
Expand Down Expand Up @@ -659,12 +660,19 @@ def load(self):
with open(clf_path, "rb") as f: # pylint: disable=C0103
clf = pickle.load(f)

self._run_container = ClassifierRunContainer(
self._viewer,
clf,
classifier_save_path=clf_path,
auto_save=True,
)
try:
self._run_container = ClassifierRunContainer(
self._viewer,
clf,
classifier_save_path=clf_path,
auto_save=True,
)
except NotImplementedError:
napari_info(
"Create a label layer with a feature dataframe before loading "
"the classifier"
)
return
self.clear()
self.append(self._run_container)

Expand Down

0 comments on commit 6981f2b

Please sign in to comment.