From fa0f509e18feba10284a99f36f33dc82b6ab162b Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 3 Mar 2024 17:17:56 -0700 Subject: [PATCH] Fix case where model path is set but not labelmap path (#10215) --- frigate/util/builtin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frigate/util/builtin.py b/frigate/util/builtin.py index b015c475b..30388251d 100644 --- a/frigate/util/builtin.py +++ b/frigate/util/builtin.py @@ -9,7 +9,7 @@ import urllib.parse from collections import Counter from collections.abc import Mapping from pathlib import Path -from typing import Any, Tuple +from typing import Any, Optional, Tuple import numpy as np import pytz @@ -139,7 +139,7 @@ def get_ffmpeg_arg_list(arg: Any) -> list: return arg if isinstance(arg, list) else shlex.split(arg) -def load_labels(path, encoding="utf-8", prefill=91): +def load_labels(path: Optional[str], encoding="utf-8", prefill=91): """Loads labels from file (with or without index numbers). Args: path: path to label file. @@ -147,6 +147,9 @@ def load_labels(path, encoding="utf-8", prefill=91): Returns: Dictionary mapping indices to labels. """ + if path is None: + return {} + with open(path, "r", encoding=encoding) as f: labels = {index: "unknown" for index in range(prefill)} lines = f.readlines()