Merge pull request #45 from roboflow/fix/042_fix_with_nms_when_detections_is_empty

🧪 ready for tests
This commit is contained in:
Piotr Skalski 2023-03-13 22:08:15 +01:00 committed by GitHub
commit 65090f612c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -249,6 +249,9 @@ class Detections:
Raises:
AssertionError: If `confidence` is None and class_agnostic is False. If `class_id` is None and class_agnostic is False.
"""
if len(self) == 0:
return self
assert (
self.confidence is not None
), f"Detections confidence must be given for NMS to be executed."

View File

@ -11,6 +11,12 @@ from supervision.detection.utils import non_max_suppression
@pytest.mark.parametrize(
"predictions, iou_threshold, expected_result, exception",
[
(
np.empty(shape=(0, 5)),
0.5,
np.array([]),
DoesNotRaise()
), # single box with no category
(
np.array([
[10.0, 10.0, 40.0, 40.0, 0.8]