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

Fix: KeyError when specifying custom rknn model #12028

Closed
wants to merge 1 commit into from
Closed
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 frigate/detectors/plugins/rknn.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, config: RknnDetectorConfig):
core_mask = 2**config.num_cores - 1
soc = self.get_soc()

model_props = self.parse_model_input(config.model.path, soc)
model_props = self.parse_model_input(config, soc)

if model_props["preset"]:
config.model.model_type = model_props["model_type"]
Expand Down Expand Up @@ -75,14 +75,22 @@ def get_soc(self):

return soc

def parse_model_input(self, model_path, soc):
def parse_model_input(self, config, soc):
model_path = config.model.path

model_props = {}

# find out if user provides his own model
# user provided models should be a path and contain a "/"
if "/" in model_path:
model_props["preset"] = False
model_props["path"] = model_path
if config.model.model_type:
model_props["model_type"] = config.model.model_type
else:
raise Exception(
"You must specify model_type if specifying your own model file."
)
Comment on lines +90 to +93
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that config.model.model_type defaults to ssd so this isn't needed, but following defensive programming and separation of concern best practices, I deemed this the best way forward.

else:
model_props["preset"] = True

Expand Down