Added check for empty detections in top k application

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
Jim Martens 2019-08-29 15:04:32 +02:00
parent da322e287f
commit 25e39edbcd
1 changed files with 4 additions and 0 deletions

View File

@ -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'])