sleap.gui.learning.configs

Find, load, and show lists of saved TrainingJobConfig.

class sleap.gui.learning.configs.ConfigFileInfo(config: sleap.nn.config.training_job.TrainingJobConfig, path: Optional[str] = None, filename: Optional[str] = None, head_name: Optional[str] = None, dont_retrain: bool = False, skeleton: Optional[sleap.skeleton.Skeleton] = None, tried_finding_skeleton: bool = False, dset_len_cache: dict = NOTHING)[source]

Object to represent a saved TrainingJobConfig

The TrainingJobConfig class holds information about the model and can be saved as a file. This class holds information about that file, e.g., the path, and also provides some properties/methods that make it easier to access certain data in or about the file.

config

the TrainingJobConfig

path

path to the TrainingJobConfig

filename

just the filename, not the full path

head_name

string which should match name of model.heads key

dont_retrain

allows us to keep track of whether we should retrain this config

property timestamp

Timestamp on file; parsed from filename (not OS timestamp).

property training_frame_count

Number of labeled frames in the training dataset

property training_instance_count

Number of instances in the training dataset

property validation_frame_count

Number of labeled frames in the validation dataset

property validation_instance_count

Number of instances in the validation dataset

class sleap.gui.learning.configs.TrainingConfigFilesWidget(cfg_getter: sleap.gui.learning.configs.TrainingConfigsGetter, head_name: str, require_trained: bool = False, *args, **kwargs)[source]

Widget to show list of saved TrainingJobConfig files.

This is used inside TrainingEditorWidget.

Parameters
  • cfg_getter – the TrainingConfigsGetter from which menu is populated.

  • head_name – used to filter configs from cfg_getter.

  • require_trained – used to filter configs from cfg_getter.

Signals:

onConfigSelection: triggered when user selects a config file

doFileSelection()[source]

Shows file browser to add training profile for given model type.

getConfigInfoByMenuIdx(menu_idx: int) → Optional[sleap.gui.learning.configs.ConfigFileInfo][source]

Return ConfigFileInfo for menu item index.

getSelectedConfigInfo() → Optional[sleap.gui.learning.configs.ConfigFileInfo][source]

Return currently selected ConfigFileInfo (if any, None otherwise).

onSelectionIdxChange(menu_idx: int)[source]

Handler for when user selects a menu item.

Either allows selection of config using file browser, or emits onConfigSelection signal for selected config.

setUserConfigData(cfg_data_dict: Dict[str, Any])[source]

Sets the user config option from settings made by user.

update(select: Optional[sleap.gui.learning.configs.ConfigFileInfo] = None)[source]

Updates menu options, optionally selecting a specific config.

class sleap.gui.learning.configs.TrainingConfigsGetter(dir_paths: List[str], head_filter: Optional[str] = None, search_depth: int = 1, configs: List[sleap.gui.learning.configs.ConfigFileInfo] = NOTHING)[source]

Searches for and loads TrainingJobConfig files.

dir_paths

List of paths in which to search for TrainingJobConfig files.

head_filter

Name of head type to use when filtering, e.g., “centered_instance”.

search_depth

How many subdirectories deep to search for config files.

find_configs() → List[sleap.gui.learning.configs.ConfigFileInfo][source]

Load configs from all saved paths.

find_configs_in_dir(dir: str, depth: int = 1) → List[sleap.gui.learning.configs.ConfigFileInfo][source]

Loads configs in specified directory.

get_filtered_configs(head_filter: str = '', only_trained: bool = False) → List[sleap.gui.learning.configs.ConfigFileInfo][source]

Returns filtered subset of loaded configs.

get_first() → Optional[sleap.gui.learning.configs.ConfigFileInfo][source]

Get first loaded config.

insert_first(cfg_info: sleap.gui.learning.configs.ConfigFileInfo)[source]

Insert config at beginning of list.

insert_last(cfg_info: sleap.gui.learning.configs.ConfigFileInfo)[source]

Insert config at end of list.

classmethod make_from_labels_filename(labels_filename: str, head_filter: Optional[str] = None)sleap.gui.learning.configs.TrainingConfigsGetter[source]

Makes object which checks for models in default subdir for dataset.

try_loading_path(path: str) → Optional[sleap.gui.learning.configs.ConfigFileInfo][source]

Attempts to load config file and wrap in ConfigFileInfo object.

update()[source]

Re-searches paths and loads any previously unloaded config files.