CRASH when running hef inference model with Hailo8L and Raspberry Pi 5

Please help! I will very appreciate!

Recently, I have built myself a face identification project with arcface_mobilefacenet.hef using Hailo8L and Raspberry Pi 5 (Both scrfd.py and the model is retrieved from hailo model zoo). However, after I had configured some Hailo8L and model parameters code, I tested an API and then the server code crashed immediately. Though, the code with no Hailo8L support run smoothly.
Note: I have checked the compatibility between the kit and the model, the Hailo8L connection (Raspberry PI 5 Kit recognizes Hailo8L).

After a couple days, I can’t find out the reason of this problem.

Does anyone have the same situation or have experience about this, please give me some advice!?

Here is a piece of the Hailo8L configure code:

from scrfd import SCRFDPostProc

from hailo_platform import (Device,
                            VDevice,
                            HailoStreamInterface,
                            HEF, ConfigureParams,
                            InputVStreamParams, 
                            OutputVStreamParams, 
                            InferVStreams, 
                            InputVStreams, 
                            OutputVStreams)



with open("/usr/share/hailo-models/scrfd_2.5g_h8l.json") as f:
    config = json.load(f)

anchors = config["anchors"]
if "strides" in anchors and "steps" not in anchors:
    anchors["steps"] = anchors["strides"]

# send param SCRFDPostProc support
scrfd_decoder = SCRFDPostProc(
    image_dims=tuple(config["input_shape"][:2]),
    anchors=anchors
)
# ==============================
# Hailo inference
def _make_vstream_params_dict(make_fn, network_group, infos):
    """
    Helper: call make_fn(network_group, info) or make_fn(info),
    và normalize result -> dict {stream_name: VStreamParams}.
    """
    params = {}
    for info in infos:
        made = None
        try:
            made = make_fn(network_group, info)
        except TypeError:
            try:
                made = make_fn(info)
            except TypeError:
                made = make_fn()

        # Normalize nested dicts -> flatten
        if isinstance(made, dict):
            for k, v in made.items():
                if isinstance(v, dict):
                    params.update(v)
                else:
                    params[k] = v
        else:
            params[info.name] = made
    return params
# ==============================

def run_hailo_inference(hef_path, input_tensor):
    hef = HEF(hef_path)
    vdevice = VDevice()
    configure_params = ConfigureParams.create_from_hef(hef, HailoStreamInterface.PCIe)

    # configure return list (network groups) -> get first group
    network_groups = vdevice.configure(hef, configure_params)
    if isinstance(network_groups, (list, tuple)):
        if len(network_groups) == 0:
            raise RuntimeError("vdevice.configure returned empty list")
        network_group = network_groups[0]
    else:
        network_group = network_groups

    input_infos = hef.get_input_vstream_infos()
    output_infos = hef.get_output_vstream_infos()
    input_name = input_infos[0].name

    # Input/Output params
    make_input_fn = getattr(InputVStreamParams, "make", InputVStreamParams)
    make_output_fn = getattr(OutputVStreamParams, "make", OutputVStreamParams)

    input_params = _make_vstream_params_dict(make_input_fn, network_group, input_infos)
    output_params = _make_vstream_params_dict(make_output_fn, network_group, output_infos)

    outputs = {}

    # Activate before vstreams
    with network_group.activate():
        with InputVStreams(network_group, input_params) as input_vstreams, \
             OutputVStreams(network_group, output_params) as output_vstreams:

            # Input
            for in_vstream in input_vstreams:
                if in_vstream.name == input_name:
                    in_vstream.send(input_tensor)

            # Output
            for out_vstream in output_vstreams:
                outputs[out_vstream.name] = out_vstream.recv()

    return outputs

Did you get any error message when it crashes?

No sir. The linux terminal had no log. It just crashed out and entire the project stop.
But in the postmant log had only an information like this: “Error: socket hang up”

Another information that I find out after checking is that the API request body note “image: undifined”.
Does this relate to the way I config model param?

Hey @danh_cao ,

Welcome to the Hailo Community!

I would look at how we do the inference in here : Hailo-Application-Code-Examples/runtime/hailo-8/python/common/hailo_inference.py at main · hailo-ai/Hailo-Application-Code-Examples · GitHub

Also you have hailort.log can you provide so i can help you better!

Thank you so much! I will try out first!