From bc38a93f731c3c232e98a423419aa3ddf5e2cff6 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Thu, 11 May 2023 04:17:50 +0300 Subject: [PATCH] Fix error in parsing DeepStack response JSON and handle cases where predictions field is missing --- frigate/detectors/plugins/deepstack.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frigate/detectors/plugins/deepstack.py b/frigate/detectors/plugins/deepstack.py index 716065903c..9d2c695405 100644 --- a/frigate/detectors/plugins/deepstack.py +++ b/frigate/detectors/plugins/deepstack.py @@ -56,8 +56,11 @@ def detect_raw(self, tensor_input): ) response_json = response.json() detections = np.zeros((20, 6), np.float32) + if response_json.get("predictions") is None: + logger.debug(f"Error in parsing response json: {response_json}") + return detections - for i, detection in enumerate(response_json["predictions"]): + for i, detection in enumerate(response_json.get("predictions")): logger.debug(f"Response: {detection}") if detection["confidence"] < 0.4: logger.debug(f"Break due to confidence < 0.4")