Skip to content

Commit 6981f2b

Browse files
committed
Add catch for no label image present (Closes #52)
1 parent cd7e017 commit 6981f2b

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/napari_feature_classifier/classifier_widget.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ def __init__(
223223
self._last_selected_label_layer = get_selected_or_valid_label_layer(
224224
viewer=self._viewer
225225
)
226+
226227
# Initialize the classifier
227228
if classifier:
228229
self._classifier = classifier
@@ -659,12 +660,19 @@ def load(self):
659660
with open(clf_path, "rb") as f: # pylint: disable=C0103
660661
clf = pickle.load(f)
661662

662-
self._run_container = ClassifierRunContainer(
663-
self._viewer,
664-
clf,
665-
classifier_save_path=clf_path,
666-
auto_save=True,
667-
)
663+
try:
664+
self._run_container = ClassifierRunContainer(
665+
self._viewer,
666+
clf,
667+
classifier_save_path=clf_path,
668+
auto_save=True,
669+
)
670+
except NotImplementedError:
671+
napari_info(
672+
"Create a label layer with a feature dataframe before loading "
673+
"the classifier"
674+
)
675+
return
668676
self.clear()
669677
self.append(self._run_container)
670678

0 commit comments

Comments
 (0)