|
24 | 24 | _create_grid_layout, |
25 | 25 | _create_label_widget, |
26 | 26 | ) |
27 | | -from deeplabcut.gui.dialogs.config_errors import CONFIG_LOAD_ERRORS |
28 | 27 | from deeplabcut.gui.displays.selected_shuffle_display import SelectedShuffleDisplay |
29 | 28 | from deeplabcut.gui.gui_assets import icon_from_resource |
30 | 29 | from deeplabcut.gui.widgets import ConfigEditor |
@@ -223,36 +222,35 @@ def open_posecfg_editor(self): |
223 | 222 | editor.show() |
224 | 223 |
|
225 | 224 | 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 | | - |
240 | 225 | 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 |
245 | 239 |
|
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) |
250 | 241 |
|
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) |
256 | 254 |
|
257 | 255 | @Slot(dict) |
258 | 256 | def _pose_cfg_change(self, pose_cfg: dict | None) -> None: |
|
0 commit comments