I am writing a python script based on the object detection example.
It is mostly working however I have one oddity where I think I am missing something. When the script is done, it segmentation faults, so my guess is, I have to close something?
Hi @konstantin.agouros,
It’s hard to tell exactly what’s the issue without inspecting the code, but segmentation fault happens mostly when you are trying to access memory that is not allocated or have been deallocated. It might be that you continue running after something got closed\deallocated and you try to access it once again.
Well it is a python script so I don’t do active memory allocation like I would in a C program.
The Segfault happens if the script is finished after using the inference on the hailo board in between so my question is: If using the python api do I have to deregister or close something?
Hi @konstantin.agouros,
In the Python API you need to release the device at the end of your run. Did you use the “with … as” option when opening the device?
Basically, for example it should look something like this:
devices = Device.scan()
hef = HEF(args.hef)
with VDevice(device_ids=devices) as target:
configure_params = ConfigureParams.create_from_hef(hef, interface=HailoStreamInterface.PCIe)
network_group = target.configure(hef, configure_params)[0]
network_group_params = network_group.create_params()
[log.info('Input layer: {:20.20} {}'.format(li.name, li.shape)) for li in hef.get_input_vstream_infos()]
[log.info('Output layer: {:20.20} {}'.format(li.name, li.shape)) for li in hef.get_output_vstream_infos()]
# Note: If you need to normalize the image, choose and change the set_resized_input function to right values
if images_path:
resized_images = [set_resized_input(lambda size: image.resize(size, Image.LANCZOS), width=width, height=height) for image in images]
else:
resized_images = images
send_process = Process(target=send, args=(network_group, resized_images, num_images))
recv_process = Process(target=recv, args=(network_group, num_images))
start_time = time.time()
recv_process.start()
send_process.start()
with network_group.activate(network_group_params):
recv_process.join()
send_process.join()
You can also use the Python examples we have in out Hailo Applications git repo:
I used the code that You quoted as basis. However what happens at the end, when recv_process and send_process are finished. That is the missing part for me as I am not working multithreaded.