Visitar URL original
widen train_network error handling, similar to 4472fd3fb7fed3c8eb55ac… · DeepLabCut/DeepLabCut@ddce16f · GitHub
Skip to content

Commit ddce16f

Browse files
committed
widen train_network error handling, similar to 4472fd3
1 parent 489b39a commit ddce16f

1 file changed

Lines changed: 26 additions & 28 deletions

File tree

‎deeplabcut/gui/tabs/train_network.py‎

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
_create_grid_layout,
2525
_create_label_widget,
2626
)
27-
from deeplabcut.gui.dialogs.config_errors import CONFIG_LOAD_ERRORS
2827
from deeplabcut.gui.displays.selected_shuffle_display import SelectedShuffleDisplay
2928
from deeplabcut.gui.gui_assets import icon_from_resource
3029
from deeplabcut.gui.widgets import ConfigEditor
@@ -223,36 +222,35 @@ def open_posecfg_editor(self):
223222
editor.show()
224223

225224
def train_network(self):
226-
config_path = self.root.config_path
227-
shuffle = int(self._shuffle.value())
228-
229-
kwargs = dict(gputouse=None, autotune=False)
230-
for k, spin_box in self._attribute_kwargs[self.root.engine].items():
231-
kwargs[k] = int(spin_box.value())
232-
if self.root.engine == Engine.PYTORCH:
233-
snapshot_to_start_training_from = self.snapshot_selection_widget.selected_snapshot
234-
if snapshot_to_start_training_from is not None:
235-
kwargs["snapshot_path"] = snapshot_to_start_training_from
236-
detector_to_start_training_from = self.detector_snapshot_selection_widget.selected_snapshot
237-
if detector_to_start_training_from is not None:
238-
kwargs["detector_path"] = detector_to_start_training_from
239-
240225
try:
241-
compat.train_network(config_path, shuffle, **kwargs)
242-
except CONFIG_LOAD_ERRORS as error:
243-
self.root.show_task_error(error, self.root.pose_cfg_path)
244-
return
226+
config_path = self.root.config_path
227+
shuffle = int(self._shuffle.value())
228+
229+
kwargs = dict(gputouse=None, autotune=False)
230+
for k, spin_box in self._attribute_kwargs[self.root.engine].items():
231+
kwargs[k] = int(spin_box.value())
232+
if self.root.engine == Engine.PYTORCH:
233+
snapshot_to_start_training_from = self.snapshot_selection_widget.selected_snapshot
234+
if snapshot_to_start_training_from is not None:
235+
kwargs["snapshot_path"] = snapshot_to_start_training_from
236+
detector_to_start_training_from = self.detector_snapshot_selection_widget.selected_snapshot
237+
if detector_to_start_training_from is not None:
238+
kwargs["detector_path"] = detector_to_start_training_from
245239

246-
msg = QtWidgets.QMessageBox()
247-
msg.setIcon(QtWidgets.QMessageBox.Information)
248-
msg.setText("The network is now trained and ready to evaluate.")
249-
msg.setInformativeText("Use the function 'evaluate_network' to evaluate the network.")
240+
compat.train_network(config_path, shuffle, **kwargs)
250241

251-
msg.setWindowTitle("Info")
252-
msg.setMinimumWidth(900)
253-
msg.setWindowIcon(icon_from_resource("logo.png"))
254-
msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
255-
msg.exec_()
242+
msg = QtWidgets.QMessageBox()
243+
msg.setIcon(QtWidgets.QMessageBox.Information)
244+
msg.setText("The network is now trained and ready to evaluate.")
245+
msg.setInformativeText("Use the function 'evaluate_network' to evaluate the network.")
246+
247+
msg.setWindowTitle("Info")
248+
msg.setMinimumWidth(900)
249+
msg.setWindowIcon(icon_from_resource("logo.png"))
250+
msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
251+
msg.exec_()
252+
except Exception as error:
253+
self.root.show_task_error(error, self.root.pose_cfg_path)
256254

257255
@Slot(dict)
258256
def _pose_cfg_change(self, pose_cfg: dict | None) -> None:

0 commit comments

Comments
 (0)