Add check for valid label index for object detection (#7149) (#7164)

This commit is contained in:
Nate Meyer 2023-07-14 20:01:53 -04:00 committed by GitHub
parent dc2e786a6f
commit 5bb5e2dc5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,9 @@ class LocalObjectDetector(ObjectDetector):
raw_detections = self.detect_raw(tensor_input)
for d in raw_detections:
if int(d[0]) < 0 or int(d[0]) >= len(self.labels):
logger.warning(f"Raw Detect returned invalid label: {d}")
continue
if d[1] < threshold:
break
detections.append(