darcyai.perceptor.perceptor_utils

get_supported_processors

def get_supported_processors() -> dict

Gets the list of supported processors.

Returns

dict - The list of supported processors.

Examples

>>> get_supported_processors()
{<Processor.CORAL_EDGE_TPU: 1>: {'is_available': True, 'coral_tpus': [{'type': 'usb', 'path':\
'/sys/bus/usb/devices/2-2'}]}, <Processor.CPU: 2>: {'is_available': True, 'cpu_count': 4}}

get_perceptor_processor

def get_perceptor_processor(processor_preference: list) -> Processor

Gets the processor for the perceptor.

Arguments

  • processor_preference (list): The list of preferred processors.

Returns

Processor - The processor for the perceptor.

Examples

>>> from darcyai.perceptor.processor import Processor
>>> processor_preference = [Processor.CORAL_EDGE_TPU, Processor.CPU]
>>> get_perceptor_processor(processor_preference)
Processor.CORAL_EDGE_TPU

validate_processor_preference

def validate_processor_preference(processor_preference,
                                  model_path_required=True)

Validate the processor preference.

Arguments

  • processor_preference: A dictionary of processor preference. The key is the processor. Values are dictionaries of model paths and labels.

Raises

  • Exception: If the processor preference is invalid.

Examples

>>> from darcyai.perceptor.processor import Processor
>>> processor_preference = {
        Processor.CORAL_EDGE_TPU: {
            "model_path": "/path/to/model.tflite",
            "labels_file": "/path/to/labels.txt",
        },
        Processor.CPU: {
            "model_path": "/path/to/model.tflite",
            "labels_file": "/path/to/labels.txt",
        },
    }
>>> validate_processor_preference(processor_preference)

validate_processor_list

def validate_processor_list(processor_list)

Validate the processor list.

Arguments

  • processor_list: A list of processors.

Raises

  • Exception: If the processor preference is invalid.

Examples

>>> from darcyai.perceptor.processor import Processor
>>> processor_list = [Processor.CORAL_EDGE_TPU, Processor.CPU]
>>> validate_processor_list(processor_list)