Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic support for multiple Hailo models #1140

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions picamera2/devices/hailo/hailo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@


class Hailo:
TARGET = None
TARGET_REF_COUNT = 0

def __init__(self, hef_path, batch_size=None, output_type='FLOAT32'):
"""
Initialize the HailoAsyncInference class with the provided HEF model file path.
Expand All @@ -20,7 +23,10 @@ def __init__(self, hef_path, batch_size=None, output_type='FLOAT32'):

self.batch_size = batch_size
self.hef = HEF(hef_path)
self.target = VDevice(params)
if Hailo.TARGET is None:
Hailo.TARGET = VDevice(params)
Hailo.TARGET_REF_COUNT += 1
self.target = Hailo.TARGET
self.infer_model = self.target.create_infer_model(hef_path)
self.infer_model.set_batch_size(1 if batch_size is None else batch_size)
self._set_input_output(output_type)
Expand Down Expand Up @@ -175,4 +181,6 @@ def _create_bindings(self):
def close(self):
"""Release the Hailo device."""
del self.configured_infer_model
self.target.release()
Hailo.TARGET_REF_COUNT -= 1
if Hailo.TARGET_REF_COUNT == 0:
self.target.release()
Loading