Source code for satorbis_kit.inference.base_inference

from abc import ABC, abstractmethod
from typing import Any, Dict
from types import SimpleNamespace



[docs] class BaseInference(ABC): """ Base class for inference modules. Provides a standardized template for model inference pipelines, ensuring consistent error handling, and configuration management across different model implementations. """ def __init__(self, config: Dict[str, Any]): """ Initialize the inference class. :param config: Dictionary containing model configuration. """ self.config = SimpleNamespace(**config) self.model = None
[docs] @abstractmethod def load_model(self): """Load the model into memory.""" pass
[docs] @abstractmethod def validate_input(self, data: Any) -> Any: """Validate the input data format and constraints.""" pass
[docs] @abstractmethod def preprocess(self, data: Any) -> Any: """Prepare the data for model prediction.""" pass
[docs] @abstractmethod def predict(self, data: Any) -> Any: """Execute the model prediction.""" pass
[docs] @abstractmethod def postprocess(self, data: Any) -> Any: """Transform model output into the desired format.""" pass
[docs] @abstractmethod def validate_output(self, data: Any) -> Any: """Validate the final output before returning.""" pass