From 25e39edbcdabf6485d5863449807e5174e394beb Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Thu, 29 Aug 2019 15:04:32 +0200 Subject: [PATCH] Added check for empty detections in top k application Signed-off-by: Jim Martens --- src/twomartens/masterthesis/ssd.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/twomartens/masterthesis/ssd.py b/src/twomartens/masterthesis/ssd.py index 74647e5..4d5b627 100644 --- a/src/twomartens/masterthesis/ssd.py +++ b/src/twomartens/masterthesis/ssd.py @@ -438,6 +438,10 @@ def _apply_top_k(detections: Sequence[np.ndarray], top_k: float) -> List[np.ndar ('ymax', 'f4')]) for i in range(batch_size): image_detections = detections[i] + if not image_detections.size: + final_detections.append(image_detections) + continue + image_detections_structured = np.core.records.fromarrays(image_detections.transpose(), dtype=data_type) descending_indices = np.argsort(-image_detections_structured['confidence'])