Skip to content

base

sleap_nn.export.predictors.base

Predictor base class for exported models.

Classes:

Name Description
ExportPredictor

Base interface for exported model inference.

ExportPredictor

Bases: ABC

Base interface for exported model inference.

Methods:

Name Description
benchmark

Benchmark inference latency and throughput.

predict

Run inference on a batch of images.

Source code in sleap_nn/export/predictors/base.py
class ExportPredictor(ABC):
    """Base interface for exported model inference."""

    @abstractmethod
    def predict(self, image: np.ndarray) -> Dict[str, np.ndarray]:
        """Run inference on a batch of images."""

    @abstractmethod
    def benchmark(
        self, image: np.ndarray, n_warmup: int = 50, n_runs: int = 200
    ) -> Dict[str, float]:
        """Benchmark inference latency and throughput."""

benchmark(image, n_warmup=50, n_runs=200) abstractmethod

Benchmark inference latency and throughput.

Source code in sleap_nn/export/predictors/base.py
@abstractmethod
def benchmark(
    self, image: np.ndarray, n_warmup: int = 50, n_runs: int = 200
) -> Dict[str, float]:
    """Benchmark inference latency and throughput."""

predict(image) abstractmethod

Run inference on a batch of images.

Source code in sleap_nn/export/predictors/base.py
@abstractmethod
def predict(self, image: np.ndarray) -> Dict[str, np.ndarray]:
    """Run inference on a batch of images."""