darcyai.perceptor.perceptor
Perceptor Objects
class Perceptor(Configurable, EventEmitter)
The Perceptor class is the base class for all perceptors.
Arguments
- model_path (
str
): The path to the model file.
Examples
>>> from darcyai.perceptor import Perceptor
>>> class MyPerceptor(Perceptor):
>>> def __init__(self):
... Perceptor.__init__(self, "path/to/model")
>>> def run(self, input_data):
... return input_data.data
>>> def load(self):
... pass
run
def run(input_data: Any, config: ConfigRegistry = None) -> Any
Runs the perceptor on the input data.
Arguments
- input_data (
StreamData
): The input data to run the perceptor on. - config (
ConfigRegistry
): The configuration for the perceptor. Defaults toNone
.
Returns
Any
: The output of the perceptor.
load
def load(accelerator_idx: Union[int, None] = None) -> None
Loads the perceptor.
Arguments
- accelerator_idx (
int, None
): The index of the accelerator to load the perceptor on. Defaults toNone
.
is_loaded
def is_loaded() -> bool
Checks if the perceptor is loaded.
Returns
bool
: True if the perceptor is loaded, False otherwise.
set_loaded
def set_loaded(loaded: bool) -> None
Sets the perceptor loaded state.
Arguments
- loaded (
bool
): The loaded state.
set_config_value
def set_config_value(key: str, value: Any)
Sets a config value.
Arguments
- key (
str
): The key of the config. - value (
Any
): The value to set.
get_config_value
def get_config_value(key: str) -> Any
Gets a config value.
Arguments
- key (
str
): The key of the config.
Returns
Any
: The value of the config.
init_config_registry
def init_config_registry()
Initializes the config registry.