sleap.nn.inference¶
Inference pipelines and utilities.
-
class
sleap.nn.inference.
BottomupPredictor
(bottomup_config: sleap.nn.config.training_job.TrainingJobConfig, bottomup_model: sleap.nn.model.Model, peak_threshold: float = 0.2)[source]¶ -
classmethod
from_trained_models
(bottomup_model_path: str) → sleap.nn.inference.BottomupPredictor[source]¶ Create predictor from saved models.
-
classmethod
-
class
sleap.nn.inference.
MockPredictor
(labels: sleap.io.dataset.Labels)[source]¶
-
class
sleap.nn.inference.
SingleInstancePredictor
(confmap_config: sleap.nn.config.training_job.TrainingJobConfig, confmap_model: sleap.nn.model.Model, peak_threshold: float = 0.2, integral_refinement: bool = True, integral_patch_size: int = 5)[source]¶ -
classmethod
from_trained_models
(confmap_model_path: str, peak_threshold: float = 0.2, integral_refinement: bool = True, integral_patch_size: int = 5) → sleap.nn.inference.SingleInstancePredictor[source]¶ Create predictor from saved models.
-
classmethod
-
class
sleap.nn.inference.
TopdownPredictor
(centroid_config: Optional[sleap.nn.config.training_job.TrainingJobConfig] = None, centroid_model: Optional[sleap.nn.model.Model] = None, confmap_config: Optional[sleap.nn.config.training_job.TrainingJobConfig] = None, confmap_model: Optional[sleap.nn.model.Model] = None, batch_size: int = 1, peak_threshold: float = 0.2, integral_refinement: bool = True, integral_patch_size: int = 5)[source]¶ -
classmethod
from_trained_models
(centroid_model_path: Optional[str] = None, confmap_model_path: Optional[str] = None, batch_size: int = 1, peak_threshold: float = 0.2, integral_refinement: bool = True, integral_patch_size: int = 5) → sleap.nn.inference.TopdownPredictor[source]¶ Create predictor from saved models.
- Parameters
centroid_model_path – Path to centroid model folder.
confmap_model_path – Path to topdown confidence map model folder.
- Returns
An instance of TopdownPredictor with the loaded models.
One of the two models can be left as None to perform inference with ground truth data. This will only work with LabelsReader as the provider.
-
classmethod
-
class
sleap.nn.inference.
VisualPredictor
(config: sleap.nn.config.training_job.TrainingJobConfig, model: sleap.nn.model.Model)[source]¶ Predictor class for generating the visual output of model.
-
sleap.nn.inference.
find_heads_for_model_paths
(paths) → Dict[str, str][source]¶ Given list of models paths, returns dict with path keyed by head name.
-
sleap.nn.inference.
make_predictor_from_models
(trained_model_paths: Dict[str, str], labels_path: Optional[str] = None, policy_args: Optional[dict] = None) → sleap.nn.inference.Predictor[source]¶ Given dict of paths keyed by head name, returns appropriate predictor.
-
sleap.nn.inference.
make_predictor_from_paths
(paths) → sleap.nn.inference.Predictor[source]¶ Builds predictor object from a list of model paths.