sleap.gui.learning.runners¶
Run training/inference in background process via CLI.
-
class
sleap.gui.learning.runners.
DatasetItemForInference
(labels_path: str, frame_filter: str = 'user', use_absolute_path: bool = False)[source]¶ Encapsulate data about frame selection based on dataset data.
-
labels_path
¶ path to the saved
Labels
dataset.
-
frame_filter
¶ which subset of frames to get from dataset, supports * “user” * “suggested”
-
use_absolute_path
¶ whether to use absolute path for inference cli call.
-
-
class
sleap.gui.learning.runners.
InferenceTask
(trained_job_paths: List[str], inference_params: Dict[str, Any] = NOTHING, labels: Optional[sleap.io.dataset.Labels] = None, labels_filename: Optional[str] = None, results: List[sleap.instance.LabeledFrame] = NOTHING)[source]¶ Encapsulates all data needed for running inference via CLI.
-
make_predict_cli_call
(item_for_inference: sleap.gui.learning.runners.ItemForInference, output_path: Optional[str] = None) → List[str][source]¶ Makes list of CLI arguments needed for running inference.
-
predict_subprocess
(item_for_inference: sleap.gui.learning.runners.ItemForInference, append_results: bool = False, waiting_callback: Optional[Callable] = None) → Tuple[str, bool][source]¶ Runs inference in a subprocess.
-
-
class
sleap.gui.learning.runners.
ItemForInference
[source]¶ Abstract base class for item on which we can run inference via CLI.
Must have path and cli_args properties, used to build CLI call.
-
class
sleap.gui.learning.runners.
ItemsForInference
(items: List[sleap.gui.learning.runners.ItemForInference], total_frame_count: int)[source]¶ Encapsulates list of items for inference.
-
class
sleap.gui.learning.runners.
VideoItemForInference
(video: sleap.io.video.Video, frames: Optional[List[int]] = None, use_absolute_path: bool = False)[source]¶ Encapsulate data about video on which inference should run.
This allows for inference on an arbitrary list of frames from video.
-
video
¶ the
Video
object (which already stores its own path)
-
frames
¶ list of frames for inference; if None, then all frames are used
-
use_absolute_path
¶ whether to use absolute path for inference cli call
-
-
sleap.gui.learning.runners.
run_gui_inference
(inference_task: sleap.gui.learning.runners.InferenceTask, items_for_inference: sleap.gui.learning.runners.ItemsForInference, gui: bool = True) → int[source]¶ Run inference on specified frames using models from training_jobs.
- Parameters
inference_task – Encapsulates information needed for running inference, such as labels dataset and models.
items_for_inference – Encapsulates information about the videos (etc.) on which we’re running inference.
gui – Whether to show gui windows and process gui events.
- Returns
Number of new frames added to labels.
-
sleap.gui.learning.runners.
run_gui_training
(labels_filename: str, labels: sleap.io.dataset.Labels, config_info_list: List[sleap.gui.learning.configs.ConfigFileInfo], gui: bool = True, save_viz: bool = False) → Dict[str, str][source]¶ Runs training for each training job.
- Parameters
labels – Labels object from which we’ll get training data.
config_info_list – List of ConfigFileInfo with configs for training.
gui – Whether to show gui windows and process gui events.
save_viz – Whether to save visualizations from training.
- Returns
Dictionary, keys are head name, values are path to trained config.
-
sleap.gui.learning.runners.
run_learning_pipeline
(labels_filename: str, labels: sleap.io.dataset.Labels, config_info_list: List[sleap.gui.learning.configs.ConfigFileInfo], inference_params: Dict[str, Any], items_for_inference: sleap.gui.learning.runners.ItemsForInference) → int[source]¶ Runs training (as needed) and inference.
- Parameters
labels_filename – Path to already saved current labels object.
labels – The current labels object; results will be added to this.
config_info_list – List of ConfigFileInfo with configs for training and inference.
inference_params – Parameters to pass to inference.
frames_to_predict – Dict that gives list of frame indices for each video.
- Returns
Number of new frames added to labels.
-
sleap.gui.learning.runners.
train_subprocess
(job_config: sleap.nn.config.training_job.TrainingJobConfig, labels_filename: str, video_paths: Optional[List[str]] = None, waiting_callback: Optional[Callable] = None, save_viz: bool = False)[source]¶ Runs training inside subprocess.
-
sleap.gui.learning.runners.
write_pipeline_files
(output_dir: str, labels_filename: str, config_info_list: List[sleap.gui.learning.configs.ConfigFileInfo], inference_params: Dict[str, Any], items_for_inference: sleap.gui.learning.runners.ItemsForInference)[source]¶ Writes the config files and scripts for manually running pipeline.