Hey everybody, i found some code which helped me to run a network on the Raspberry Pi with the AI Kit.
I found it here How do I increase the max queue size for HailoRT? - #4 by omria.
import numpy as np
from hailo_platform import (
HEF, VDevice, HailoStreamInterface, InferVStreams,
ConfigureParams, InputVStreamParams, OutputVStreamParams, FormatType
)
def run_inference(hef_path, num_images=1):
# Load model
hef = HEF(hef_path)
# Setup device and configure model
with VDevice() as device:
# Configure network
config_params = ConfigureParams.create_from_hef(
hef=hef,
interface=HailoStreamInterface.PCIe
)
configuration = device.configure(hef, config_params)
network_group = configuration[0]
# Setup streams
input_params = InputVStreamParams.make(
network_group,
format_type=FormatType.FLOAT32
)
output_params = OutputVStreamParams.make(
network_group,
format_type=FormatType.FLOAT32
)
# Prepare input data
input_info = hef.get_input_vstream_infos()[0]
h, w, c = input_info.shape
dataset = np.random.rand(num_images, h, w, c).astype(np.float32)
# Run inference
with network_group.activate():
with InferVStreams(network_group, input_params, output_params) as pipeline:
results = pipeline.infer({input_info.name: dataset})
return results
This was a good starting point for me.