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

Add handling for non-existent or empty model file paths #6525

Merged
Merged
Changes from 1 commit
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
14 changes: 9 additions & 5 deletions frigate/detectors/detector_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@ def check_and_load_plus_model(
}

def compute_model_hash(self) -> None:
with open(self.path, "rb") as f:
file_hash = hashlib.md5()
while chunk := f.read(8192):
file_hash.update(chunk)
self._model_hash = file_hash.hexdigest()
if not self.path or not os.path.exists(self.path):
print("File does not exist or path is empty.")
skrashevich marked this conversation as resolved.
Show resolved Hide resolved
self._model_hash = hashlib.md5(b"unknown").hexdigest()
else:
with open(self.path, "rb") as f:
file_hash = hashlib.md5()
while chunk := f.read(8192):
file_hash.update(chunk)
self._model_hash = file_hash.hexdigest()

def create_colormap(self, enabled_labels: set[str]) -> None:
"""Get a list of colors for enabled labels."""
Expand Down