HailoInference_async_multimodel
index
/home/bedrock/Desktop/project/AlertWatch/Production/detector/inference/HailoInference_async_multimodel.py

Hailo Inference Module
 
This module provides functionality to perform asynchronous inference using the Hailo platform.
It supports running multiple models concurrently, configuring network groups, and handling inference pipelines.
 
Classes:
    - HailoInferenceAsyncMultiModel: Manages multiple inference models on a Hailo device.
 
Functions:
    - initialize_inference_models: Initializes face detection and face landmarks models for inference.
 
Dependencies:
    - hailo_platform: For Hailo device and model configuration.
    - numpy: For numerical operations and input data manipulation.
    - subprocess: For interacting with external commands (e.g., `hailortcli`).
 
Usage:
    Use the `initialize_inference_models` function to set up models for face detection and landmarks inference.
 
Author:
    Lior Jigalo
 
License:
    MIT

 
Modules
       
numpy
subprocess

 
Classes
       
builtins.object
HailoInferenceAsyncMultiModel

 
class HailoInferenceAsyncMultiModel(builtins.object)
    HailoInferenceAsyncMultiModel(model_paths, input_types=('UINT8', 'UINT8'), output_types=('UINT8', 'UINT8'))
 
Manages multiple inference models on a Hailo device.
 
This class handles the configuration of two models, their network groups, input/output stream parameters,
and provides methods to run inference on the models.
 
Attributes:
    model_paths (tuple): Paths to the HEF files for the two models.
    models (dict): Contains model-specific configuration and parameters.
    target (VDevice): Represents the Hailo VDevice.
 
Methods:
    __init__: Initializes the inference object with two models.
    _get_hailo_architecture: Detects the Hailo device architecture.
    _load_model: Configures a model and sets up its network group.
    get_input_shape: Returns the shape of the input layer for a specific model.
    run: Executes inference on the specified model.
    release_device: Releases the Hailo VDevice.
 
  Methods defined here:
__init__(self, model_paths, input_types=('UINT8', 'UINT8'), output_types=('UINT8', 'UINT8'))
Initialize the Hailo inference object with two models.
 
Args:
    model_paths (tuple): Paths to the two HEF files.
    input_types (tuple): Input types for the two models (default: UINT8).
    output_types (tuple): Output types for the two models (default: UINT8).
get_input_shape(self, model_id=1)
Return the shape of the input layer for a specific model.
 
Args:
    model_id (int): The ID of the model (1 or 2).
 
Returns:
    tuple: Shape of the input layer.
release_device(self)
Release the VDevice.
run(self, model_id, input_data)
Run inference on the specified model.
 
Args:
    model_id (int): The ID of the model (1 or 2).
    input_data (np.ndarray): The input data for inference.
 
Returns:
    dict: Output data from the inference.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
initialize_inference_models(face_det_path, face_landmark_path)
Initializes the Hailo inference models for face detection and face landmarks.
 
Args:
    face_det_path (str): Path to the face detection HEF file.
    face_landmark_path (str): Path to the face landmarks HEF file.
 
Returns:
    tuple: Contains the following:
        - hailo_inference (HailoInferenceAsyncMultiModel): Initialized inference object.
        - face_detection_input_shape (tuple): Input shape for the face detection model.
        - face_landmarks_input_shape (tuple): Input shape for the face landmarks model.
        - face_land_output_name (str): Name of the output stream for the landmarks model.